export const ATLAS_TILE_WIDTH = 32 export const GAME_MAP_COUNT = 4 export enum Tile { EMPTY = 0, WALL = 1, GHOST_WALL = 2, FOOD = 3, PLAYER_SPAWN_1 = 4, PLAYER_SPAWN_2 = 5, PLAYER_SPAWN_3 = 6, PLAYER_SPAWN_4 = 7, GHOST_SPAWN = 8, THICC_DOT = 9, INITIAL_DOT = 10 } export enum Wall { EMPTY, WALL_HZ, WALL_VT, TURN_Q1, TURN_Q2, TURN_Q3, TURN_Q4, TEE_NORTH, TEE_EAST, TEE_SOUTH, TEE_WEST, CROSS, DOT, WALL_END_NORTH, WALL_END_SOUTH, WALL_END_EAST, WALL_END_WEST } export enum ItemType { DOT, THICC_DOT, FOOD } export enum Key { NOTHING, UP, DOWN, LEFT, RIGHT } export enum GhostType { BLINKY = 0, PINKY = 1, INKY = 2, CLYDE = 3 } export enum GhostState { CHASE, SCATTER, EATEN, SCARED } export type Ghost = { pos: Vec2, type: GhostType, target: Vec2, state: GhostState, currentDirection: Rotation, } export type KeyMap = { [key: string]: Key } export const GameKeyMap = { "KeyW": Key.UP, "KeyA": Key.LEFT, "KeyS": Key.DOWN, "KeyD": Key.RIGHT, } export enum Rotation { NOTHING, NORTH, EAST, SOUTH, WEST } export type Vec2 = { x: number, y: number } export type InputMap = { [key: number]: Key } export type Player = { pos: Vec2, moveRotation: Rotation, inputRotation: Rotation, moving: boolean, name?: string } export type PlayerInput = { start: boolean, key: Key, name?: string } export type Input = { players: {[key: number]: PlayerInput}, added?: number[], removed?: number[], } export type Message = { type?: string; connections?: number[], added?: number, removed?: number, id?: number, frame?: number, data?: any, connection?: number, state?: GameState, error?: string } export type Players = { [key: number]: Player } export type Item = { type: ItemType, pos: Vec2 } export type Items = { [key: number]: Item } export enum SpawnIndex { PAC_SPAWN_1 = 1, PAC_SPAWN_2 = 2, PAC_SPAWN_3 = 3, PAC_SPAWN_4 = 4, GHOST_SPAWN = 0 } export type Map = { data: number[], walls: number[], width: number, height: number, id: number, spawns?: Vec2[] } export type Maps = { [key: number]: Map } export type Ghosts = [Ghost, Ghost, Ghost, Ghost] export type GameState = { started: boolean, input: InputMap, players: Players, ghosts: Ghosts, items: Items, frame: number, rng: number, mapId: number | undefined } export type Frame = { data: GameState, input: Input }