git repos / blockattack-game

commit e4d93567

sago007 · 2016-09-28 17:26
e4d93567360308e3bd49907d551c4ee987585e20 patch · browse files
parent f1708e5e65ed2d5b0e7bf3142214776bdf01643b

The old global variables xsize and ysize now contains the actual size.

Changed files

M source/code/main.cpp before
diff --git a/source/code/main.cpp b/source/code/main.cpp index c510bcf..4b1e00f 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp
@@ -267,10 +267,8 @@ void ResetFullscreen() {
}
void DrawBackground(SDL_Renderer* target) {
- int w = 0;
- int h = 0;
- SDL_GetWindowSize(sdlWindow, &w, &h);
- backgroundImage.DrawScaled(target, SDL_GetTicks(), 0, 0, w, h);
+ SDL_GetWindowSize(sdlWindow, &xsize, &ysize);
+ backgroundImage.DrawScaled(target, SDL_GetTicks(), 0, 0, xsize, ysize);
}
//The small things that are faaling when you clear something
@@ -311,11 +309,9 @@ public:
if (y<1.0) {
velocityY=10.0;
}
- int h = 0;
- SDL_GetWindowSize(sdlWindow, nullptr, &h);
- if ((velocityY>minVelocity) && (y>(double)(h-ballSize)) && (y<h)) {
+ if ((velocityY>minVelocity) && (y>(ysize-ballSize)) && (y<ysize)) {
velocityY = -0.70*velocityY;
- y = h-ballSize;
+ y = ysize-ballSize;
}
lastTime = currentTime;
}
@@ -365,14 +361,11 @@ public:
void update() {
currentTime = SDL_GetTicks();
- int h = 0;
- int w = 0;
- SDL_GetWindowSize(sdlWindow, &w, &h);
for (int i = 0; i<maxNumberOfBalls; i++) {
if (ballUsed[i]) {
ballArray[i].update();
- if (ballArray[i].getY()>h+100 || ballArray[i].getX()>w || ballArray[i].getX()<-ballSize) {
+ if (ballArray[i].getY()>ysize+100 || ballArray[i].getX()>xsize || ballArray[i].getX()<-ballSize) {
ballUsed[i] = false;
}
}