diff --git a/breakout.c b/breakout.c index 0115e7b..9b03b30 100644 --- a/breakout.c +++ b/breakout.c @@ -164,7 +164,7 @@ void BREAKOUT_PushNewRow(Scenery * scenery){ } for (size_t x = 0; x < (scenery->XBlocks); x++) { (scenery->blocks)[x + oldBlockCount] = BLOCK_CreateDefault(); - (scenery->blocks)[x + oldBlockCount].TargetRect = (SDL_Rect) {.x = ((128 * x) + 2), .y = 1, .w = 124, .h = 62 }; + (scenery->blocks)[x + oldBlockCount].TargetRect = (SDL_Rect) {.x = ((128 * x) + 2), .y = -63, .w = 124, .h = 62 }; (scenery->blocks)[x + oldBlockCount].TextureIndex = (((scenery->TopLeftBlockColor) + x) % BLOCK_TextureCount); (scenery->blocks)[x + oldBlockCount].DestYValue = 1; } @@ -561,11 +561,17 @@ void PADDLE_MoveSmooth(Paddle * obj){ (obj->TargetRect).x = paddleXMid - (int)roundf((float)(paddleXMid - mouseX) * PADDLE_SmoothFactor) - halfPaddle; } +void PADDLE_MoveAuto(Scenery * scenery){ + int paddleXMid, halfPaddle = (((scenery->paddle).TargetRect).w / 2); + + paddleXMid = halfPaddle + ((scenery->paddle).TargetRect.x); // Current State + ((scenery->paddle).TargetRect).x = paddleXMid - (int)roundf((float)(paddleXMid - (((scenery->ball).Location).x + (rand() % 30) + ((scenery->ball).Size))) * 0.2f) - halfPaddle; +} + void PADDLE_AdaptSpeedGradient(Paddle * obj, int FrameCount){ if (FrameCount > PADDLE_AccelerationTime) return; (obj->TargetRect).w = PADDLE_MaxSize - (((double)FrameCount / (double)PADDLE_AccelerationTime) * (PADDLE_MaxSize - PADDLE_MinSize)); - } void PADDLE_Update(Paddle * obj, Scenery * scenery, const Uint8 * keystate){ @@ -586,6 +592,9 @@ void PADDLE_Update(Paddle * obj, Scenery * scenery, const Uint8 * keystate){ ((obj->TargetRect).x) += (obj->Speed); } break; + case Automatic: + PADDLE_MoveAuto(scenery); + break; default: printf("Unknown Paddle Control Mode: %d!\n", obj->Mode); break; diff --git a/breakout.h b/breakout.h index b5dcd5c..7240da0 100644 --- a/breakout.h +++ b/breakout.h @@ -10,7 +10,7 @@ #include "vector.h" // Enums -typedef enum controlModeEnum {KeyboardControl = 0, MouseControl = 1} ControlMode; +typedef enum controlModeEnum {KeyboardControl = 0, MouseControl = 1, Automatic = 2} ControlMode; // End Enums // Structs