projects
/
pong.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8011e36
)
resetting when the ball goes off-screen
author
Matthew Owens
<matthew@owens.tech>
Sat, 3 Oct 2020 12:05:51 +0000
(13:05 +0100)
committer
Matthew Owens
<matthew@owens.tech>
Sat, 3 Oct 2020 12:05:51 +0000
(13:05 +0100)
src/main.c
patch
|
blob
|
history
diff --git
a/src/main.c
b/src/main.c
index
20cd0a6
..
e8866d5
100644
(file)
--- a/
src/main.c
+++ b/
src/main.c
@@
-168,10
+168,11
@@
static void ball_update(const Uint8 *keyStates, float dt)
ball.v.x *= -1;
}
if(ball.r.y + ball.r.h > windowSize.y){
- ball.r.y = windowSize.y - ball.r.h;
+ ball_init();
+ ball.v.x = 0;
ball.v.y *= -1;
}
- if(ball.r.y < 0 ) { ball.r.y = 0; ball
.v.y *= -1;
}
+ if(ball.r.y < 0 ) { ball.r.y = 0; ball
_init(); ball.v.x = 0;
}
if(ball.r.x < 0 ) { ball.r.x = 0; ball.v.x *= -1; }
}