Proper block scaling (ingame) // BUG: Missing block
This commit is contained in:
parent
e707caa7cc
commit
e253025cfd
15
breakout.c
15
breakout.c
@ -25,7 +25,7 @@ SDL_Rect * BLOCK_SourceRects;
|
|||||||
Ball ball;
|
Ball ball;
|
||||||
Paddle paddle;
|
Paddle paddle;
|
||||||
Block * blocks;
|
Block * blocks;
|
||||||
int BlockCount = 25; // Move to scenery
|
int BlockCount = 60; // Move to scenery
|
||||||
Uint8 * PADDLE_MoveLeftKeys, * PADDLE_MoveRightKeys;
|
Uint8 * PADDLE_MoveLeftKeys, * PADDLE_MoveRightKeys;
|
||||||
double BALL_Speed = 15.0f;
|
double BALL_Speed = 15.0f;
|
||||||
int PADDLE_Speed = 10;
|
int PADDLE_Speed = 10;
|
||||||
@ -47,12 +47,11 @@ void BREAKOUT_INITIALIZE(SDL_Renderer * renderer, int width, int height){
|
|||||||
paddle = PADDLE_CreateDefault();
|
paddle = PADDLE_CreateDefault();
|
||||||
blocks = malloc(BlockCount * sizeof(Block));
|
blocks = malloc(BlockCount * sizeof(Block));
|
||||||
int index;
|
int index;
|
||||||
for (int y = 0; y < 5; y++) {
|
for (int y = 0; y < 6; y++) {
|
||||||
index = 5 * y;
|
index = 10 * y;
|
||||||
for (int x = 0; x < 5; x++) {
|
for (int x = 0; x < 10; x++) {
|
||||||
blocks[x + index] = BLOCK_CreateDefault();
|
blocks[x + index] = BLOCK_CreateDefault();
|
||||||
blocks[x + index].TargetRect.x = 200 * x;
|
blocks[x + index].TargetRect = (SDL_Rect) {.x = ((192 * x) + 4), .y = ((96 * y) + 2), .w = 184, .h = 92 };
|
||||||
blocks[x + index].TargetRect.y = 100 * y;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("Game initialized!\n");
|
printf("Game initialized!\n");
|
||||||
@ -74,8 +73,8 @@ void BREAKOUT_Update(Uint8 * keystate){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BREAKOUT_Draw(SDL_Renderer * renderer){
|
void BREAKOUT_Draw(SDL_Renderer * renderer){
|
||||||
for (size_t i = 0; i < BlockCount; i++) {
|
for (int i = 0; i < BlockCount; i++) {
|
||||||
BLOCK_Draw(renderer, blocks + i);
|
BLOCK_Draw(renderer, &(blocks[i]));
|
||||||
}
|
}
|
||||||
BALL_Draw(renderer, &ball);
|
BALL_Draw(renderer, &ball);
|
||||||
PADDLE_Draw(renderer, &paddle);
|
PADDLE_Draw(renderer, &paddle);
|
||||||
|
Loading…
Reference in New Issue
Block a user