From 830e40ca778958a415c5dfe52fb3bf715f694fc0 Mon Sep 17 00:00:00 2001 From: Michael Chen Date: Tue, 30 Jan 2018 14:47:01 +0100 Subject: [PATCH 1/2] Fixed tiny uplaod bug --- gameover.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gameover.c b/gameover.c index 823f3a3..0b2cd62 100644 --- a/gameover.c +++ b/gameover.c @@ -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); } From 7b31604a5557a7cbe7f44f553c9539287d035c8b Mon Sep 17 00:00:00 2001 From: Michael Chen Date: Thu, 1 Feb 2018 11:41:12 +0100 Subject: [PATCH 2/2] Fixed collision with paddle at small ball scale --- breakout.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/breakout.c b/breakout.c index 61d9acb..a17341e 100644 --- a/breakout.c +++ b/breakout.c @@ -457,11 +457,11 @@ 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)); + 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_SteerMomentum(obj, paddle); // Sets it to unit vector! - // Following assumes that the paddle position was udated before the ball was updated + 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)); BALL_MoveAwayFromBoundaries(obj);