feat(room-layout): Implement new grid-based room layout system with critical bug fixes

- Add grid unit constants (5x4 tiles) to constants.js
- Create comprehensive grid conversion helper functions
- Implement 4-direction room positioning (N/S/E/W) with breadth-first algorithm
- Add door placement functions with CRITICAL fixes:
  * Negative modulo fix: ((sum % 2) + 2) % 2 for deterministic placement
  * Asymmetric alignment fix: single-door rooms align with multi-door rooms
  * Consistent grid alignment using Math.floor() for negative coordinates
- Rewrite calculateRoomPositions to support variable room sizes
- Update createDoorSpritesForRoom to use new placement system
- Store room dimensions globally for cross-system access

This implements the comprehensive room layout redesign as specified in
planning_notes/new_room_layout with all critical fixes from review2.

Addresses: Variable room sizes, proper door alignment, and grid-based positioning
This commit is contained in:
Z. Cliffe Schreuders
2025-11-16 08:45:06 +00:00
parent 57d9b8f5d8
commit 2e62a4e62b
3 changed files with 894 additions and 388 deletions

View File

@@ -2,6 +2,17 @@
export const TILE_SIZE = 32;
export const DOOR_ALIGN_OVERLAP = 32 * 3;
export const GRID_SIZE = 32;
// Grid unit system constants for room layout
// Grid units are the base stacking size for rooms
export const GRID_UNIT_WIDTH_TILES = 5; // 5 tiles wide
export const GRID_UNIT_HEIGHT_TILES = 4; // 4 tiles tall (stacking area)
export const VISUAL_TOP_TILES = 2; // Top 2 rows are visual wall overlay
// Calculated grid unit sizes in pixels
export const GRID_UNIT_WIDTH_PX = GRID_UNIT_WIDTH_TILES * TILE_SIZE; // 160px
export const GRID_UNIT_HEIGHT_PX = GRID_UNIT_HEIGHT_TILES * TILE_SIZE; // 128px
export const MOVEMENT_SPEED = 150;
export const RUN_SPEED_MULTIPLIER = 1.5; // Speed multiplier when holding shift
export const RUN_ANIMATION_MULTIPLIER = 1.5; // Animation speed multiplier when holding shift