From bfdc0b9f497ef10f6687abcc55d93405c611af11 Mon Sep 17 00:00:00 2001 From: XaviDCR92 Date: Thu, 26 Jul 2018 21:15:59 +0200 Subject: * Menu.cpp: actions for CHOICE_SINGLE_PLAYER_GAME have been moved to a new function called MainMenuSinglePlayer(). + BaseUnit.cpp, BaseUnit.h: new _selected flag. + Camera.cpp, Camera.h: linear movement has been taken over quadratic movement. Also, cursor now moves if dealing with screen borders. + Cursor.cpp, Cursor.h: new Cursor class holds cursor X/Y information. It is meant to be contained inside a HumanPlayer object. * Game.cpp: minor changes in casts and comments. + HumanPlayer.cpp: added callbacks for button release events. * HumanPlayer.cpp, HumanPlayerBtn.cpp: button handling has been transferred from HumanPlayer.cpp to HumanPlayerBtn.cpp in order to improve modularity. + Sprite.cpp: sprite data was not being checked against NULL. - Unit.cpp: drawHandler() is now executed by Player object. --- Player.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Player.cpp') diff --git a/Player.cpp b/Player.cpp index e8c6e86..19d581d 100644 --- a/Player.cpp +++ b/Player.cpp @@ -3,6 +3,7 @@ * ******************************************************************/ #include "Player.h" +#include "Unit.h" #include /* ******************************************************************* @@ -54,3 +55,27 @@ _name{'\0'} /* Set all resources to default value. */ memset(_resourcesMap, DEFAULT_RESOURCES, sizeof(uint8_t) * MAX_RESOURCE_TYPES); } + +void Player::handleUnits(void) +{ + for (size_t szUnit = 0; szUnit < MAX_UNITS; szUnit++) + { + /* Select Unit object from internal table. */ + Unit& unit = _unitsMap[szUnit]; + + /* Execute unit handler. */ + unit.handler(); + } +} + +void Player::drawUnits(void) +{ + for (size_t szUnit = 0; szUnit < MAX_UNITS; szUnit++) + { + /* Select Unit object from internal table. */ + Unit& u = _unitsMap[szUnit]; + + /* Execute drawHandler for selected Unit. */ + u.drawHandler(); + } +} -- cgit v1.2.3