M.E.R.G.E

This commit is contained in:
JusDeChâtaigne
2023-12-08 07:30:39 +01:00
committed by GitHub
parent 4968c7049e
commit 21cdf31bc5
24 changed files with 812 additions and 9 deletions
+65
View File
@@ -0,0 +1,65 @@
class ArrowSprite {
constructor(direction) {
this.direction = direction;
this.width = 75;
this.height = 75;
this.y = 700;
this.dy = 0;
this.points = true;
this.combo = true;
this.drawArrow = this.drawArrow.bind(this);
this.arrowParams(direction);
}
arrowParams(direction) {
this.directionImage = new Image();
switch (direction) {
case "left":
this.directionImage.src = "assets/leftArrowDynamic.png";
this.shift = 0;
this.x = 84.375;
break;
case "down":
this.directionImage.src = "assets/downArrowDynamic.png";
this.shift = 300;
this.x = 154.6875;
break;
case "up":
this.directionImage.src = "assets/upArrowDynamic.png";
this.shift = 600;
this.x = 225;
break;
case "right":
this.directionImage.src = "assets/rightArrowDynamic.png";
this.shift = 900;
this.x = 295.3125;
break;
}
}
drawArrow() {
let numFrames = 0;
const animate = () => {
numFrames++;
ctx.drawImage(
this.directionImage,
this.shift,
0,
this.width,
this.height,
this.x,
this.y,
this.width,
this.height
);
this.y += this.dy;
if (numFrames === 15) {
this.shift += this.width;
numFrames = 0;
this.shift = this.shift === 1200 ? 0 : this.shift;
}
requestAnimationFrame(animate);
};
animate();
}
}