This commit is contained in:
Baptiste 2023-12-07 09:51:55 +01:00
parent 5cd1b4fd59
commit f636d6de6a
3 changed files with 12 additions and 0 deletions

BIN
assets/car.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

View file

@ -1,6 +1,7 @@
let mapWidth = 210.;
let mapHeith = 100.;
const playerSize = 50.;
const carSize = 50.;
const playerSpeed=.2;
const bulletSpeed=playerSpeed*2;
const halfSqrtTwo=0.70710678118;

View file

@ -1,7 +1,10 @@
const imgPlayer = new Image();
const imgBullet = new Image();
const imgCar = new Image();
imgPlayer.src = "./assets/body.png";
imgBullet.src = "./assets/bullet.png";
imgCar.src = "./assets/car.png";
class Render {
constructor(id, mapsrc) {
@ -62,6 +65,14 @@ class Render {
}
}
RenderCar(x,y, angle) {
this.ctx.save();
this.ctx.translate(x, y);
this.ctx.rotate(angle);
this.ctx.drawImage(imgCar, -carSize / 2, -carSize / 2, carSize, carSize);
this.ctx.restore();
}
RenderBullet(bullet) {
this.ctx.save();
this.ctx.translate(bullet.x, bullet.y);