Не могу сделать плавный прыжок ,кто знает помогите начинающему gameDev программитсу
let canvas = document.getElementById("canvas");
let ctx = canvas.getContext("2d");
let bg = new Image();
bg.src = "https://st2.depositphotos.com/2172301/10601/v/600/depositphotos_106013420-stock-illustration-seamless-cartoon-landscape-with-mountains.jpg";
let cactus = new Image();
cactus.src ="img/cactus.png";
let dog = new Image();
dog.src = "https://cdn2.iconfinder.com/data/icons/japan-flat-2/340/dog_pet_animal_japanese_shiba_inu_japan-256.png";
let dogX = 100;
let dogY = 250;
let pipe = [];
pipe[0] = {
x:canvas.width,
y:270
};
function draw(){
ctx.drawImage(bg,0,0);
ctx.drawImage(dog,dogX,dogY,100,100);
for(let i = 0;i<pipe.length;i++){
ctx.drawImage(cactus,pipe[i].x,pipe[i].y,80,80);
pipe[i].x -= speed;
if(pipe[i].x == 300){
pipe.push({
x:canvas.width,
y:270
});
}
}
requestAnimationFrame(draw);
}
function space(){
dogY -= 85;
}
document.addEventListener("keydown",space);
bg.onload = draw;