From 786dccd2bc0946d48b8a2758ef2c607678bc8dd9 Mon Sep 17 00:00:00 2001 From: XaviDCR92 Date: Fri, 8 Sep 2017 18:39:22 +0200 Subject: Removed Building and GameStructures modules. Restructured SW for Unit and Player, still a lot TODO --- Unit.h | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 84 insertions(+), 20 deletions(-) (limited to 'Unit.h') 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__ -- cgit v1.2.3