summaryrefslogtreecommitdiff
path: root/Game.cpp
diff options
context:
space:
mode:
authorXaviDCR92 <xavi.dcr@gmail.com>2018-07-26 21:15:59 +0200
committerXaviDCR92 <xavi.dcr@gmail.com>2018-07-26 21:15:59 +0200
commitbfdc0b9f497ef10f6687abcc55d93405c611af11 (patch)
tree43914b2eada0bf5fb09093d61a250d4930b57a5d /Game.cpp
parent853c6cddaa2713a9eb0c1f1c55e3f61592f04a46 (diff)
* 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.
Diffstat (limited to 'Game.cpp')
-rw-r--r--Game.cpp17
1 files changed, 9 insertions, 8 deletions
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<enum tPauseMenuChoice>(gb.menu(astrPauseMenuOptions, MAX_PAUSE_MENU_CHOICES));
}
else
{