Add input logic for building
This commit is contained in:
@@ -4,12 +4,34 @@
|
||||
#include <breeze.h>
|
||||
#include <flecs.h>
|
||||
|
||||
typedef enum InputState {
|
||||
typedef enum InputType {
|
||||
INPUT_NONE,
|
||||
INPUT_PLACING,
|
||||
INPUT_DRAGGING,
|
||||
INPUT_BUILDING,
|
||||
INPUT_SELECTED_UNITS,
|
||||
INPUT_SELECTED_OBJECT,
|
||||
INPUT_SELECTED_BUILDING,
|
||||
} InputType;
|
||||
|
||||
typedef struct InputState {
|
||||
InputType state;
|
||||
// Input mapping
|
||||
MouseButton LMB;
|
||||
MouseButton RMB;
|
||||
MouseButton MMB;
|
||||
KeyboardKey ESC;
|
||||
f32 DRAG_LIMIT;
|
||||
// Common
|
||||
Vector2 mouseDown;
|
||||
Vector2 mouseDownWorld;
|
||||
f32 mouseDownElapsed;
|
||||
// INPUT_BUILDING
|
||||
int building;
|
||||
bool buildingCanPlace;
|
||||
TilePosition buildingPos;
|
||||
TileSize buildingSize;
|
||||
// SELECTED_UNITS
|
||||
// SELECTED_OBJECTS
|
||||
// SELECTED_BUILDING
|
||||
} InputState;
|
||||
|
||||
typedef struct Game {
|
||||
@@ -21,15 +43,7 @@ typedef struct Game {
|
||||
BzSpatialGrid *entityGrid;
|
||||
f32 frameDuration;
|
||||
ecs_entity_t entity;
|
||||
struct {
|
||||
InputState state;
|
||||
int building;
|
||||
bool buildingCanPlace;
|
||||
TilePosition buildingPos;
|
||||
TileSize buildingSize;
|
||||
Vector2 mouseDown;
|
||||
f32 mouseDownElapsed;
|
||||
} input;
|
||||
InputState input;
|
||||
struct {
|
||||
i64 wood;
|
||||
i64 iron;
|
||||
|
||||
Reference in New Issue
Block a user