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`.
|
||||
Reference in New Issue
Block a user