drag'n drop del jugador
This commit is contained in:
@@ -37,12 +37,32 @@ class MapEditor {
|
||||
MapEditor(); // Constructor
|
||||
~MapEditor(); // Destructor
|
||||
|
||||
void updateMousePosition(); // Convierte coordenadas de ventana a coordenadas de juego y tile
|
||||
void renderEnemyBoundaries(); // Dibuja marcadores de boundaries y líneas de ruta
|
||||
void renderBoundaryMarker(float x, float y, Uint8 color); // Dibuja un marcador de boundary en una posición
|
||||
// Tipos para drag & drop
|
||||
enum class DragTarget { NONE, PLAYER, ENEMY_INITIAL, ENEMY_BOUND1, ENEMY_BOUND2, ITEM };
|
||||
|
||||
struct DragState {
|
||||
DragTarget target{DragTarget::NONE};
|
||||
int index{-1}; // Índice del enemigo o item en room_data_
|
||||
float offset_x{0.0F}; // Offset entre el cursor y el origen de la entidad al inicio del drag
|
||||
float offset_y{0.0F};
|
||||
float snap_x{0.0F}; // Posición snapped actual (para preview)
|
||||
float snap_y{0.0F};
|
||||
};
|
||||
|
||||
// Métodos internos
|
||||
void updateMousePosition(); // Convierte coordenadas de ventana a coordenadas de juego y tile
|
||||
void renderEnemyBoundaries(); // Dibuja marcadores de boundaries y líneas de ruta
|
||||
void renderBoundaryMarker(float x, float y, Uint8 color); // Dibuja un marcador de boundary en una posición
|
||||
void renderSelectionHighlight(); // Dibuja highlight del elemento seleccionado/arrastrado
|
||||
void handleMouseDown(float game_x, float game_y); // Procesa click del ratón (hit test + inicio de drag)
|
||||
void handleMouseUp(); // Procesa soltar el ratón (commit del drag)
|
||||
void updateDrag(); // Actualiza la posición snapped durante el drag
|
||||
static auto snapToGrid(float value) -> float; // Alinea un valor a la cuadrícula de 8x8
|
||||
static auto pointInRect(float px, float py, const SDL_FRect& rect) -> bool; // Hit test punto en rectángulo
|
||||
|
||||
// Estado del editor
|
||||
bool active_{false};
|
||||
DragState drag_;
|
||||
|
||||
// Copia mutable de los datos de la habitación (para edición futura)
|
||||
Room::Data room_data_;
|
||||
|
||||
Reference in New Issue
Block a user