Merge branch 'devsave' of collaborating.tuhh.de:czg6669/breakout into devsave

This commit is contained in:
Andreas Neumann 2018-02-01 12:45:15 +01:00
commit 68f60a866f
2 changed files with 5 additions and 4 deletions

View File

@ -457,10 +457,10 @@ void BALL_MoveAwayFromBoundaries(Ball * obj){
bool BALL_CollideWithPaddle(Ball * obj, Paddle * paddle){
if (RECT_Collide(&(obj->TargetRect), &(paddle->TargetRect))) {
Vector ballCenter = BALL_GetCenter(obj);
if (ballCenter.y > (paddle->TargetRect).y) // if the ball hits the paddle from the sides (or the bottom (?))
BALL_CollideWithRect(obj, &(paddle->TargetRect));
else
if ((ballCenter.x) > ((paddle->TargetRect).x) || (ballCenter.x) < ((paddle->TargetRect).x + (paddle->TargetRect).w)) // if the ball hits the paddle from the sides (or the bottom (?))
BALL_SteerMomentum(obj, paddle); // Sets it to unit vector!
else
BALL_CollideWithRect(obj, &(paddle->TargetRect));
// Following assumes that the paddle position was udated before the ball was updated
while (RECT_Collide(&(obj->TargetRect), &(paddle->TargetRect))) { // Move away from rect in small steps
(obj->Location) = VECTOR_Add((obj->Location), (obj->Momentum));

View File

@ -135,6 +135,7 @@ void GAMEOVER_MouseClicked(SDL_MouseButtonEvent b, Scenery * scenery){
GAME_ChangeState(Highscores);
} else if (clickInRect(b, &GAMEOVER_RestartButtonRect)) {
printf("Restart was called from gameover!\n");
GAMEOVER_UploadState = Initial;
GAME_Restart();
GAME_ChangeState(Game);
}