jumpstorm/engine/config/sprites.ts

49 lines
1003 B
TypeScript
Raw Normal View History

2023-07-19 23:38:24 -04:00
export enum Sprites {
FLOOR,
TRAMPOLINE,
2023-08-25 18:48:17 -04:00
COFFEE
2023-07-19 23:38:24 -04:00
}
export interface SpriteSpec {
sheet: string;
width: number;
height: number;
frames: number;
msPerFrame: number;
2023-08-12 15:49:16 -04:00
states?: Map<string | number, Partial<SpriteSpec>>;
2023-07-19 23:38:24 -04:00
}
export const SPRITE_SPECS: Map<Sprites, Partial<SpriteSpec>> = new Map<
Sprites,
SpriteSpec
>();
const floorSpriteSpec = {
height: 40,
frames: 3,
msPerFrame: 125,
2023-08-25 18:48:17 -04:00
states: new Map<number, Partial<SpriteSpec>>()
2023-07-19 23:38:24 -04:00
};
2023-08-12 15:49:16 -04:00
[40, 80, 120, 160].forEach((width) => {
floorSpriteSpec.states.set(width, {
width,
2023-08-25 18:48:17 -04:00
sheet: `/assets/floor_tile_${width}.png`
2023-08-12 15:49:16 -04:00
});
});
2023-07-19 23:38:24 -04:00
SPRITE_SPECS.set(Sprites.FLOOR, floorSpriteSpec);
2023-08-12 15:49:16 -04:00
const coffeeSpriteSpec = {
2023-07-19 23:38:24 -04:00
msPerFrame: 100,
width: 60,
height: 45,
frames: 3,
2023-08-25 18:48:17 -04:00
states: new Map<string, Partial<SpriteSpec>>()
2023-08-12 15:49:16 -04:00
};
2023-08-25 18:48:17 -04:00
coffeeSpriteSpec.states.set('LEFT', {
sheet: '/assets/coffee_left.png'
2023-08-12 15:49:16 -04:00
});
2023-08-25 18:48:17 -04:00
coffeeSpriteSpec.states.set('RIGHT', {
sheet: '/assets/coffee_right.png'
2023-07-19 23:38:24 -04:00
});
2023-08-12 15:49:16 -04:00
SPRITE_SPECS.set(Sprites.COFFEE, coffeeSpriteSpec);