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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
import { Direction } from "../interfaces/Direction";
export enum Sprites {
PLAYER,
FUNCTION_BOX,
WALL,
LAMBDA_FACTORY,
KEY,
LOCKED_DOOR,
CURRY,
BUBBLE,
PORTAL,
GRASS,
}
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);
const lambdaFactorySpriteSpec = {
msPerFrame: 200,
width: 64,
height: 64,
frames: 3,
sheet: "/assets/function_factory.png",
};
SPRITE_SPECS.set(Sprites.LAMBDA_FACTORY, lambdaFactorySpriteSpec);
const keySpriteSpec = {
msPerFrame: 200,
width: 64,
height: 64,
frames: 3,
sheet: "/assets/key.png",
};
SPRITE_SPECS.set(Sprites.KEY, keySpriteSpec);
const lockedDoorSpriteSpec = {
msPerFrame: 200,
width: 64,
height: 64,
frames: 3,
sheet: "/assets/locked_door.png",
};
SPRITE_SPECS.set(Sprites.LOCKED_DOOR, lockedDoorSpriteSpec);
const currySpriteSpec = {
msPerFrame: 200,
width: 64,
height: 64,
frames: 3,
sheet: "/assets/curry.png",
};
SPRITE_SPECS.set(Sprites.CURRY, currySpriteSpec);
const bubbleSpriteSpec = {
msPerFrame: 200,
width: 64,
height: 64,
frames: 3,
sheet: "/assets/bubble.png",
};
SPRITE_SPECS.set(Sprites.BUBBLE, bubbleSpriteSpec);
const portalSpriteSpec = {
msPerFrame: 150,
width: 64,
height: 64,
frames: 9,
sheet: "/assets/portal.png",
};
SPRITE_SPECS.set(Sprites.PORTAL, portalSpriteSpec);
const grassSpriteSpec = {
msPerFrame: 200,
width: 64,
height: 64,
frames: 3,
sheet: "/assets/grass.png",
};
SPRITE_SPECS.set(Sprites.GRASS, grassSpriteSpec);
|