summaryrefslogtreecommitdiff
path: root/Unit.h
diff options
context:
space:
mode:
authorXaviDCR92 <xavi.dcr@gmail.com>2017-09-08 18:39:22 +0200
committerXaviDCR92 <xavi.dcr@gmail.com>2017-09-08 18:39:22 +0200
commit786dccd2bc0946d48b8a2758ef2c607678bc8dd9 (patch)
tree47952d77e5646a993671134b50c16f32ebe35b1c /Unit.h
parent72d350a37aa67936361ac8a374472b7e0227da61 (diff)
downloadpocketempires-786dccd2bc0946d48b8a2758ef2c607678bc8dd9.tar.gz
Removed Building and GameStructures modules. Restructured SW for Unit and Player, still a lot TODO
Diffstat (limited to 'Unit.h')
-rw-r--r--Unit.h104
1 files changed, 84 insertions, 20 deletions
diff --git a/Unit.h b/Unit.h
index 4e5d85b..55439c4 100644
--- a/Unit.h
+++ b/Unit.h
@@ -4,47 +4,111 @@
/* **************************************
* Includes *
* **************************************/
-
+
#include "Global_Inc.h"
-#include "Gfx.h"
-#include "GameStructures.h"
#include "Camera.h"
#ifdef __cplusplus
extern "C"
{
#endif //__cplusplus
-
+
/* **************************************
* Defines *
* **************************************/
-
+
/* **************************************
* Structs and enums *
* **************************************/
-
+
+typedef enum t_unitdirection
+{
+ DIRECTION_LEFT = 0,
+ DIRECTION_RIGHT,
+ DIRECTION_UP,
+ DIRECTION_DOWN
+}UNIT_DIRECTION;
+
+typedef struct t_Unit
+{
+ uint16_t x;
+ uint16_t y;
+ uint16_t target_x;
+ uint16_t target_y;
+ uint8_t hp;
+ uint8_t id;
+ UNIT_DIRECTION dir;
+ bool mirror; // True = down or left; true = up or right
+ bool building;
+ bool walking;
+ bool alive;
+ bool selected;
+ bool selecting_attack;
+ bool attacking;
+ uint8_t walk_counter;
+}TYPE_UNIT;
+
typedef enum t_unitid
{
- PEASANT = 0
+ // Walking units
+ PEASANT = 0,
+
+ MAX_UNIT_ID,
+
+ // Buildings
+ BARRACKS,
+ TOWER,
+
+ MAX_BUILDING_ID,
+
+ MAX_UNITS_BUILDINGS,
+
+ FIRST_UNIT_ID = PEASANT,
+ FIRST_BUILDING_ID = BARRACKS
}TYPE_UNIT_ID;
-
+
+typedef struct
+{
+ const char* str;
+ void (*pAction)(TYPE_UNIT*);
+}TYPE_UNIT_ACTION;
+
+typedef enum t_availableactions
+{
+ ACTION_BUILD,
+ ACTION_ATTACK,
+ ACTION_CREATE_UNIT
+}UNIT_ACTION;
+
+typedef struct t_Camera TYPE_CAMERA;
+
/* **************************************
* Global prototypes *
* **************************************/
-
-void UnitInit(void);
-uint8_t UnitGetHpFromID(uint8_t id);
-uint8_t UnitGetWidthFromID(uint8_t id);
-uint8_t UnitGetHeightFromID(uint8_t id);
-void UnitDraw(TYPE_CAMERA * ptrCamera, TYPE_UNIT * ptrUnit, bool bSelected);
-const char* UnitSelectedOptions(TYPE_UNIT* ptrUnit);
-void UnitMoveTo(TYPE_UNIT * ptrUnit, uint16_t x, uint16_t y);
-void UnitHandler(TYPE_UNIT * ptrUnit);
-void UnitAcceptAction(TYPE_UNIT* ptrUnit);
-void UnitResetMenuLevel(void);
+
+// Initialization and handling
+void UnitInit(void);
+void UnitHandler(TYPE_UNIT* ptrUnit);
+
+// Unit information
+uint8_t UnitGetHpFromID(uint8_t id);
+uint8_t UnitGetWidthFromID(uint8_t id);
+uint8_t UnitGetHeightFromID(uint8_t id);
+uint8_t UnitGetAvailableActions(TYPE_UNIT* ptrUnit);
+
+// Rendering
+void UnitDraw(TYPE_UNIT* ptrUnit, TYPE_CAMERA* ptrCamera, bool bHighlighted);
+
+void UnitMoveTo(TYPE_UNIT* ptrUnit, uint16_t x, uint16_t y);
+
+void UnitAcceptAction(TYPE_UNIT* ptrUnit);
+void UnitResetMenuLevel(void);
+
+// Selection index
+const char* UnitGetActionString(UNIT_ACTION action);
#ifdef __cplusplus
}
#endif //__cplusplus
-
+
#endif //__UNIT_HEADER__