feat(#15): add basic animations implementation

This commit is contained in:
Juan Sebastián Montoya 2024-09-20 08:35:05 -05:00
parent 36bebe5237
commit 9403de1042
2 changed files with 105 additions and 19 deletions

View file

@ -50,6 +50,21 @@ const foregroundCollisionMaps = [
const clicableObjects = ["debug", "level1", "level2"];
const playerAnimations = {
idle: {
left: [51],
right: [17],
top: [34],
bottom: [0],
},
walk: {
left: [51, 52, 53, 54],
right: [17, 18, 19, 20],
top: [34, 35, 36, 37],
bottom: [0, 1, 2, 3],
},
};
class Game extends GameObject {
constructor({ canvas }) {
super();
@ -63,11 +78,11 @@ class Game extends GameObject {
const player = new Player({
speed: 1,
gameObjects: [new SpriteSheet({ imageId: "character", tileHeight: 32 })],
animations: playerAnimations,
x: 6 * TILE_SIZE,
y: 4 * TILE_SIZE,
width: TILE_SIZE,
height: 2 * TILE_SIZE,
debug: true,
});
const camera = new Camera({
gameObjects: [
@ -78,7 +93,7 @@ class Game extends GameObject {
],
target: player,
});
const fpsCounter = new FpsCounter({ debug: false });
const fpsCounter = new FpsCounter();
this.gameObjects = [canvasResizer, camera, fpsCounter];
this.canvas = canvas;