Proper block scaling (ingame) // BUG: Missing block

This commit is contained in:
Michael Chen 2018-01-15 15:35:25 +01:00
parent e707caa7cc
commit e253025cfd

View File

@ -25,7 +25,7 @@ SDL_Rect * BLOCK_SourceRects;
Ball ball;
Paddle paddle;
Block * blocks;
int BlockCount = 25; // Move to scenery
int BlockCount = 60; // Move to scenery
Uint8 * PADDLE_MoveLeftKeys, * PADDLE_MoveRightKeys;
double BALL_Speed = 15.0f;
int PADDLE_Speed = 10;
@ -47,12 +47,11 @@ void BREAKOUT_INITIALIZE(SDL_Renderer * renderer, int width, int height){
paddle = PADDLE_CreateDefault();
blocks = malloc(BlockCount * sizeof(Block));
int index;
for (int y = 0; y < 5; y++) {
index = 5 * y;
for (int x = 0; x < 5; x++) {
for (int y = 0; y < 6; y++) {
index = 10 * y;
for (int x = 0; x < 10; x++) {
blocks[x + index] = BLOCK_CreateDefault();
blocks[x + index].TargetRect.x = 200 * x;
blocks[x + index].TargetRect.y = 100 * y;
blocks[x + index].TargetRect = (SDL_Rect) {.x = ((192 * x) + 4), .y = ((96 * y) + 2), .w = 184, .h = 92 };
}
}
printf("Game initialized!\n");
@ -74,8 +73,8 @@ void BREAKOUT_Update(Uint8 * keystate){
}
void BREAKOUT_Draw(SDL_Renderer * renderer){
for (size_t i = 0; i < BlockCount; i++) {
BLOCK_Draw(renderer, blocks + i);
for (int i = 0; i < BlockCount; i++) {
BLOCK_Draw(renderer, &(blocks[i]));
}
BALL_Draw(renderer, &ball);
PADDLE_Draw(renderer, &paddle);