Fix tile rendering dimensions and alignment, update tile definitions to use height
This commit is contained in:
153
implementación/coordinate_system_analysis.md
Normal file
153
implementación/coordinate_system_analysis.md
Normal file
@@ -0,0 +1,153 @@
|
||||
# Análisis del Sistema de Coordenadas
|
||||
|
||||
## GridSystem - Cómo Funciona la Rotación
|
||||
|
||||
En `GridSystem.getGlobalCells()`, las transformaciones son:
|
||||
|
||||
```javascript
|
||||
// Local coords: lx (columna), ly (fila convertida desde matriz)
|
||||
// ly = (numberOfRows - 1) - row // Fila 0 de matriz = Y más alto
|
||||
|
||||
switch (rotation) {
|
||||
case NORTH:
|
||||
gx = startX + lx;
|
||||
gy = startY + ly;
|
||||
break;
|
||||
case SOUTH:
|
||||
gx = startX - lx;
|
||||
gy = startY - ly;
|
||||
break;
|
||||
case EAST:
|
||||
gx = startX + ly;
|
||||
gy = startY - lx;
|
||||
break;
|
||||
case WEST:
|
||||
gx = startX - ly;
|
||||
gy = startY + lx;
|
||||
break;
|
||||
}
|
||||
```
|
||||
|
||||
## Ejemplo: Corridor 2x6 (Ancho=2, Largo=6)
|
||||
|
||||
Layout en matriz (fila 0 arriba, fila 5 abajo):
|
||||
```
|
||||
[1, 1] // Fila 0 -> ly=5 (norte)
|
||||
[1, 1] // Fila 1 -> ly=4
|
||||
[1, 1] // Fila 2 -> ly=3
|
||||
[1, 1] // Fila 3 -> ly=2
|
||||
[1, 1] // Fila 4 -> ly=1
|
||||
[1, 1] // Fila 5 -> ly=0 (sur)
|
||||
```
|
||||
|
||||
### Rotación NORTH (Sin rotar)
|
||||
- Anchor en (0,0)
|
||||
- Celdas ocupadas: (0,0) (1,0) (0,1) (1,1) ... (0,5) (1,5)
|
||||
- Salida SUR: celdas (0,0) y (1,0) -> exits en estas posiciones mirando SOUTH
|
||||
- Salida NORTE: celdas (0,5) y (1,5) -> exits en estas posiciones mirando NORTH
|
||||
|
||||
**Definición de exits para NORTH (Config Straight):**
|
||||
```javascript
|
||||
{ x: 0, y: 0, direction: SOUTH },
|
||||
{ x: 1, y: 0, direction: SOUTH },
|
||||
{ x: 0, y: 5, direction: NORTH },
|
||||
{ x: 1, y: 5, direction: NORTH }
|
||||
```
|
||||
|
||||
### Rotación EAST
|
||||
- Anchor en (0,0)
|
||||
- Transformación: gx = 0 + ly, gy = 0 - lx
|
||||
- Celda local (lx=0, ly=0): Global (0, 0)
|
||||
- Celda local (lx=1, ly=0): Global (0, -1)
|
||||
- Celda local (lx=0, ly=5): Global (5, 0)
|
||||
- Celda local (lx=1, ly=5): Global (5, -1)
|
||||
|
||||
El corridor ahora es horizontal, creciendo hacia la derecha (+X), con ancho en dirección -Y.
|
||||
|
||||
**Celdas ocupadas:**
|
||||
- (0,0), (0,-1) - extremo oeste
|
||||
- (1,0), (1,-1)
|
||||
- (2,0), (2,-1)
|
||||
- (3,0), (3,-1)
|
||||
- (4,0), (4,-1)
|
||||
- (5,0), (5,-1) - extremo este
|
||||
|
||||
**Definición de exits para EAST (Config Straight):**
|
||||
Salida WEST (era SUR): en el extremo oeste
|
||||
```javascript
|
||||
{ x: 0, y: 0, direction: WEST },
|
||||
{ x: 0, y: -1, direction: WEST }
|
||||
```
|
||||
|
||||
Salida EAST (era NORTE): en el extremo este
|
||||
```javascript
|
||||
{ x: 5, y: 0, direction: EAST },
|
||||
{ x: 5, y: -1, direction: EAST }
|
||||
```
|
||||
|
||||
### Rotación SOUTH
|
||||
- Anchor en (0,0)
|
||||
- Transformación: gx = 0 - lx, gy = 0 - ly
|
||||
- Celda local (lx=0, ly=0): Global (0, 0)
|
||||
- Celda local (lx=1, ly=0): Global (-1, 0)
|
||||
- Celda local (lx=0, ly=5): Global (0, -5)
|
||||
- Celda local (lx=1, ly=5): Global (-1, -5)
|
||||
|
||||
El corridor crece hacia abajo (-Y) y hacia la izquierda (-X).
|
||||
|
||||
**Celdas ocupadas:**
|
||||
- (0,0), (-1,0) - extremo norte (era sur)
|
||||
- (0,-1), (-1,-1)
|
||||
- (0,-2), (-1,-2)
|
||||
- (0,-3), (-1,-3)
|
||||
- (0,-4), (-1,-4)
|
||||
- (0,-5), (-1,-5) - extremo sur (era norte)
|
||||
|
||||
**Definición de exits para SOUTH (Config Straight):**
|
||||
Salida NORTH (era SUR original): en el extremo norte
|
||||
```javascript
|
||||
{ x: 0, y: 0, direction: NORTH },
|
||||
{ x: -1, y: 0, direction: NORTH }
|
||||
```
|
||||
|
||||
Salida SOUTH (era NORTE original): en el extremo sur
|
||||
```javascript
|
||||
{ x: 0, y: -5, direction: SOUTH },
|
||||
{ x: -1, y: -5, direction: SOUTH }
|
||||
```
|
||||
|
||||
### Rotación WEST
|
||||
- Anchor en (0,0)
|
||||
- Transformación: gx = 0 - ly, gy = 0 + lx
|
||||
- Celda local (lx=0, ly=0): Global (0, 0)
|
||||
- Celda local (lx=1, ly=0): Global (0, 1)
|
||||
- Celda local (lx=0, ly=5): Global (-5, 0)
|
||||
- Celda local (lx=1, ly=5): Global (-5, 1)
|
||||
|
||||
El corridor es horizontal, creciendo hacia la izquierda (-X), con ancho en dirección +Y.
|
||||
|
||||
**Celdas ocupadas:**
|
||||
- (0,0), (0,1) - extremo este (era sur)
|
||||
- (-1,0), (-1,1)
|
||||
- (-2,0), (-2,1)
|
||||
- (-3,0), (-3,1)
|
||||
- (-4,0), (-4,1)
|
||||
- (-5,0), (-5,1) - extremo oeste (era norte)
|
||||
|
||||
**Definición de exits para WEST (Config Straight):**
|
||||
Salida EAST (era SUR original): en el extremo este
|
||||
```javascript
|
||||
{ x: 0, y: 0, direction: EAST },
|
||||
{ x: 0, y: 1, direction: EAST }
|
||||
```
|
||||
|
||||
Salida WEST (era NORTE original): en el extremo oeste
|
||||
```javascript
|
||||
{ x: -5, y: 0, direction: WEST },
|
||||
{ x: -5, y: 1, direction: WEST }
|
||||
```
|
||||
|
||||
## Conclusión
|
||||
Las definiciones actuales de corridors están ✅ **CORRECTAS**.
|
||||
|
||||
El problema debe estar en el `DungeonGenerator.js`.
|
||||
34
implementación/implementation_plan_rotation.md
Normal file
34
implementación/implementation_plan_rotation.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Paradigm Shift: Explicit Rotations & Corridors
|
||||
|
||||
## Goal
|
||||
To eliminate dynamic rotation calculations which caused alignment issues, specifically for asymmetric tiles like Corridors (2x6). We will implement explicit exit definitions for all 4 rotations for Corridors, just like we did for Rooms.
|
||||
|
||||
## Steps
|
||||
|
||||
### 1. Update `TileDefinitions.js`
|
||||
- Modify `corridor_straight` and `corridor_steps`.
|
||||
- Change `exitConfigurations` from an array of simple arrays to an array of objects.
|
||||
- Each object will represent a configuration (Straight, Corner-Left, Corner-Right) but will contain `exitsByRotation` for `NORTH`, `EAST`, `SOUTH`, `WEST`.
|
||||
- Pre-calculate coordinates for these rotations based on the 2x6 layout.
|
||||
|
||||
### 2. Rewrite `DungeonGenerator.js`
|
||||
- **Simplify `step()`**:
|
||||
- Iterate through `TileDefinitions` that might apply.
|
||||
- Handle `pendingExits`.
|
||||
- **New Alignment Logic**:
|
||||
- Pick a card.
|
||||
- If it has `exitConfigurations` (Corridors), iterate them.
|
||||
- Inside, iterate 4 Rotations.
|
||||
- Inside, iterate Exits.
|
||||
- If it has simple definitions (Rooms), iterate 4 Rotations.
|
||||
- Inside, iterate Exits.
|
||||
- **Placement**:
|
||||
- Calculate `GlobalPos = TargetConnection - LocalExitPos`.
|
||||
- Check Validity (Opposite Direction).
|
||||
- Check `canPlace`.
|
||||
- **Cleanup**: Remove deprecated methods like `getRotatedOffset`.
|
||||
|
||||
## Expected Outcome
|
||||
- Corridors align perfectly in all directions.
|
||||
- No gaps.
|
||||
- Code is easier to understand (no complex matrix rotation math in JS, just lookups).
|
||||
Reference in New Issue
Block a user