JSFiddle - React, Tailwind, and code Playground

HTML

<!doctype html>
<html>
<head>
    <title>rectExample</title>
    <meta charset='utf-8' />
</head>
<body>
<button id="downButton">down</button>
<button id="upButton">up</button>
<button id="rightButton">right</button>
<button id="leftButton">left</button>
<button id="pspeed">+ speed</button>
<button id="mspeed">- speed</button>
<button id="zerospeed"> zero speed</button>
<canvas id='example'>Обновите браузер</canvas>
<script>
    var example = document.getElementById("example"),
        ctx     = example.getContext('2d');
    ew = example.width  = 340;
    eh = example.height = 350;
    var downButton = document.getElementById("downButton");
    var upButton = document.getElementById("upButton");
    var rightButton = document.getElementById("rightButton");
    var leftButton = document.getElementById("leftButton");
    var pspeed = document.getElementById("pspeed");
    var mspeed = document.getElementById("mspeed");
    var zerospeed = document.getElementById("zerospeed");
    downButton.onclick = function () {
        side = 1
        y = y + s;
    }
    upButton.onclick = function () {
        side = 2
        y = y - s; }
    rightButton.onclick = function () {
        side = 3
        x = x + s; }
    leftButton.onclick = function () {
        side = 4
        x = x - s; }
    pspeed.onclick = function () { s = s + 1; }
    mspeed.onclick = function () { s = s - 1; }
    zerospeed.onclick = function () { s = 0; }
    var side = 0;
    var s = 10;
    var x = 10;
     var y = 10;
     var xb = 70;
     var yb = 70;
    ctx.strokeRect(x, y, 10, 10);
    ctx.strokeRect(x, y, 330, 340);




function anim() {
ctx.clearRect(0, 0, 340, 350);
ctx.font = "italic 20px Ariel";
ctx.fillText(s, 5, 10 + 25);
    ctx.fillText(side, 50, 10 + 25);
    ctx.strokeRect(x, y, 10, 10);
    ctx.strokeRect(0, 0, 330, 340);
ctx.fillStyle = 'black';
ctx.fillRect(xb, yb, 50, 50);

if (x <= 3) x = 4;
        if((side == 1) && (x + 11 >= xb) && (y + 11 >= yb) && (y < yb + 50) && (x <=...