Skip to content
Snippets Groups Projects
Commit 2cd5d8c2 authored by CARDILE VINCENT's avatar CARDILE VINCENT
Browse files

correction text

parent 1d1276fb
Branches
No related merge requests found
......@@ -61,6 +61,7 @@ public:
void moveRight();
void displayText(const char* text, u_int16_t x, u_int16_t y, u_int16_t nbChar, SDL_Color color);
void gameOver();
void clearText(u_int8_t nbToDel);
};
#endif
\ No newline at end of file
......@@ -16,8 +16,8 @@ std::vector<SDL_Texture*> Menu::textTextures;
u_int16_t Menu::DEFAULT_SCREEN_WIDTH = 640;
u_int16_t Menu::DEFAULT_SCREEN_HEIGHT = 480;
u_int16_t Menu::TEXT_HEIGHT = DEFAULT_SCREEN_HEIGHT/18;
u_int16_t Menu::TEXT_WIDTH = DEFAULT_SCREEN_WIDTH/40;
u_int16_t Menu::TEXT_HEIGHT = DEFAULT_SCREEN_HEIGHT/10;
u_int16_t Menu::TEXT_WIDTH = DEFAULT_SCREEN_WIDTH/30;
/**
......@@ -80,8 +80,8 @@ Menu::reset()
void
Menu::gameOver()
{
this->displayText("Game Over", DEFAULT_SCREEN_WIDTH/2 - 50, DEFAULT_SCREEN_HEIGHT/2, 9, Draw::WHITE);
this->displayText("Press R to restart", DEFAULT_SCREEN_WIDTH/2 - 75, DEFAULT_SCREEN_HEIGHT/2 + 20, 17, Draw::WHITE);
this->displayText("Game Over", DEFAULT_SCREEN_WIDTH/2 - 4 * TEXT_WIDTH, DEFAULT_SCREEN_HEIGHT/2, 9, Draw::LIGHT_GRAY);
this->displayText("Press R to restart", DEFAULT_SCREEN_WIDTH/2 - 8 * TEXT_WIDTH, DEFAULT_SCREEN_HEIGHT/2 + TEXT_HEIGHT , 17, Draw::LIGHT_GRAY);
this->freeze = true;
}
......@@ -112,6 +112,9 @@ Menu::handleRightPress()
void
Menu::handleRPress()
{
if(this->textSurfaces.size() > 0 && this->textTextures.size() > 0 && this->freeze) {
this->clearText(2);
}
this->reset();
}
......@@ -123,15 +126,8 @@ void
Menu::handleSpacePress()
{
this->toggleReady();
if(!this->gameStarted) {
if(!this->gameStarted)
this->gameStarted = true;
if(this->textSurfaces.size() > 0 && this->textTextures.size() > 0) {
SDL_DestroyTexture(this->textTextures.back());
SDL_FreeSurface(this->textSurfaces.back());
this->textTextures.pop_back();
this->textSurfaces.pop_back();
}
}
}
/**
......@@ -199,4 +195,16 @@ Menu::displayText(const char* text, u_int16_t x, u_int16_t y, u_int16_t nbChar,
SDL_RenderCopy(renderer, message, NULL, &messageRect);
this->textSurfaces.push_back(surfaceMessage);
this->textTextures.push_back(message);
}
void
Menu::clearText(u_int8_t nbToDel)
{
for (u_int8_t i = 0; i < nbToDel; i++)
{
SDL_DestroyTexture(this->textTextures.back());
SDL_FreeSurface(this->textSurfaces.back());
this->textTextures.pop_back();
this->textSurfaces.pop_back();
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment