Spaces:
Runtime error
Runtime error
Update game_engine.py
Browse files- game_engine.py +39 -27
game_engine.py
CHANGED
|
@@ -3,6 +3,7 @@ import time
|
|
| 3 |
import math
|
| 4 |
from dataclasses import dataclass
|
| 5 |
from typing import Dict, List, Tuple
|
|
|
|
| 6 |
|
| 7 |
@dataclass
|
| 8 |
class Vector2D:
|
|
@@ -28,18 +29,47 @@ class PhysicsEngine:
|
|
| 28 |
new_velocity.y = max(-self.terminal_velocity.y, min(new_velocity.y, self.terminal_velocity.y))
|
| 29 |
return new_velocity
|
| 30 |
|
| 31 |
-
class
|
| 32 |
-
"""
|
| 33 |
def __init__(self):
|
| 34 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
def
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
def
|
| 41 |
-
|
| 42 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
class GauchoCharacter:
|
| 45 |
"""Clase base del personaje principal con habilidades progresivas"""
|
|
@@ -62,21 +92,3 @@ class GauchoCharacter:
|
|
| 62 |
"""Desbloquea habilidades seg煤n progreso"""
|
| 63 |
if ability in self.abilities:
|
| 64 |
self.abilities[ability] = True
|
| 65 |
-
|
| 66 |
-
class WorldGenerator:
|
| 67 |
-
"""Generador procedural del mundo argentino futurista"""
|
| 68 |
-
def __init__(self):
|
| 69 |
-
self.biomas = {
|
| 70 |
-
'pampa': self._generate_pampa,
|
| 71 |
-
'patagonia': self._generate_patagonia,
|
| 72 |
-
'quebrada': self._generate_quebrada
|
| 73 |
-
}
|
| 74 |
-
|
| 75 |
-
def _generate_pampa(self, chunk_size: int) -> List[List[str]]:
|
| 76 |
-
return [['pampa' for _ in range(chunk_size)] for _ in range(chunk_size)]
|
| 77 |
-
|
| 78 |
-
def _generate_patagonia(self, chunk_size: int) -> List[List[str]]:
|
| 79 |
-
# Implementaci贸n similar con variaciones geogr谩ficas
|
| 80 |
-
pass
|
| 81 |
-
|
| 82 |
-
# ... (Implementaciones similares para otros sistemas clave)
|
|
|
|
| 3 |
import math
|
| 4 |
from dataclasses import dataclass
|
| 5 |
from typing import Dict, List, Tuple
|
| 6 |
+
import random
|
| 7 |
|
| 8 |
@dataclass
|
| 9 |
class Vector2D:
|
|
|
|
| 29 |
new_velocity.y = max(-self.terminal_velocity.y, min(new_velocity.y, self.terminal_velocity.y))
|
| 30 |
return new_velocity
|
| 31 |
|
| 32 |
+
class WorldGenerator:
|
| 33 |
+
"""Generador procedural del mundo argentino futurista"""
|
| 34 |
def __init__(self):
|
| 35 |
+
self.biomas = {
|
| 36 |
+
'pampa': self._generate_pampa,
|
| 37 |
+
'patagonia': self._generate_patagonia,
|
| 38 |
+
'quebrada': self._generate_quebrada
|
| 39 |
+
}
|
| 40 |
|
| 41 |
+
def _generate_pampa(self, chunk_size: int) -> List[List[str]]:
|
| 42 |
+
"""Genera chunk de la pampa c贸smica con llanuras y estancias futuristas"""
|
| 43 |
+
return [
|
| 44 |
+
['pampa_llanura' if random.random() < 0.8 else 'pampa_estancia'
|
| 45 |
+
for _ in range(chunk_size)]
|
| 46 |
+
for _ in range(chunk_size)
|
| 47 |
+
]
|
| 48 |
+
|
| 49 |
+
def _generate_patagonia(self, chunk_size: int) -> List[List[str]]:
|
| 50 |
+
"""Genera chunk patag贸nico con monta帽as y lagos glaciares"""
|
| 51 |
+
return [
|
| 52 |
+
[
|
| 53 |
+
'patagonia_monta帽a' if (x + y) % 4 == 0 else 'patagonia_lago'
|
| 54 |
+
for x in range(chunk_size)
|
| 55 |
+
]
|
| 56 |
+
for y in range(chunk_size)
|
| 57 |
+
]
|
| 58 |
|
| 59 |
+
def _generate_quebrada(self, chunk_size: int) -> List[List[str]]:
|
| 60 |
+
"""Genera chunk de quebrada con formaciones rocosas coloridas"""
|
| 61 |
+
return [
|
| 62 |
+
[
|
| 63 |
+
f'quebrada_{random.choice(["rojo", "verde", "azul"])}'
|
| 64 |
+
for _ in range(chunk_size)
|
| 65 |
+
]
|
| 66 |
+
for _ in range(chunk_size)
|
| 67 |
+
]
|
| 68 |
+
|
| 69 |
+
def generate_chunk(self, biome: str, size: int) -> List[List[str]]:
|
| 70 |
+
"""Genera una secci贸n del mundo seg煤n el bioma seleccionado"""
|
| 71 |
+
generator = self.biomas.get(biome, self._generate_pampa)
|
| 72 |
+
return generator(size)
|
| 73 |
|
| 74 |
class GauchoCharacter:
|
| 75 |
"""Clase base del personaje principal con habilidades progresivas"""
|
|
|
|
| 92 |
"""Desbloquea habilidades seg煤n progreso"""
|
| 93 |
if ability in self.abilities:
|
| 94 |
self.abilities[ability] = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|