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()
|
#define MIRROR(SP) mirrorData((SP).getPixelData(), (SP).getRowSize()), (SP).getRowSize()
|
||||||
|
|
||||||
|
typedef nsGui::GlutFont::GlutFonts Font;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @class PixelManager
|
* @class PixelManager
|
||||||
@ -172,16 +173,9 @@ public:
|
|||||||
* @param[in] pos : pixel coordinates of the text
|
* @param[in] pos : pixel coordinates of the text
|
||||||
* @param[in] text : text to show on screen
|
* @param[in] text : text to show on screen
|
||||||
* @param[in] color : color of the text to show
|
* @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;
|
void drawText(const Position& pos, const string& text, const RGBAcolor& color = nsGraphics::KWhite, Font font = Font::BITMAP_TIMES_ROMAN_24) const;
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief display the current screen refresh rate
|
|
||||||
* @param[in] fps : current framerate
|
|
||||||
* @fn void drawFPS(unsigned fps) const;
|
|
||||||
*/
|
|
||||||
void drawFPS(unsigned fps) const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief show the title screen of the game
|
* @brief show the title screen of the game
|
||||||
@ -226,10 +220,11 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
* @brief display the player name selection menu
|
* @brief display the player name selection menu
|
||||||
* @param[in] pID : player id
|
* @param[in] pID : player id
|
||||||
|
* @param[in] score : score of this player
|
||||||
* @param[out] name : name selected by the player
|
* @param[out] name : name selected by the player
|
||||||
* @fn
|
* @fn
|
||||||
*/
|
*/
|
||||||
void askPlayerNameMenu(playerID pID, string& name);
|
void askPlayerNameMenu(playerID pID, unsigned score, string& name);
|
||||||
|
|
||||||
// y will be negative sometimes, so not unsigned
|
// 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 {
|
void PixelManager::drawText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color, Font font) const {
|
||||||
window << Text(pos, text, color, GlutFont::GlutFonts::BITMAP_TIMES_ROMAN_24);
|
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>
|
vector<RGBAcolor>
|
||||||
PixelManager::mirrorData(const vector<nsGraphics::RGBAcolor>& inPixels, unsigned rowSize) {
|
PixelManager::mirrorData(const vector<nsGraphics::RGBAcolor>& inPixels, unsigned rowSize) {
|
||||||
vector<RGBAcolor> outPixels;
|
vector<RGBAcolor> outPixels;
|
||||||
|
@ -30,7 +30,7 @@ void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){
|
|||||||
startFrame();
|
startFrame();
|
||||||
drawSprite(menuBackground);
|
drawSprite(menuBackground);
|
||||||
drawSprite(logo,Position(100,50));
|
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 margin = 0;
|
||||||
size_t cpt = 0;
|
size_t cpt = 0;
|
||||||
for(string& value : currentMenu.entries ){
|
for(string& value : currentMenu.entries ){
|
||||||
@ -77,16 +77,18 @@ PlayMode PixelManager::showInitialMenu(){
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixelManager::askPlayerNameMenu(playerID pID, string& name) {
|
void PixelManager::askPlayerNameMenu(playerID pID, unsigned score, string& name) {
|
||||||
name = string(6, 'A');
|
name = string(6, 'A');
|
||||||
size_t currentSelected = 0 ;
|
size_t currentSelected = 0 ;
|
||||||
chrono::milliseconds waitTime = chrono::milliseconds(100);
|
chrono::milliseconds waitTime = chrono::milliseconds(100);
|
||||||
while (window.isOpen()){
|
while (window.isOpen()){
|
||||||
startFrame();
|
startFrame();
|
||||||
drawSprite(menuBackground);
|
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){
|
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();
|
endFrame();
|
||||||
// go down
|
// go down
|
||||||
|
@ -37,8 +37,9 @@ void Game::displayAll(unsigned fps) const {
|
|||||||
|
|
||||||
displayGod();
|
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){
|
for(size_t i=0;i<players.size();++i){
|
||||||
if(!players[i].isEliminated()){
|
if(!players[i].isEliminated()){
|
||||||
|
@ -28,13 +28,10 @@ bool Game::areThereInvadersLeft(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::handleScoreSaving(){
|
void Game::handleScoreSaving(){
|
||||||
|
for(unsigned i=0;i<players.size();++i){
|
||||||
string pName;
|
string pName;
|
||||||
pm.askPlayerNameMenu(PLAYER1, pName);
|
pm.askPlayerNameMenu(i, players[i].score, pName);
|
||||||
sm.inputScore(move(pName), players[0].score);
|
sm.inputScore(move(pName), players[i].score);
|
||||||
if(playMode==PlayMode::TWO_LOCAL){
|
|
||||||
string pName2;
|
|
||||||
pm.askPlayerNameMenu(PLAYER2, pName2);
|
|
||||||
sm.inputScore(move(pName2), players[1].score);
|
|
||||||
}
|
}
|
||||||
sm.writeFile();
|
sm.writeFile();
|
||||||
}
|
}
|
||||||
@ -154,5 +151,5 @@ Position Game::invIndexToPos(unsigned x, unsigned y) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Game::arePlayersDead() {
|
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(){
|
void Game::managePlayers(){
|
||||||
for(unsigned i=0;i<players.size();++i)manageOnePlayer(i);
|
for(unsigned i=0;i<players.size();++i)manageOnePlayer(i);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user