Team Ai
Apppublic

broadfield-dev/stack-overflow-game

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
constants.js189 linesDownload Raw Back to src
1// Game dimensions2export const GAME_WIDTH = 256;3export const GAME_HEIGHT = 224;4export const BORDER_OFFSET = 21; // Offset for 21px borders on each side5 6// Bitmap font character set7export const BITMAP_FONT_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';8 9// Grid configuration10export const BLOCK_SIZE = 8; // 8x8 pixel blocks for retro feel11export const GRID_WIDTH = 10;12export const GRID_HEIGHT = 20;13export const PLAY_AREA_WIDTH = GRID_WIDTH * BLOCK_SIZE; // 80 pixels14export const PLAY_AREA_HEIGHT = GRID_HEIGHT * BLOCK_SIZE; // 160 pixels15export const PLAY_AREA_X = 80 + BORDER_OFFSET; // Centered with room for UI + border offset16export const PLAY_AREA_Y = 28; // Room for header (moved up 20 pixels from original 48)17 18// Level progression19export const LINES_PER_LEVEL = 2; // Temporary for testing20export const MAX_LEVEL = 10;21 22// Tetromino shapes (NES Tetris style)23export const TETROMINOES = {24  I: {25    shape: [[1, 1, 1, 1]],26    color: 0, // Will be replaced with palette color27    name: 'I'28  },29  O: {30    shape: [31      [1, 1],32      [1, 1]33    ],34    color: 1,35    name: 'O'36  },37  T: {38    shape: [39      [0, 1, 0],40      [1, 1, 1]41    ],42    color: 2,43    name: 'T'44  },45  S: {46    shape: [47      [0, 1, 1],48      [1, 1, 0]49    ],50    color: 3,51    name: 'S'52  },53  Z: {54    shape: [55      [1, 1, 0],56      [0, 1, 1]57    ],58    color: 4,59    name: 'Z'60  },61  J: {62    shape: [63      [1, 0, 0],64      [1, 1, 1]65    ],66    color: 5,67    name: 'J'68  },69  L: {70    shape: [71      [0, 0, 1],72      [1, 1, 1]73    ],74    color: 6,75    name: 'L'76  }77};78 79// Advanced mode tetrominoes (includes all classic + new shapes)80export const ADVANCED_TETROMINOES = {81  ...TETROMINOES,82  // Small L (3 blocks) - top row83  SMALL_L: {84    shape: [85      [1, 1],86      [1, 0]87    ],88    color: 0,89    name: 'SMALL_L'90  },91  // Small L mirrored (3 blocks) - top row92  SMALL_L_MIRROR: {93    shape: [94      [1, 1],95      [0, 1]96    ],97    color: 1,98    name: 'SMALL_L_MIRROR'99  },100  // U shape (5 blocks) - middle left101  U: {102    shape: [103      [1, 0, 1],104      [1, 1, 1]105    ],106    color: 2,107    name: 'U'108  },109  // S shape (4 blocks) - middle right110  S_ADVANCED: {111    shape: [112      [0, 1, 1],113      [1, 1, 0]114    ],115    color: 3,116    name: 'S_ADVANCED'117  },118  // 2x2 with extra piece (5 blocks) - bottom left119  BLOCK_PLUS: {120    shape: [121      [1, 1, 1],122      [1, 1, 0]123    ],124    color: 4,125    name: 'BLOCK_PLUS'126  },127  // T with top extended (5 blocks) - bottom right128  T_EXTENDED: {129    shape: [130      [0, 1, 0],131      [0, 1, 1],132      [0, 1, 0]133    ],134    color: 5,135    name: 'T_EXTENDED'136  }137};138 139// NES Tetris scoring140export const SCORES = {141  SINGLE: 40,142  DOUBLE: 100,143  TRIPLE: 300,144  TETRIS: 1200,145  SOFT_DROP: 1,146  PERFECT_CLEAR: 10000 // Bonus for clearing entire field147};148 149// Game speeds (frames per drop) - Higher = slower150// Smooth progression, gets hard at level 6+151export const LEVEL_SPEEDS = [152  90,  // Level 1 - relaxed start153  80,  // Level 2154  70,  // Level 3155  60,  // Level 4156  50,  // Level 5157  35,  // Level 6 - starts getting hard158  25,  // Level 7159  18,  // Level 8160  12,  // Level 9161  6    // Level 10 - very challenging162];163 164// Level titles for intro screens165export const LEVEL_TITLES = {166  1: 'Low Earth Orbit',167  2: 'Moon Surface',168  3: 'Mars Horizon',169  4: 'Asteroid Belt',170  5: 'Jupiter Storms',171  6: 'Deep Space Station',172  7: 'Nebula Expanse',173  8: 'Binary Star System',174  9: 'Alien Megastructure',175  10: 'Edge of the Universe'176};177 178// UI Layout - single panel to the right of play area179export const UI = {180  // Panel positioned right of play area with 8px gap between frames181  PANEL_X: PLAY_AREA_X + PLAY_AREA_WIDTH + 16,182  PANEL_Y: PLAY_AREA_Y,183  PANEL_WIDTH: 64,184  PANEL_HEIGHT: PLAY_AREA_HEIGHT,185  PADDING: 6,186  LINE_HEIGHT: 20187};188 189