Spaces:
Runtime error
Runtime error
File size: 3,373 Bytes
804c744 7e14105 804c744 7e14105 804c744 7e14105 804c744 7e14105 804c744 7e14105 804c744 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# game_engine.py
import time
import math
from dataclasses import dataclass
from typing import Dict, List, Tuple
import random
@dataclass
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
|