diff options
| author | XaviDCR92 <xavi.dcr@gmail.com> | 2018-07-09 19:26:13 +0200 |
|---|---|---|
| committer | XaviDCR92 <xavi.dcr@gmail.com> | 2018-07-09 19:26:13 +0200 |
| commit | f0b654b9bf3bc2a93c1f89d4cc3edcf77b948555 (patch) | |
| tree | 91b7404dca0b6eb136cb7f9b144435419144b777 /Player.h | |
| parent | d85464781580796bbcc744ae732e56d1920e3b0f (diff) | |
| download | pocketempires-f0b654b9bf3bc2a93c1f89d4cc3edcf77b948555.tar.gz | |
Game has been restructured in favor of OOP
Diffstat (limited to 'Player.h')
| -rw-r--r-- | Player.h | 119 |
1 files changed, 31 insertions, 88 deletions
@@ -1,106 +1,49 @@ -#ifndef __PLAYER_HEADER__ -#define __PLAYER_HEADER__ +#ifndef PLAYER_H__ +#define PLAYER_H__ /* ************************************** - * Includes * + * Includes * * **************************************/ -#include "Global_Inc.h" -#include "Camera.h" -#include "Unit.h" +#include <stdint.h> /* ************************************** - * Defines * + * Defines * * **************************************/ -#define PLAYER_NAME_LENGTH 16 -#define PLAYER_MAX_UNITS_BUILDINGS 32 - /* ************************************** - * Structs and enums * + * Structs and enums * * **************************************/ -typedef struct t_Resource -{ - uint16_t Wood; - uint16_t Gold; - uint16_t Food; -}TYPE_RESOURCES; - /* ************************************** - * Class definition * + * Class definition * * **************************************/ -#ifdef __cplusplus - class Player { - public: - Player(); - ~Player(); - void Init(void); - void Handler(void); - void DrawHandler(void); - char* getName(void) {return name;} - void setHuman(bool value) { human = value; } - bool isHuman(void) {return human;} - void createUnit(TYPE_UNIT_ID id, TYPE_COLLISION_BLOCK cb); - uint8_t getPopulation(void) {return (unit_i + 1);} - void ShowResources(void); - uint8_t getAliveUnits(void); - - private: - // Player definition - bool human; - char name[PLAYER_NAME_LENGTH]; - TYPE_RESOURCES Resources; - - // Unit handling - TYPE_UNIT units[PLAYER_MAX_UNITS_BUILDINGS]; - uint8_t unit_i; - - // Camera handling - TYPE_CAMERA Camera; - - // Map rendering - void RenderMap(void); - - // Button pressed/released events - void ButtonLeftReleased(void); - void ButtonRightReleased(void); - void ButtonAPressed(void); - void ButtonAReleased(void); - void ButtonBPressed(void); - void ButtonBReleased(void); - - bool checkNewBuildingPosition(TYPE_COLLISION_BLOCK * cb); - void UnitBuildingSelection(void); - void showHealth(uint8_t hp); - void ButtonHandler(void); - void ActionsMenu(void); - void MenuDrawHandler(void); - TYPE_COLLISION_BLOCK GetCursorPos(void); - - // Unit selection - bool anyUnitSelected; - int8_t selectedUnitCandidate; - uint8_t unselectUnits_counter; - - // Actions selection - bool showActionsMenu; - uint8_t showActionsMenu_counter; - uint8_t showActionsMenu_index; - uint8_t showActionsMenu_counterLevel1; - void IncreaseShowActionsMenuIndex(); - - // Action callbacks - void ActionCreateUnit(TYPE_UNIT *ptrUnit, TYPE_UNIT_ID unit); - void ActionCreateBuilding(TYPE_UNIT_ID bldg); - - // Collision detection - bool checkCollisionAgainstOtherUnits(TYPE_COLLISION_BLOCK* cb); + public: + enum tResource + { + RESOURCE_TYPE_WOOD, + RESOURCE_TYPE_FOOD, + RESOURCE_TYPE_GOLD, + + MAX_RESOURCE_TYPES + }; + + explicit Player(const char* const strPlayerName); + virtual void drawHandler(void) = 0; + const char* getName(void) {return _name;} + void setName(const char* const strName); + + protected: + enum + { + MAX_NAME_LENGTH = 16 + }; + + uint16_t _resourcesMap[MAX_RESOURCE_TYPES] = {0}; + char _name[MAX_NAME_LENGTH] = {0}; }; -#endif // __cplusplus - -#endif //PLAYER_HEADER__ +#endif /* PLAYER_H__ */ |
