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. --- Game.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'Game.cpp') diff --git a/Game.cpp b/Game.cpp index e4c0438..5a3f833 100644 --- a/Game.cpp +++ b/Game.cpp @@ -67,7 +67,7 @@ void Game(const struct tGameConfig& sGameConfig) /* Do not calculate a new frame * until refresh flag is set. */ - while (gb.update() == false); + while (not gb.update()); } while (GamePause() != PAUSE_MENU_CHOICE_QUIT); } @@ -82,19 +82,20 @@ void Game(const struct tGameConfig& sGameConfig) *********************************************************************/ static void GameNextFrame(const struct tGameConfig& sGameConfig) { - for (uint8_t i = 0; i < sGameConfig.u8NHumanPlayers; i++) + for (size_t szHumanPlayer = 0; szHumanPlayer < sGameConfig.u8NHumanPlayers; szHumanPlayer++) { - HumanPlayer* pHumanPlayerData = &sGameConfig.pHumanPlayerData[i]; + HumanPlayer* const pHumanPlayerData = &sGameConfig.pHumanPlayerData[szHumanPlayer]; if (pHumanPlayerData != NULL) { + /* Execute handler for selected HumanPlayer. */ pHumanPlayerData->handler(); } + else + { + /* HumanPlayer handler callback not available. */ + } } - - /* Update camera position according - * to button pressed events. */ - sGameConfig.cam.handler(); } /*****************************************************************//** @@ -118,7 +119,7 @@ static enum tPauseMenuChoice GamePause(void) [PAUSE_MENU_CHOICE_QUIT] = strPauseMenuOption_1 }; - return (enum tPauseMenuChoice)gb.menu(astrPauseMenuOptions, MAX_PAUSE_MENU_CHOICES); + return static_cast(gb.menu(astrPauseMenuOptions, MAX_PAUSE_MENU_CHOICES)); } else { -- cgit v1.2.3