score during gameplay
This commit is contained in:
parent
fdaa535b29
commit
209e1289ab
@ -132,6 +132,12 @@ private:
|
|||||||
|
|
||||||
// drawing methods
|
// drawing methods
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief display players score on the screen
|
||||||
|
* @fn void displayScore();
|
||||||
|
*/
|
||||||
|
void displayScore() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief main display function, clear the window and calls sub display functions
|
* @brief main display function, clear the window and calls sub display functions
|
||||||
* @param[in] fps : current screen refresh rate
|
* @param[in] fps : current screen refresh rate
|
||||||
|
|||||||
@ -34,8 +34,9 @@ void Game::displayAll(unsigned fps) const {
|
|||||||
pm->drawTorpedo(tor, confData.torpedosWidth, confData.torpedosColor);
|
pm->drawTorpedo(tor, confData.torpedosWidth, confData.torpedosColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
displayGod();
|
displayGod();
|
||||||
|
displayScore();
|
||||||
|
|
||||||
DEBUG_INSTR(
|
DEBUG_INSTR(
|
||||||
pm->drawText(Position(pm->getScreenWidth()-200, 20), "FPS : "+to_string(fps), nsGraphics::KWhite, Font::BITMAP_8_BY_13);
|
pm->drawText(Position(pm->getScreenWidth()-200, 20), "FPS : "+to_string(fps), nsGraphics::KWhite, Font::BITMAP_8_BY_13);
|
||||||
@ -69,6 +70,16 @@ void Game::displayHearts(playerID pID) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Game::displayScore() const{
|
||||||
|
unsigned margin = 0;
|
||||||
|
unsigned playerNumber = 1;
|
||||||
|
for (auto& player: players){
|
||||||
|
pm->drawText(Position(0,10+margin),"player "+to_string(playerNumber)+" :",nsGraphics::KWhite,Font::BITMAP_8_BY_13);
|
||||||
|
pm->drawText(Position(100,10+margin),to_string(player.score) ,nsGraphics::KWhite,Font::BITMAP_8_BY_13);
|
||||||
|
++playerNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Game::displayInvader(const Position& pos, InvaderType type) const {
|
void Game::displayInvader(const Position& pos, InvaderType type) const {
|
||||||
if(type==InvaderType::NONE)return;
|
if(type==InvaderType::NONE)return;
|
||||||
const InvaderTypeDef& invDef = confData.invadersDef.at(type);
|
const InvaderTypeDef& invDef = confData.invadersDef.at(type);
|
||||||
|
|||||||
@ -109,12 +109,6 @@ void Game::initGame(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Plays the game, and returns once the game is finished
|
|
||||||
*
|
|
||||||
* @return @WinValue::PLAYERS if the players won, @WinValue::INVADERS is the invaders won, WinValue::NOBODY else (also in case of error)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define START_TIMER() DEBUG_INSTR(debugTime = chrono::high_resolution_clock::now())
|
#define START_TIMER() DEBUG_INSTR(debugTime = chrono::high_resolution_clock::now())
|
||||||
#define PRINT_TIMER(X) DEBUG_MSG((X) << " :" << chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now()-debugTime).count())
|
#define PRINT_TIMER(X) DEBUG_MSG((X) << " :" << chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now()-debugTime).count())
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user