Spaces:
Runtime error
Runtime error
| # game_engine.py | |
| import time | |
| import math | |
| from dataclasses import dataclass | |
| from typing import Dict, List, Tuple | |
| import random | |
| class Vector2D: | |
| x: float | |
| y: float | |
| def __add__(self, other): | |
| return Vector2D(self.x + other.x, self.y + other.y) | |
| def __mul__(self, scalar: float): | |
| return Vector2D(self.x * scalar, self.y * scalar) | |
| class PhysicsEngine: | |
| """Motor físico personalizado para mecánicas híbridas""" | |
| def __init__(self): | |
| self.gravity = Vector2D(0, 0.5) | |
| self.terminal_velocity = Vector2D(10, 15) | |
| def apply_momentum(self, velocity: Vector2D, acceleration: Vector2D, dt: float) -> Vector2D: | |
| """Combina momentum estilo Sonic con precisión tipo Contra""" | |
| new_velocity = velocity + acceleration * dt | |
| new_velocity.x = max(-self.terminal_velocity.x, min(new_velocity.x, self.terminal_velocity.x)) | |
| new_velocity.y = max(-self.terminal_velocity.y, min(new_velocity.y, self.terminal_velocity.y)) | |
| return new_velocity | |
| class WorldGenerator: | |
| """Generador procedural del mundo argentino futurista""" | |
| def __init__(self): | |
| self.biomas = { | |
| 'pampa': self._generate_pampa, | |
| 'patagonia': self._generate_patagonia, | |
| 'quebrada': self._generate_quebrada | |
| } | |
| def _generate_pampa(self, chunk_size: int) -> List[List[str]]: | |
| """Genera chunk de la pampa cósmica con llanuras y estancias futuristas""" | |
| return [ | |
| ['pampa_llanura' if random.random() < 0.8 else 'pampa_estancia' | |
| for _ in range(chunk_size)] | |
| for _ in range(chunk_size) | |
| ] | |
| def _generate_patagonia(self, chunk_size: int) -> List[List[str]]: | |
| """Genera chunk patagónico con montañas y lagos glaciares""" | |
| return [ | |
| [ | |
| 'patagonia_montaña' if (x + y) % 4 == 0 else 'patagonia_lago' | |
| for x in range(chunk_size) | |
| ] | |
| for y in range(chunk_size) | |
| ] | |
| def _generate_quebrada(self, chunk_size: int) -> List[List[str]]: | |
| """Genera chunk de quebrada con formaciones rocosas coloridas""" | |
| return [ | |
| [ | |
| f'quebrada_{random.choice(["rojo", "verde", "azul"])}' | |
| for _ in range(chunk_size) | |
| ] | |
| for _ in range(chunk_size) | |
| ] | |
| def generate_chunk(self, biome: str, size: int) -> List[List[str]]: | |
| """Genera una sección del mundo según el bioma seleccionado""" | |
| generator = self.biomas.get(biome, self._generate_pampa) | |
| return generator(size) | |
| class GauchoCharacter: | |
| """Clase base del personaje principal con habilidades progresivas""" | |
| def __init__(self): | |
| self.position = Vector2D(0, 0) | |
| self.velocity = Vector2D(0, 0) | |
| self.abilities = { | |
| 'mate_tec': False, | |
| 'boleadoras': False, | |
| 'poncho_stealth': False | |
| } | |
| self.inventory = { | |
| 'cristales': {valor: False for valor in [ | |
| 'Solidaridad', 'Familia', 'Amistad', | |
| 'Respeto', 'Creatividad', 'Responsabilidad', 'Diversidad' | |
| ]} | |
| } | |
| def unlock_ability(self, ability: str): | |
| """Desbloquea habilidades según progreso""" | |
| if ability in self.abilities: | |
| self.abilities[ability] = True | |