<canvas id="canvas" width="300px" height="300px"></canvas>
<script>
var cvs = document.getElementById("canvas");
var ctx = cvs.getContext("2d");
var tank1 = new Image();
var mario = new Image();
tank1.src = "https://javascript.ru/cat/list/jquery_54.png";
mario.src = "https://javascript.ru/cat/list/donkey.gif";
function draw () {
var x = Math.floor(Math.random() * 100 + 1);
ctx.drawImage(tank1, 100, 100);
ctx.drawImage(mario, x, 114);
}
//tank1.onload = draw;
mario.onload = draw;
</script>