pero el despegue va muy rapido no ? podria ser mas realista import pygame import math…
- User
pero el despegue va muy rapido no ? podria ser mas realista
import pygame import math
Inicialización de Pygame
pygame.init()
Dimensiones de la pantalla
ANCHO_PANTALLA = 1200 ALTO_PANTALLA = 800
pantalla = pygame.display.set_mode((ANCHO_PANTALLA, ALTO_PANTALLA)) pygame.display.set_caption("Simulación de Exploración Espacial")
Colores
BLANCO = (255, 255, 255) NEGRO = (0, 0, 0) AZUL = (0, 0, 255) ROJO = (255, 0, 0) VERDE = (0, 255, 0)
Reloj para controlar los FPS
reloj = pygame.time.Clock()
Cargar imágenes
fondo = pygame.image.load("espacio.png").convert() fondo_tierra = pygame.image.load("tierra.png").convert() # Nuevo fondo para la escena en tierra nave_imagen = pygame.image.load("nave.png").convert_alpha() planeta_imagen = pygame.image.load("planeta.png").convert_alpha()
Clase para planetas o cuerpos celestes
class CuerpoCeleste: def init(self, x, y, masa, radio, imagen): self.x = x self.y = y self.masa = masa self.radio = radio self.imagen = pygame.transform.scale(imagen, (radio2, radio2)) self.rect = self.imagen.get_rect(center=(self.x, self.y))
def dibujar(self, pantalla): pantalla.blit(self.imagen, self.rect)Clase para la nave espacial
class NaveEspacial: def init(self, planetas): self.x = ANCHO_PANTALLA / 2 self.y = ALTO_PANTALLA - 50 # Posición inicial en tierra self.vx = 0 self.vy = 0 self.angulo = 90 # Apuntando hacia arriba self.fuerza_emp = 0 self.masa = 1000 # kg self.fuerza_emp_max = 20000 # Newtons self.combustible = 1000 # Unidades de combustible self.planetas = planetas # Lista de planetas para cálculo gravitacional self.imagen_original = pygame.transform.scale(nave_imagen, (50, 50)) self.imagen = self.imagen_original self.rect = self.imagen.get_rect(center=(self.x, self.y)) self.en_tierra = True # Indicador de si la nave está en tierra
def actualizar(self, dt, estado_juego): if estado_juego == "en_tierra": # Mientras esté en tierra, no actualizamos la física return # Constante gravitacional simplificada para la simulación G = 6.67430e-1 # Valor ajustado para jugabilidad # Fuerzas gravitacionales fuerza_gravedad_x = 0 fuerza_gravedad_y = 0 for planeta in self.planetas: dx = planeta.x - self.x dy = planeta.y - self.y distancia = math.hypot(dx, dy) if distancia == 0: continue # Evitar división por cero fuerza = G * self.masa * planeta.masa / distancia**2 theta = math.atan2(dy, dx) fuerza_gravedad_x += fuerza * math.cos(theta) fuerza_gravedad_y += fuerza * math.sin(theta) # Fuerza de empuje fuerza_emp_x = self.fuerza_emp * math.cos(math.radians(self.angulo)) fuerza_emp_y = -self.fuerza_emp * math.sin(math.radians(self.angulo)) # Fuerza neta fuerza_total_x = fuerza_emp_x + fuerza_gravedad_x fuerza_total_y = fuerza_emp_y + fuerza_gravedad_y # Aceleración ax = fuerza_total_x / self.masa ay = fuerza_total_y / self.masa # Actualizar velocidades self.vx += ax * dt self.vy += ay * dt # Actualizar posición self.x += self.vx * dt self.y += self.vy * dt # Rotar imagen según el ángulo self.imagen = pygame.transform.rotate(self.imagen_original, -self.angulo) self.rect = self.imagen.get_rect(center=(self.x, self.y)) # Consumo de combustible if self.fuerza_emp > 0 and self.combustible > 0: consumo = self.fuerza_emp / self.fuerza_emp_max * dt * 50 self.combustible -= consumo if self.combustible < 0: self.combustible = 0 self.fuerza_emp = 0 else: self.fuerza_emp = 0 def dibujar(self, pantalla): pantalla.blit(self.imagen, self.rect) # Dibujar indicador de combustible pygame.draw.rect(pantalla, ROJO, (10, 10, self.combustible / 2, 20)) # Mostrar velocidad fuente = pygame.font.SysFont(None, 24) velocidad = math.hypot(self.vx, self.vy) texto_velocidad = fuente.render(f"Velocidad: {velocidad:.2f} px/s", True, BLANCO) pantalla.blit(texto_velocidad, (10, 40)) def comprobar_misiones(self, misiones): for mision in misiones: if not mision.completada and mision.comprobar_completada(self): mision.completada = True print(f"Misión completada: {mision.descripcion}") - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.