Files
vibe3_physics/source/ball.h
Sergio Valor 7b24e387b7 Implementar modo real fullscreen y resolver conflictos
MODO REAL FULLSCREEN (F4):
- F4: Cambia resolución interna a resolución nativa del escritorio
- Pelotas usan dimensiones dinámicas del terreno de juego
- Interfaz se adapta automáticamente (texto, debug, gradiente)
- Reinicio automático de escena con nuevas dimensiones

RESOLUCIÓN DINÁMICA:
- Ball constructor acepta screen_width/height como parámetros
- Colisiones usan dimensiones dinámicas en lugar de constantes
- Spawn de pelotas usa margen configurable (BALL_SPAWN_MARGIN)
- Toda la interfaz se adapta a resolución actual

MODOS FULLSCREEN MUTUAMENTE EXCLUYENTES:
- F3 (fullscreen normal) y F4 (real fullscreen) se desactivan mutuamente
- F1/F2 (zoom) bloqueados durante cualquier modo fullscreen
- Sin estados mixtos que rompan el renderizado
- Transiciones seguras entre todos los modos

MEJORAS DE CONFIGURACIÓN:
- BALL_SPAWN_MARGIN: margen lateral configurable para spawn de pelotas
- Resolución base actualizada a 640x360 (16:9)
- Spawn margin reducido a 15% para mayor dispersión

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-18 19:20:02 +02:00

62 lines
2.5 KiB
C++

#pragma once
#include <SDL3/SDL_rect.h> // for SDL_FRect
#include <memory> // for shared_ptr, unique_ptr
#include "defines.h" // for Color
#include "external/sprite.h" // for Sprite
class Texture;
class Ball {
private:
std::unique_ptr<Sprite> sprite_; // Sprite para pintar la clase
SDL_FRect pos_; // Posición y tamaño de la pelota
float vx_, vy_; // Velocidad
float gravity_force_; // Gravedad base
float gravity_mass_factor_; // Factor de masa individual (0.7-1.3, afecta gravedad)
GravityDirection gravity_direction_; // Direcci\u00f3n de la gravedad
int screen_width_; // Ancho del terreno de juego
int screen_height_; // Alto del terreno de juego
Color color_; // Color de la pelota
bool on_surface_; // Indica si la pelota est\u00e1 en la superficie (suelo/techo/pared)
bool stopped_; // Indica si la pelota ha terminado de moverse;
float loss_; // Coeficiente de rebote. Pérdida de energía en cada rebote
public:
// Constructor
Ball(float x, float vx, float vy, Color color, std::shared_ptr<Texture> texture, int screen_width, int screen_height, GravityDirection gravity_dir = GravityDirection::DOWN, float mass_factor = 1.0f);
// Destructor
~Ball() = default;
// Actualiza la lógica de la clase
void update(float deltaTime);
// Pinta la clase
void render();
// Modifica la velocidad
void modVel(float vx, float vy);
// Cambia la gravedad
void switchGravity();
// Cambia la direcci\u00f3n de gravedad
void setGravityDirection(GravityDirection direction);
// Aplica un peque\u00f1o empuje lateral aleatorio
void applyRandomLateralPush();
// Getters para debug
float getVelocityY() const { return vy_; }
float getVelocityX() const { return vx_; }
float getGravityForce() const { return gravity_force_; }
float getLossCoefficient() const { return loss_; }
GravityDirection getGravityDirection() const { return gravity_direction_; }
bool isOnSurface() const { return on_surface_; }
// Getters para batch rendering
SDL_FRect getPosition() const { return pos_; }
Color getColor() const { return color_; }
};