129 lines
2.5 KiB
TypeScript
129 lines
2.5 KiB
TypeScript
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);
|