JSFiddle - React, Tailwind, and code Playground

HTML

<div class="boris">

</div>

CSS

.boris {
  width:800px;
  height:800px;
  background-color:black;
  position:relative;
}

JavaScript

var arr = [];
function enemy() {
this.name = "Boris";
this.color = "red";
this.width = "50px";
this.height = "10px";
this.x = Math.floor((Math.random() * 200) + 1);
this.y = Math.floor((Math.random() * 200) + 1);
}
enemy.prototype.move = function() {
this.x++;
var chance = Math.random();
if(chance > 0.5) {
this.y++;
}
}
function create() {
var one = new enemy();
var div = document.createElement("DIV");
div.className = "div";
div.style.backgroundColor = one.color;
div.style.position = "absolute";
div.style.left = one.x + 'px';
div.style.top = one.y + 'px';
div.style.width = one.width;
div.style.height = one.height;
document.querySelector(".boris").appendChild(div);
setInterval(one.move, 100);
}
create();
create();