summaryrefslogtreecommitdiff
path: root/src/engine/config/sprites.ts
blob: 7cb8adf329cc07cf30dcee2b219b61c0cb2d6db3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { Direction } from "../interfaces/Direction";

export enum Sprites {
  PLAYER,
  FUNCTION_BOX,
  WALL,
}

export interface SpriteSpec {
  sheet: string;
  width: number;
  height: number;
  frames: number;
  msPerFrame: number;
  states?: Map<string | number, Partial<SpriteSpec>>;
}

export const SPRITE_SPECS: Map<Sprites, Partial<SpriteSpec>> = new Map<
  Sprites,
  SpriteSpec
>();

const playerSpriteSpec = {
  msPerFrame: 200,
  width: 64,
  height: 64,
  frames: 3,
  states: new Map<string, Partial<SpriteSpec>>(),
};
playerSpriteSpec.states.set(Direction.NONE, {
  sheet: "/assets/lambda/neutral.png",
});
[Direction.LEFT, Direction.RIGHT, Direction.UP, Direction.DOWN].forEach(
  (direction) => {
    playerSpriteSpec.states.set(direction, {
      sheet: `/assets/lambda/${direction.toLowerCase()}.png`,
    });
  },
);
SPRITE_SPECS.set(Sprites.PLAYER, playerSpriteSpec);

const functionBoxSpriteSpec = {
  msPerFrame: 200,
  width: 64,
  height: 64,
  frames: 3,
  sheet: "/assets/function_block.png",
};
SPRITE_SPECS.set(Sprites.FUNCTION_BOX, functionBoxSpriteSpec);

const wallSpriteSpec = {
  msPerFrame: 200,
  width: 64,
  height: 64,
  frames: 3,
  sheet: "/assets/wall.png",
};
SPRITE_SPECS.set(Sprites.WALL, wallSpriteSpec);