fatigué
This commit is contained in:
parent
8f24a307f8
commit
a10a1e67c5
@ -29,6 +29,7 @@ using namespace std;
|
||||
|
||||
#define MIRROR(SP) mirrorData((SP).getPixelData(), (SP).getRowSize()), (SP).getRowSize()
|
||||
|
||||
typedef nsGui::GlutFont::GlutFonts Font;
|
||||
|
||||
/*!
|
||||
* @class PixelManager
|
||||
@ -172,16 +173,9 @@ public:
|
||||
* @param[in] pos : pixel coordinates of the text
|
||||
* @param[in] text : text to show on screen
|
||||
* @param[in] color : color of the text to show
|
||||
* @fn void displayText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color = nsGraphics::KWhite) const;
|
||||
* @fn void drawText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color = nsGraphics::KWhite) const;
|
||||
*/
|
||||
void displayText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color = nsGraphics::KWhite) const;
|
||||
|
||||
/*!
|
||||
* @brief display the current screen refresh rate
|
||||
* @param[in] fps : current framerate
|
||||
* @fn void drawFPS(unsigned fps) const;
|
||||
*/
|
||||
void drawFPS(unsigned fps) const;
|
||||
void drawText(const Position& pos, const string& text, const RGBAcolor& color = nsGraphics::KWhite, Font font = Font::BITMAP_TIMES_ROMAN_24) const;
|
||||
|
||||
/*!
|
||||
* @brief show the title screen of the game
|
||||
@ -226,10 +220,11 @@ public:
|
||||
/*!
|
||||
* @brief display the player name selection menu
|
||||
* @param[in] pID : player id
|
||||
* @param[in] score : score of this player
|
||||
* @param[out] name : name selected by the player
|
||||
* @fn
|
||||
*/
|
||||
void askPlayerNameMenu(playerID pID, string& name);
|
||||
void askPlayerNameMenu(playerID pID, unsigned score, string& name);
|
||||
|
||||
// y will be negative sometimes, so not unsigned
|
||||
|
||||
|
@ -125,15 +125,10 @@ void PixelManager::drawGodFace(int y, bool angry) const {
|
||||
|
||||
}
|
||||
|
||||
void PixelManager::displayText(const Position& pos, const string& text,const nsGraphics::RGBAcolor& color) const {
|
||||
window << Text(pos, text, color, GlutFont::GlutFonts::BITMAP_TIMES_ROMAN_24);
|
||||
void PixelManager::drawText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color, Font font) const {
|
||||
window << Text(pos, text, color, font);
|
||||
}
|
||||
|
||||
void PixelManager::drawFPS(unsigned fps) const {
|
||||
window << Text(Position(getScreenWidth()-200, 10), "FPS : "+ to_string(fps), nsGraphics::KWhite);
|
||||
}
|
||||
|
||||
|
||||
vector<RGBAcolor>
|
||||
PixelManager::mirrorData(const vector<nsGraphics::RGBAcolor>& inPixels, unsigned rowSize) {
|
||||
vector<RGBAcolor> outPixels;
|
||||
|
@ -30,7 +30,7 @@ void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){
|
||||
startFrame();
|
||||
drawSprite(menuBackground);
|
||||
drawSprite(logo,Position(100,50));
|
||||
displayText(Position(1150,700), "version 1.0.0");
|
||||
drawText(Position(1150, 700), "version 1.0.0");
|
||||
size_t margin = 0;
|
||||
size_t cpt = 0;
|
||||
for(string& value : currentMenu.entries ){
|
||||
@ -77,16 +77,18 @@ PlayMode PixelManager::showInitialMenu(){
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void PixelManager::askPlayerNameMenu(playerID pID, string& name) {
|
||||
void PixelManager::askPlayerNameMenu(playerID pID, unsigned score, string& name) {
|
||||
name = string(6, 'A');
|
||||
size_t currentSelected = 0 ;
|
||||
chrono::milliseconds waitTime = chrono::milliseconds(100);
|
||||
while (window.isOpen()){
|
||||
startFrame();
|
||||
drawSprite(menuBackground);
|
||||
displayText(Position(600,100),"Nom du joueur "+to_string(pID+1));
|
||||
drawText(Position(600, 100), "Nom du joueur " + to_string(pID + 1));
|
||||
drawText(Position(600, 150), "Score : " + to_string(score));
|
||||
for (size_t i = 0; i < name.size(); ++i){
|
||||
displayText(Position(600+30*i,200),string(1,name[i]),(i == currentSelected) ? nsGraphics::KRed : nsGraphics::KWhite);
|
||||
drawText(Position(600 + 30 * i, 200), string(1, name[i]),
|
||||
(i == currentSelected) ? nsGraphics::KRed : nsGraphics::KWhite);
|
||||
}
|
||||
endFrame();
|
||||
// go down
|
||||
|
@ -37,8 +37,9 @@ void Game::displayAll(unsigned fps) const {
|
||||
|
||||
displayGod();
|
||||
|
||||
pm.drawFPS(fps);
|
||||
|
||||
DEBUG_INSTR(
|
||||
pm.drawText(Position(pm.getScreenWidth()-200, 20), "FPS : "+to_string(fps), nsGraphics::KWhite, Font::BITMAP_8_BY_13);
|
||||
)
|
||||
|
||||
for(size_t i=0;i<players.size();++i){
|
||||
if(!players[i].isEliminated()){
|
||||
|
@ -28,13 +28,10 @@ bool Game::areThereInvadersLeft(){
|
||||
}
|
||||
|
||||
void Game::handleScoreSaving(){
|
||||
string pName;
|
||||
pm.askPlayerNameMenu(PLAYER1, pName);
|
||||
sm.inputScore(move(pName), players[0].score);
|
||||
if(playMode==PlayMode::TWO_LOCAL){
|
||||
string pName2;
|
||||
pm.askPlayerNameMenu(PLAYER2, pName2);
|
||||
sm.inputScore(move(pName2), players[1].score);
|
||||
for(unsigned i=0;i<players.size();++i){
|
||||
string pName;
|
||||
pm.askPlayerNameMenu(i, players[i].score, pName);
|
||||
sm.inputScore(move(pName), players[i].score);
|
||||
}
|
||||
sm.writeFile();
|
||||
}
|
||||
@ -154,5 +151,5 @@ Position Game::invIndexToPos(unsigned x, unsigned y) const {
|
||||
}
|
||||
|
||||
bool Game::arePlayersDead() {
|
||||
return all_of(players.begin(), players.end(), [](Player& p){return p.isEliminated();});
|
||||
return all_of(players.begin(), players.end(), [](Player& p) -> bool {return p.isEliminated();});
|
||||
}
|
||||
|
@ -42,8 +42,6 @@ void Game::manageOnePlayer(playerID pID){
|
||||
}
|
||||
}
|
||||
|
||||
/** Makes the players play once
|
||||
*/
|
||||
void Game::managePlayers(){
|
||||
for(unsigned i=0;i<players.size();++i)manageOnePlayer(i);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user