Files
bworld/common/constants.ts
T
2026-09-25 17:14:26 -03:00

42 lines
1.1 KiB
TypeScript

export const TEXTURE_SIZE = 16;
export const TICKS_PER_SECOND = 20;
export const TICK_DELTA = 1 / TICKS_PER_SECOND;
export const SLOT_SIZE = 18 * 3;
export interface SpriteRegion {
x: number;
y: number;
}
export const faces = ["west", "east", "bottom", "top", "north", "south"] as const;
export type Faces = typeof faces[number];
export const AIR = 0;
export const VOID = 0xFFFFFFFF;
export const ID_MASK = 0xFFFF;
export const STATE_SHIFT = 16;
export const CHUNK_SIZE = 16;
export const CHUNK_HEIGHT = 256;
// the top of oceans and rivers
export const SEA_LEVEL = 64;
export const CHUNK_AREA = CHUNK_SIZE * CHUNK_SIZE;
// the player's collision box, position is the middle of its feet
export const PLAYER_WIDTH = 0.55;
export const PLAYER_HEIGHT = 1.79;
export const PLAYER_EYE_HEIGHT = 1.69;
// where a block placed against each face of another block goes
export const FACE_OFFSETS: Record<Faces, { x: number; y: number; z: number }> = {
top: { x: 0, y: 1, z: 0 },
bottom: { x: 0, y: -1, z: 0 },
north: { x: 0, y: 0, z: -1 },
south: { x: 0, y: 0, z: 1 },
west: { x: -1, y: 0, z: 0 },
east: { x: 1, y: 0, z: 0 },
};