diff --git a/source/code/DialogBox.cpp b/source/code/DialogBox.cpp index 6c6b2a2..6f337ae 100644 --- a/source/code/DialogBox.cpp +++ b/source/code/DialogBox.cpp @@ -95,7 +95,7 @@ bool DialogBox::IsActive() { void DialogBox::Draw(SDL_Renderer* target) { - backgroundImage.Draw(target, SDL_GetTicks(), 0, 0); + DrawBackground(screen); DrawRectYellow(target, x, y, 200, 600); nf_button_font.draw(target, x+300, y+20, NFont::CENTER, "%s", header.c_str()); nf_button_font.draw(target, x+150, y+140, NFont::CENTER, _("Enter to accept")); diff --git a/source/code/MenuSystem.cpp b/source/code/MenuSystem.cpp index 4656f15..042c8b8 100644 --- a/source/code/MenuSystem.cpp +++ b/source/code/MenuSystem.cpp @@ -122,7 +122,7 @@ int Button::getHeight() { void Menu::drawSelf() { SDL_RenderClear(screen); - backgroundImage.Draw(screen, SDL_GetTicks(), 0, 0); + DrawBackground(screen); vector::iterator it; for (it = buttons.begin(); it < buttons.end(); it++) { (*it)->drawToScreen(); diff --git a/source/code/ScoresDisplay.cpp b/source/code/ScoresDisplay.cpp index 027dd64..3d07ce1 100644 --- a/source/code/ScoresDisplay.cpp +++ b/source/code/ScoresDisplay.cpp @@ -39,7 +39,7 @@ const int numberOfPages = 3; //Draws the highscores void ScoresDisplay::DrawHighscores(int x, int y, bool endless) { - backgroundImage.Draw(screen, 0, 0, 0); + DrawBackground(screen); if (endless) { nf_standard_blue_font.draw(screen, x+100,y+100, "%s",_("Endless:") ); } @@ -64,7 +64,7 @@ void ScoresDisplay::DrawHighscores(int x, int y, bool endless) { } void ScoresDisplay::DrawStats() { - backgroundImage.Draw(screen, 0, 0, 0); + DrawBackground(screen); int y = 5; const int y_spacing = 30; NFont_Write(screen, 10,y,_("Stats") ); diff --git a/source/code/global.hpp b/source/code/global.hpp index 2c5a72a..f9a559c 100644 --- a/source/code/global.hpp +++ b/source/code/global.hpp @@ -38,6 +38,7 @@ enum class Gametype { SinglePlayerEndless=0, SinglePlayerTimeTrial=1, StageClear int runGame(Gametype gametype,int level); bool OpenDialogbox(int x, int y, std::string& name, const std::string& header); +void DrawBackground(SDL_Renderer* target); extern sago::SagoSprite menuMarked; extern sago::SagoSprite menuUnmarked; @@ -55,7 +56,6 @@ extern std::string player2name; extern SDL_Renderer *screen; //The whole screen; extern Mix_Chunk *typingChunk; extern sago::SagoSprite mouse; -extern sago::SagoSprite backgroundImage; extern bool highPriority; extern bool NoSound; extern int verboseLevel; diff --git a/source/code/main.cpp b/source/code/main.cpp index 2b48eb8..c510bcf 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp @@ -266,7 +266,7 @@ void ResetFullscreen() { SDL_ShowCursor(SDL_DISABLE); } -static void DrawBackground(SDL_Renderer* target) { +void DrawBackground(SDL_Renderer* target) { int w = 0; int h = 0; SDL_GetWindowSize(sdlWindow, &w, &h); @@ -311,9 +311,11 @@ public: if (y<1.0) { velocityY=10.0; } - if ((velocityY>minVelocity) && (y>(double)(768-ballSize)) && (y<768.0)) { + int h = 0; + SDL_GetWindowSize(sdlWindow, nullptr, &h); + if ((velocityY>minVelocity) && (y>(double)(h-ballSize)) && (y800 || ballArray[i].getX()>xsize || ballArray[i].getX()<-ballSize) { + if (ballArray[i].getY()>h+100 || ballArray[i].getX()>w || ballArray[i].getX()<-ballSize) { ballUsed[i] = false; } }