fixed block push animation
This commit is contained in:
parent
396c8f7ddc
commit
2c860c2f4b
13
breakout.c
13
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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user