Added collision detection for bricks as well as a parameter to track whether a brick has been destroyed. Fixed an issue where the ball's position on the next frame did not incorporate tickrate compensation (mismatch between predicted next value and actual). Added 'substeps' (iterations of main function that do not draw to screen, to allow for more precise calculation of movement by performing the calculations more frequently) and SDL_Delay to reduce FPS if it exceeds a given value (to prevent very high CPU usage with 1000+fps where not at all necessary)

This commit is contained in:
Joe Adams 2018-01-07 15:41:35 +00:00
parent d233f15f34
commit a40944d189

View File

@ -35,6 +35,7 @@ typedef struct ball {
double initVX;
double initVY;
double radius;
char isColliding;
} ball;
typedef struct brick {
@ -43,6 +44,7 @@ typedef struct brick {
int y;
int width;
int height;
char destroyed;
} brick;
typedef struct brickCD {
@ -65,7 +67,7 @@ double heronsFormula(coord a, coord b, coord c) {
char vertexWithinQuad(coord point, coord *quad);
void updatePaddle(Uint32 tickrate, paddle *thePaddle, char moveX, int winWidth, int winHeight);
void updateBall(Uint32 tickrate, ball *theBall, paddle *thePaddle, int winWidth, int winHeight);
void updateBall(Uint32 tickrate, ball *theBall, paddle *thePaddle, int winWidth, int winHeight, brick *bricks, int brickCount);
void drawPaddle(paddle *thePaddle, int winWidth, int winHeight, colour *c);
void drawBall(ball *theBall, colour *c);
@ -95,6 +97,7 @@ int main(void) {
}
int go; //Var for loop control
int step = 0; //Var for step counter
/* ----------------
* Main Window
@ -171,7 +174,10 @@ int main(void) {
* Game variables
* ----------------
*/
char subSteps = 3; // Draw every N+1 frames, thereby calculating movement more precisely
int targetFPS = 144; // Limit FPS to this value, to stop unneccessary calculations
char moveX=0;
brick bricks[128];
@ -187,10 +193,11 @@ int main(void) {
.x = 0,
.y = 0,
.vX = 0.4f,
.vY = -1.5f,
.vY = -3.0f,
.initVX = theBall.vX,
.initVY = theBall.vY,
.radius = 4
.radius = 4,
.isColliding = 0
};
paddle thePaddle = {
@ -265,45 +272,50 @@ int main(void) {
*/
updatePaddle(tickrate, &thePaddle, moveX, winWidth, winHeight);
updateBall(tickrate, &theBall, &thePaddle, winWidth, winHeight);
updateBall(tickrate, &theBall, &thePaddle, winWidth, winHeight, &bricks, brickCount);
/*
* ----------------
* Draw to buffer
* ----------------
*/
if (step % (subSteps+1) == 0) {
//step = 0;
/*
* ----------------
* Draw to buffer
* ----------------
*/
SDL_GL_MakeCurrent(window1, context1);
SDL_GL_MakeCurrent(window1, context1);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
colour paddleCol;
paddleCol.r = 1.0; paddleCol.g = 1.0; paddleCol.b = 1.0; paddleCol.a = 1.0;
colour paddleCol;
paddleCol.r = 1.0; paddleCol.g = 1.0; paddleCol.b = 1.0; paddleCol.a = 1.0;
colour bgcol1; colour bgcol2;
bgcol1.r = 0.7216; /*184*/ bgcol2.r = 0.0824; /*21 */
bgcol1.g = 0.2471; /*63 */ bgcol2.g = 0.0901; /*23 */
bgcol1.b = 0.6078; /*155*/ bgcol2.b = 0.4431; /*113*/
bgcol1.a = 1.0000; /*255*/ bgcol2.a = 1.0000; /*255*/
colour bgcol1; colour bgcol2;
bgcol1.r = 0.7216; /*184*/ bgcol2.r = 0.0824; /*21 */
bgcol1.g = 0.2471; /*63 */ bgcol2.g = 0.0901; /*23 */
bgcol1.b = 0.6078; /*155*/ bgcol2.b = 0.4431; /*113*/
bgcol1.a = 1.0000; /*255*/ bgcol2.a = 1.0000; /*255*/
drawPaddle(&thePaddle, winWidth, winHeight, &paddleCol);
drawBall(&theBall, &paddleCol);
drawBricks(&bricks, brickCount, winWidth, winHeight, &brickColours);
drawBg(winWidth, winHeight, &bgcol1, &bgcol2);
glFlush();
/*
* --------------------------------
* Output to Window
* --------------------------------
*/
SDL_GL_SwapWindow(window1);
drawPaddle(&thePaddle, winWidth, winHeight, &paddleCol);
drawBall(&theBall, &paddleCol);
drawBricks(&bricks, brickCount, winWidth, winHeight, &brickColours);
drawBg(winWidth, winHeight, &bgcol1, &bgcol2);
glFlush();
/*
* --------------------------------
* Output to Window
* --------------------------------
*/
SDL_GL_SwapWindow(window1);
}
if (SDL_GetTicks() - timer < 1000 / (targetFPS * (subSteps+1))) SDL_Delay((1000 / (targetFPS * (subSteps+1))) - (SDL_GetTicks() - timer));
step++;
}
/*
@ -338,38 +350,82 @@ void updatePaddle(Uint32 tickrate, paddle *thePaddle, char moveX, int winWidth,
if (thePaddle->x > winWidth-(thePaddle->width/2)) thePaddle->x = winWidth-(thePaddle->width/2);
}
void updateBall(Uint32 tickrate, ball *theBall, paddle *thePaddle, int winWidth, int winHeight) {
double ballNX = theBall->x + theBall->vX; // Calculates the position of the ball's centre on the next step
double ballNY = theBall->y + theBall->vY;
void updateBall(Uint32 tickrate, ball *theBall, paddle *thePaddle, int winWidth, int winHeight, brick *bricks, int brickCount) {
double ballNX = theBall->x + theBall->vX * 0.1 * tickrate; // Calculates the position of the ball's centre on the next step
double ballNY = theBall->y + theBall->vY * 0.1 * tickrate;
double paddleRX = thePaddle->x - (double)(winWidth / 2);
double paddleRY = 20 - (double)(winHeight / 2);
coord paddle[4] = {
{ .x = paddleRX, .y = paddleRY },
{ .x = paddleRX, .y = paddleRY+thePaddle->height },
{ .x = paddleRX+thePaddle->width, .y = paddleRY+thePaddle->height },
{ .x = paddleRX+thePaddle->width, .y = paddleRY },
{.x = paddleRX, .y = paddleRY },
{.x = paddleRX, .y = paddleRY - thePaddle->height },
{.x = paddleRX + thePaddle->width, .y = paddleRY - thePaddle->height },
{.x = paddleRX + thePaddle->width, .y = paddleRY },
};
// Collision with paddle
// (Testing each vertex of ball)
char colliding = 0;
int mults[4] = { -1,-1,1,1 };
for (int i = 0, j = 3; i < 4; i++, j++) {
coord ballN = { .x = ballNX+(theBall->radius*mults[i%4]), .y = ballNY+(theBall->radius*mults[j%4]) };
coord ballN = { .x = ballNX + (theBall->radius*mults[i % 4]),.y = ballNY + (theBall->radius*mults[j % 4]) };
if (vertexWithinQuad(ballN, paddle)) colliding = 1;
}
if (colliding) {
if (theBall->x + theBall->radius < paddleRX) { // Left side collision
theBall->vX *= -1.0;
} else if (theBall->x - theBall->radius > paddleRX + thePaddle->width) { // Right side collision
theBall->vX *= -1.0;
if (theBall->isColliding == 0) {
theBall->isColliding == 1;
if (theBall->x + theBall->radius < paddleRX) { // Left side collision
theBall->vX *= -1.0;
}
else if (theBall->x - theBall->radius > paddleRX + thePaddle->width) { // Right side collision
theBall->vX *= -1.0;
}
else {
theBall->vY *= -1.0;
theBall->vX = ((ballNX - paddleRX - (double)(thePaddle->width / 2)) / ((double)thePaddle->width / 2))*0.5; // Sets X velocity to be proportional to the relative position of the ball and the paddle on collision
}
} else {
theBall->vY *= -1.0;
theBall->vX = ((ballNX - paddleRX - (double)(thePaddle->width / 2)) / ((double)thePaddle->width / 2))*0.5; // Sets X velocity to be proportional to the relative position of the ball and the paddle on collision
// Already solving a collision
}
} else {
theBall->isColliding = 0;
}
// Collision with bricks
// (Testing each vertex of ball against every brick)
for (int i = 0; i < brickCount; i++) {
colliding = 0;
if (bricks[i].destroyed == 0) {
coord brick[4] = {
{.x = bricks[i].x - (winWidth / 2), .y = bricks[i].y },
{.x = bricks[i].x - (winWidth / 2), .y = bricks[i].y - bricks[i].height },
{.x = bricks[i].x - (winWidth / 2) + bricks[i].width, .y = bricks[i].y - bricks[i].height },
{.x = bricks[i].x - (winWidth / 2) + bricks[i].width, .y = bricks[i].y },
};
for (int j = 0, k = 3; j < 4; j++, k++) {
coord ballN = { .x = ballNX + (theBall->radius*mults[j % 4]),.y = ballNY + (theBall->radius*mults[k % 4]) };
if (vertexWithinQuad(ballN, brick)) colliding = 1;
}
if (colliding) {
if (theBall->x + theBall->radius < bricks[i].x - (winWidth / 2)) { // Left side collision
theBall->vX *= -1.0;
}
else if (theBall->x - theBall->radius > bricks[i].x - (winWidth / 2) + bricks[i].width) { // Right side collision
theBall->vX *= -1.0;
}
else {
theBall->vY *= -1.0;
}
bricks[i].destroyed = 1;
break;
}
}
}
@ -417,8 +473,8 @@ void drawPaddle(paddle *thePaddle, int winWidth, int winHeight, colour *c) {
glBegin(GL_QUADS);
glColor3f(c->r, c->g, c->b);
glVertex3d(0.0, 0.0, 0.0);
glVertex3d(0.0, (double)thePaddle->height, 0.0);
glVertex3d((double)thePaddle->width, (double)thePaddle->height, 0.0);
glVertex3d(0.0, (double)-1*thePaddle->height, 0.0);
glVertex3d((double)thePaddle->width, (double)-1*thePaddle->height, 0.0);
glVertex3d((double)thePaddle->width, 0.0, 0.0);
glEnd();
@ -446,138 +502,140 @@ void drawBall(ball *theBall, colour *c) {
void drawBricks(brick *bricks, int brickCount, int winWidth, int winHeight, colour *colours) {
for (int i = 0; i < brickCount; i++) {
GLint matrixmode = 0;
glGetIntegerv(GL_MATRIX_MODE, &matrixmode);
glPushMatrix();
glTranslated((double)bricks[i].x-(winWidth/2), (double)bricks[i].y, 0.0);
glBegin(GL_QUADS);
if (bricks[i].destroyed == 0) {
GLint matrixmode = 0;
glGetIntegerv(GL_MATRIX_MODE, &matrixmode);
glPushMatrix();
glTranslated((double)bricks[i].x - (winWidth / 2), (double)bricks[i].y, 0.0);
glBegin(GL_QUADS);
glColor3f(
colours[bricks[i].brickType-1].r,
colours[bricks[i].brickType-1].g,
colours[bricks[i].brickType-1].b
colours[bricks[i].brickType - 1].r,
colours[bricks[i].brickType - 1].g,
colours[bricks[i].brickType - 1].b
);
glVertex3d(0.0, 0.0, 0.0);
glVertex3d(0.0, (double)bricks[i].height, 0.0);
glVertex3d(0.0, 0.0, 0.0);
glVertex3d(0.0, (double)bricks[i].height, 0.0);
glVertex3d((double)bricks[i].width, (double)bricks[i].height, 0.0);
glVertex3d((double)bricks[i].width, 0.0, 0.0);
glEnd();
glPopMatrix();
glMatrixMode(matrixmode);
glVertex3d((double)bricks[i].width, 0.0, 0.0);
glEnd();
glPopMatrix();
glMatrixMode(matrixmode);
}
}
}
void initialiseBricks(brick *bricks, int *brickCount) {
bricks[0 ] = (brick) { .brickType = 1, .x = 17, .y = 130, .width = 30, .height = 10 };
bricks[1 ] = (brick) { .brickType = 1, .x = 49, .y = 130, .width = 30, .height = 10 };
bricks[2 ] = (brick) { .brickType = 1, .x = 81, .y = 130, .width = 30, .height = 10 };
bricks[3 ] = (brick) { .brickType = 1, .x = 113, .y = 130, .width = 30, .height = 10 };
bricks[4 ] = (brick) { .brickType = 1, .x = 145, .y = 130, .width = 30, .height = 10 };
bricks[5 ] = (brick) { .brickType = 1, .x = 177, .y = 130, .width = 30, .height = 10 };
bricks[6 ] = (brick) { .brickType = 1, .x = 209, .y = 130, .width = 30, .height = 10 };
bricks[7 ] = (brick) { .brickType = 1, .x = 241, .y = 130, .width = 30, .height = 10 };
bricks[8 ] = (brick) { .brickType = 1, .x = 273, .y = 130, .width = 30, .height = 10 };
bricks[9 ] = (brick) { .brickType = 1, .x = 305, .y = 130, .width = 30, .height = 10 };
bricks[10 ] = (brick) { .brickType = 1, .x = 337, .y = 130, .width = 30, .height = 10 };
bricks[11 ] = (brick) { .brickType = 1, .x = 369, .y = 130, .width = 30, .height = 10 };
bricks[12 ] = (brick) { .brickType = 1, .x = 401, .y = 130, .width = 30, .height = 10 };
bricks[13 ] = (brick) { .brickType = 1, .x = 433, .y = 130, .width = 30, .height = 10 };
bricks[14 ] = (brick) { .brickType = 1, .x = 17, .y = 142, .width = 30, .height = 10 };
bricks[15 ] = (brick) { .brickType = 1, .x = 49, .y = 142, .width = 30, .height = 10 };
bricks[16 ] = (brick) { .brickType = 1, .x = 81, .y = 142, .width = 30, .height = 10 };
bricks[17 ] = (brick) { .brickType = 1, .x = 113, .y = 142, .width = 30, .height = 10 };
bricks[18 ] = (brick) { .brickType = 1, .x = 145, .y = 142, .width = 30, .height = 10 };
bricks[19 ] = (brick) { .brickType = 1, .x = 177, .y = 142, .width = 30, .height = 10 };
bricks[20 ] = (brick) { .brickType = 1, .x = 209, .y = 142, .width = 30, .height = 10 };
bricks[21 ] = (brick) { .brickType = 1, .x = 241, .y = 142, .width = 30, .height = 10 };
bricks[22 ] = (brick) { .brickType = 1, .x = 273, .y = 142, .width = 30, .height = 10 };
bricks[23 ] = (brick) { .brickType = 1, .x = 305, .y = 142, .width = 30, .height = 10 };
bricks[24 ] = (brick) { .brickType = 1, .x = 337, .y = 142, .width = 30, .height = 10 };
bricks[25 ] = (brick) { .brickType = 1, .x = 369, .y = 142, .width = 30, .height = 10 };
bricks[26 ] = (brick) { .brickType = 1, .x = 401, .y = 142, .width = 30, .height = 10 };
bricks[27 ] = (brick) { .brickType = 1, .x = 433, .y = 142, .width = 30, .height = 10 };
bricks[28 ] = (brick) { .brickType = 2, .x = 17, .y = 154, .width = 30, .height = 10 };
bricks[29 ] = (brick) { .brickType = 2, .x = 49, .y = 154, .width = 30, .height = 10 };
bricks[30 ] = (brick) { .brickType = 2, .x = 81, .y = 154, .width = 30, .height = 10 };
bricks[31 ] = (brick) { .brickType = 2, .x = 113, .y = 154, .width = 30, .height = 10 };
bricks[32 ] = (brick) { .brickType = 2, .x = 145, .y = 154, .width = 30, .height = 10 };
bricks[33 ] = (brick) { .brickType = 2, .x = 177, .y = 154, .width = 30, .height = 10 };
bricks[34 ] = (brick) { .brickType = 2, .x = 209, .y = 154, .width = 30, .height = 10 };
bricks[35 ] = (brick) { .brickType = 2, .x = 241, .y = 154, .width = 30, .height = 10 };
bricks[36 ] = (brick) { .brickType = 2, .x = 273, .y = 154, .width = 30, .height = 10 };
bricks[37 ] = (brick) { .brickType = 2, .x = 305, .y = 154, .width = 30, .height = 10 };
bricks[38 ] = (brick) { .brickType = 2, .x = 337, .y = 154, .width = 30, .height = 10 };
bricks[39 ] = (brick) { .brickType = 2, .x = 369, .y = 154, .width = 30, .height = 10 };
bricks[40 ] = (brick) { .brickType = 2, .x = 401, .y = 154, .width = 30, .height = 10 };
bricks[41 ] = (brick) { .brickType = 2, .x = 433, .y = 154, .width = 30, .height = 10 };
bricks[42 ] = (brick) { .brickType = 2, .x = 17, .y = 166, .width = 30, .height = 10 };
bricks[43 ] = (brick) { .brickType = 2, .x = 49, .y = 166, .width = 30, .height = 10 };
bricks[44 ] = (brick) { .brickType = 2, .x = 81, .y = 166, .width = 30, .height = 10 };
bricks[45 ] = (brick) { .brickType = 2, .x = 113, .y = 166, .width = 30, .height = 10 };
bricks[46 ] = (brick) { .brickType = 2, .x = 145, .y = 166, .width = 30, .height = 10 };
bricks[47 ] = (brick) { .brickType = 2, .x = 177, .y = 166, .width = 30, .height = 10 };
bricks[48 ] = (brick) { .brickType = 2, .x = 209, .y = 166, .width = 30, .height = 10 };
bricks[49 ] = (brick) { .brickType = 2, .x = 241, .y = 166, .width = 30, .height = 10 };
bricks[50 ] = (brick) { .brickType = 2, .x = 273, .y = 166, .width = 30, .height = 10 };
bricks[51 ] = (brick) { .brickType = 2, .x = 305, .y = 166, .width = 30, .height = 10 };
bricks[52 ] = (brick) { .brickType = 2, .x = 337, .y = 166, .width = 30, .height = 10 };
bricks[53 ] = (brick) { .brickType = 2, .x = 369, .y = 166, .width = 30, .height = 10 };
bricks[54 ] = (brick) { .brickType = 2, .x = 401, .y = 166, .width = 30, .height = 10 };
bricks[55 ] = (brick) { .brickType = 2, .x = 433, .y = 166, .width = 30, .height = 10 };
bricks[56 ] = (brick) { .brickType = 3, .x = 17, .y = 178, .width = 30, .height = 10 };
bricks[57 ] = (brick) { .brickType = 3, .x = 49, .y = 178, .width = 30, .height = 10 };
bricks[58 ] = (brick) { .brickType = 3, .x = 81, .y = 178, .width = 30, .height = 10 };
bricks[59 ] = (brick) { .brickType = 3, .x = 113, .y = 178, .width = 30, .height = 10 };
bricks[60 ] = (brick) { .brickType = 3, .x = 145, .y = 178, .width = 30, .height = 10 };
bricks[61 ] = (brick) { .brickType = 3, .x = 177, .y = 178, .width = 30, .height = 10 };
bricks[62 ] = (brick) { .brickType = 3, .x = 209, .y = 178, .width = 30, .height = 10 };
bricks[63 ] = (brick) { .brickType = 3, .x = 241, .y = 178, .width = 30, .height = 10 };
bricks[64 ] = (brick) { .brickType = 3, .x = 273, .y = 178, .width = 30, .height = 10 };
bricks[65 ] = (brick) { .brickType = 3, .x = 305, .y = 178, .width = 30, .height = 10 };
bricks[66 ] = (brick) { .brickType = 3, .x = 337, .y = 178, .width = 30, .height = 10 };
bricks[67 ] = (brick) { .brickType = 3, .x = 369, .y = 178, .width = 30, .height = 10 };
bricks[68 ] = (brick) { .brickType = 3, .x = 401, .y = 178, .width = 30, .height = 10 };
bricks[69 ] = (brick) { .brickType = 3, .x = 433, .y = 178, .width = 30, .height = 10 };
bricks[70 ] = (brick) { .brickType = 3, .x = 17, .y = 190, .width = 30, .height = 10 };
bricks[71 ] = (brick) { .brickType = 3, .x = 49, .y = 190, .width = 30, .height = 10 };
bricks[72 ] = (brick) { .brickType = 3, .x = 81, .y = 190, .width = 30, .height = 10 };
bricks[73 ] = (brick) { .brickType = 3, .x = 113, .y = 190, .width = 30, .height = 10 };
bricks[74 ] = (brick) { .brickType = 3, .x = 145, .y = 190, .width = 30, .height = 10 };
bricks[75 ] = (brick) { .brickType = 3, .x = 177, .y = 190, .width = 30, .height = 10 };
bricks[76 ] = (brick) { .brickType = 3, .x = 209, .y = 190, .width = 30, .height = 10 };
bricks[77 ] = (brick) { .brickType = 3, .x = 241, .y = 190, .width = 30, .height = 10 };
bricks[78 ] = (brick) { .brickType = 3, .x = 273, .y = 190, .width = 30, .height = 10 };
bricks[79 ] = (brick) { .brickType = 3, .x = 305, .y = 190, .width = 30, .height = 10 };
bricks[80 ] = (brick) { .brickType = 3, .x = 337, .y = 190, .width = 30, .height = 10 };
bricks[81 ] = (brick) { .brickType = 3, .x = 369, .y = 190, .width = 30, .height = 10 };
bricks[82 ] = (brick) { .brickType = 3, .x = 401, .y = 190, .width = 30, .height = 10 };
bricks[83 ] = (brick) { .brickType = 3, .x = 433, .y = 190, .width = 30, .height = 10 };
bricks[84 ] = (brick) { .brickType = 4, .x = 17, .y = 202, .width = 30, .height = 10 };
bricks[85 ] = (brick) { .brickType = 4, .x = 49, .y = 202, .width = 30, .height = 10 };
bricks[86 ] = (brick) { .brickType = 4, .x = 81, .y = 202, .width = 30, .height = 10 };
bricks[87 ] = (brick) { .brickType = 4, .x = 113, .y = 202, .width = 30, .height = 10 };
bricks[88 ] = (brick) { .brickType = 4, .x = 145, .y = 202, .width = 30, .height = 10 };
bricks[89 ] = (brick) { .brickType = 4, .x = 177, .y = 202, .width = 30, .height = 10 };
bricks[90 ] = (brick) { .brickType = 4, .x = 209, .y = 202, .width = 30, .height = 10 };
bricks[91 ] = (brick) { .brickType = 4, .x = 241, .y = 202, .width = 30, .height = 10 };
bricks[92 ] = (brick) { .brickType = 4, .x = 273, .y = 202, .width = 30, .height = 10 };
bricks[93 ] = (brick) { .brickType = 4, .x = 305, .y = 202, .width = 30, .height = 10 };
bricks[94 ] = (brick) { .brickType = 4, .x = 337, .y = 202, .width = 30, .height = 10 };
bricks[95 ] = (brick) { .brickType = 4, .x = 369, .y = 202, .width = 30, .height = 10 };
bricks[96 ] = (brick) { .brickType = 4, .x = 401, .y = 202, .width = 30, .height = 10 };
bricks[97 ] = (brick) { .brickType = 4, .x = 433, .y = 202, .width = 30, .height = 10 };
bricks[98 ] = (brick) { .brickType = 4, .x = 17, .y = 214, .width = 30, .height = 10 };
bricks[99 ] = (brick) { .brickType = 4, .x = 49, .y = 214, .width = 30, .height = 10 };
bricks[100] = (brick) { .brickType = 4, .x = 81, .y = 214, .width = 30, .height = 10 };
bricks[101] = (brick) { .brickType = 4, .x = 113, .y = 214, .width = 30, .height = 10 };
bricks[102] = (brick) { .brickType = 4, .x = 145, .y = 214, .width = 30, .height = 10 };
bricks[103] = (brick) { .brickType = 4, .x = 177, .y = 214, .width = 30, .height = 10 };
bricks[104] = (brick) { .brickType = 4, .x = 209, .y = 214, .width = 30, .height = 10 };
bricks[105] = (brick) { .brickType = 4, .x = 241, .y = 214, .width = 30, .height = 10 };
bricks[106] = (brick) { .brickType = 4, .x = 273, .y = 214, .width = 30, .height = 10 };
bricks[107] = (brick) { .brickType = 4, .x = 305, .y = 214, .width = 30, .height = 10 };
bricks[108] = (brick) { .brickType = 4, .x = 337, .y = 214, .width = 30, .height = 10 };
bricks[109] = (brick) { .brickType = 4, .x = 369, .y = 214, .width = 30, .height = 10 };
bricks[110] = (brick) { .brickType = 4, .x = 401, .y = 214, .width = 30, .height = 10 };
bricks[111] = (brick) { .brickType = 4, .x = 433, .y = 214, .width = 30, .height = 10 };
bricks[0 ] = (brick) { .brickType = 1, .x = 17, .y = 130, .width = 30, .height = 10, .destroyed = 0 };
bricks[1 ] = (brick) { .brickType = 1, .x = 49, .y = 130, .width = 30, .height = 10, .destroyed = 0 };
bricks[2 ] = (brick) { .brickType = 1, .x = 81, .y = 130, .width = 30, .height = 10, .destroyed = 0 };
bricks[3 ] = (brick) { .brickType = 1, .x = 113, .y = 130, .width = 30, .height = 10, .destroyed = 0 };
bricks[4 ] = (brick) { .brickType = 1, .x = 145, .y = 130, .width = 30, .height = 10, .destroyed = 0 };
bricks[5 ] = (brick) { .brickType = 1, .x = 177, .y = 130, .width = 30, .height = 10, .destroyed = 0 };
bricks[6 ] = (brick) { .brickType = 1, .x = 209, .y = 130, .width = 30, .height = 10, .destroyed = 0 };
bricks[7 ] = (brick) { .brickType = 1, .x = 241, .y = 130, .width = 30, .height = 10, .destroyed = 0 };
bricks[8 ] = (brick) { .brickType = 1, .x = 273, .y = 130, .width = 30, .height = 10, .destroyed = 0 };
bricks[9 ] = (brick) { .brickType = 1, .x = 305, .y = 130, .width = 30, .height = 10, .destroyed = 0 };
bricks[10 ] = (brick) { .brickType = 1, .x = 337, .y = 130, .width = 30, .height = 10, .destroyed = 0 };
bricks[11 ] = (brick) { .brickType = 1, .x = 369, .y = 130, .width = 30, .height = 10, .destroyed = 0 };
bricks[12 ] = (brick) { .brickType = 1, .x = 401, .y = 130, .width = 30, .height = 10, .destroyed = 0 };
bricks[13 ] = (brick) { .brickType = 1, .x = 433, .y = 130, .width = 30, .height = 10, .destroyed = 0 };
bricks[14 ] = (brick) { .brickType = 1, .x = 17, .y = 142, .width = 30, .height = 10, .destroyed = 0 };
bricks[15 ] = (brick) { .brickType = 1, .x = 49, .y = 142, .width = 30, .height = 10, .destroyed = 0 };
bricks[16 ] = (brick) { .brickType = 1, .x = 81, .y = 142, .width = 30, .height = 10, .destroyed = 0 };
bricks[17 ] = (brick) { .brickType = 1, .x = 113, .y = 142, .width = 30, .height = 10, .destroyed = 0 };
bricks[18 ] = (brick) { .brickType = 1, .x = 145, .y = 142, .width = 30, .height = 10, .destroyed = 0 };
bricks[19 ] = (brick) { .brickType = 1, .x = 177, .y = 142, .width = 30, .height = 10, .destroyed = 0 };
bricks[20 ] = (brick) { .brickType = 1, .x = 209, .y = 142, .width = 30, .height = 10, .destroyed = 0 };
bricks[21 ] = (brick) { .brickType = 1, .x = 241, .y = 142, .width = 30, .height = 10, .destroyed = 0 };
bricks[22 ] = (brick) { .brickType = 1, .x = 273, .y = 142, .width = 30, .height = 10, .destroyed = 0 };
bricks[23 ] = (brick) { .brickType = 1, .x = 305, .y = 142, .width = 30, .height = 10, .destroyed = 0 };
bricks[24 ] = (brick) { .brickType = 1, .x = 337, .y = 142, .width = 30, .height = 10, .destroyed = 0 };
bricks[25 ] = (brick) { .brickType = 1, .x = 369, .y = 142, .width = 30, .height = 10, .destroyed = 0 };
bricks[26 ] = (brick) { .brickType = 1, .x = 401, .y = 142, .width = 30, .height = 10, .destroyed = 0 };
bricks[27 ] = (brick) { .brickType = 1, .x = 433, .y = 142, .width = 30, .height = 10, .destroyed = 0 };
bricks[28 ] = (brick) { .brickType = 2, .x = 17, .y = 154, .width = 30, .height = 10, .destroyed = 0 };
bricks[29 ] = (brick) { .brickType = 2, .x = 49, .y = 154, .width = 30, .height = 10, .destroyed = 0 };
bricks[30 ] = (brick) { .brickType = 2, .x = 81, .y = 154, .width = 30, .height = 10, .destroyed = 0 };
bricks[31 ] = (brick) { .brickType = 2, .x = 113, .y = 154, .width = 30, .height = 10, .destroyed = 0 };
bricks[32 ] = (brick) { .brickType = 2, .x = 145, .y = 154, .width = 30, .height = 10, .destroyed = 0 };
bricks[33 ] = (brick) { .brickType = 2, .x = 177, .y = 154, .width = 30, .height = 10, .destroyed = 0 };
bricks[34 ] = (brick) { .brickType = 2, .x = 209, .y = 154, .width = 30, .height = 10, .destroyed = 0 };
bricks[35 ] = (brick) { .brickType = 2, .x = 241, .y = 154, .width = 30, .height = 10, .destroyed = 0 };
bricks[36 ] = (brick) { .brickType = 2, .x = 273, .y = 154, .width = 30, .height = 10, .destroyed = 0 };
bricks[37 ] = (brick) { .brickType = 2, .x = 305, .y = 154, .width = 30, .height = 10, .destroyed = 0 };
bricks[38 ] = (brick) { .brickType = 2, .x = 337, .y = 154, .width = 30, .height = 10, .destroyed = 0 };
bricks[39 ] = (brick) { .brickType = 2, .x = 369, .y = 154, .width = 30, .height = 10, .destroyed = 0 };
bricks[40 ] = (brick) { .brickType = 2, .x = 401, .y = 154, .width = 30, .height = 10, .destroyed = 0 };
bricks[41 ] = (brick) { .brickType = 2, .x = 433, .y = 154, .width = 30, .height = 10, .destroyed = 0 };
bricks[42 ] = (brick) { .brickType = 2, .x = 17, .y = 166, .width = 30, .height = 10, .destroyed = 0 };
bricks[43 ] = (brick) { .brickType = 2, .x = 49, .y = 166, .width = 30, .height = 10, .destroyed = 0 };
bricks[44 ] = (brick) { .brickType = 2, .x = 81, .y = 166, .width = 30, .height = 10, .destroyed = 0 };
bricks[45 ] = (brick) { .brickType = 2, .x = 113, .y = 166, .width = 30, .height = 10, .destroyed = 0 };
bricks[46 ] = (brick) { .brickType = 2, .x = 145, .y = 166, .width = 30, .height = 10, .destroyed = 0 };
bricks[47 ] = (brick) { .brickType = 2, .x = 177, .y = 166, .width = 30, .height = 10, .destroyed = 0 };
bricks[48 ] = (brick) { .brickType = 2, .x = 209, .y = 166, .width = 30, .height = 10, .destroyed = 0 };
bricks[49 ] = (brick) { .brickType = 2, .x = 241, .y = 166, .width = 30, .height = 10, .destroyed = 0 };
bricks[50 ] = (brick) { .brickType = 2, .x = 273, .y = 166, .width = 30, .height = 10, .destroyed = 0 };
bricks[51 ] = (brick) { .brickType = 2, .x = 305, .y = 166, .width = 30, .height = 10, .destroyed = 0 };
bricks[52 ] = (brick) { .brickType = 2, .x = 337, .y = 166, .width = 30, .height = 10, .destroyed = 0 };
bricks[53 ] = (brick) { .brickType = 2, .x = 369, .y = 166, .width = 30, .height = 10, .destroyed = 0 };
bricks[54 ] = (brick) { .brickType = 2, .x = 401, .y = 166, .width = 30, .height = 10, .destroyed = 0 };
bricks[55 ] = (brick) { .brickType = 2, .x = 433, .y = 166, .width = 30, .height = 10, .destroyed = 0 };
bricks[56 ] = (brick) { .brickType = 3, .x = 17, .y = 178, .width = 30, .height = 10, .destroyed = 0 };
bricks[57 ] = (brick) { .brickType = 3, .x = 49, .y = 178, .width = 30, .height = 10, .destroyed = 0 };
bricks[58 ] = (brick) { .brickType = 3, .x = 81, .y = 178, .width = 30, .height = 10, .destroyed = 0 };
bricks[59 ] = (brick) { .brickType = 3, .x = 113, .y = 178, .width = 30, .height = 10, .destroyed = 0 };
bricks[60 ] = (brick) { .brickType = 3, .x = 145, .y = 178, .width = 30, .height = 10, .destroyed = 0 };
bricks[61 ] = (brick) { .brickType = 3, .x = 177, .y = 178, .width = 30, .height = 10, .destroyed = 0 };
bricks[62 ] = (brick) { .brickType = 3, .x = 209, .y = 178, .width = 30, .height = 10, .destroyed = 0 };
bricks[63 ] = (brick) { .brickType = 3, .x = 241, .y = 178, .width = 30, .height = 10, .destroyed = 0 };
bricks[64 ] = (brick) { .brickType = 3, .x = 273, .y = 178, .width = 30, .height = 10, .destroyed = 0 };
bricks[65 ] = (brick) { .brickType = 3, .x = 305, .y = 178, .width = 30, .height = 10, .destroyed = 0 };
bricks[66 ] = (brick) { .brickType = 3, .x = 337, .y = 178, .width = 30, .height = 10, .destroyed = 0 };
bricks[67 ] = (brick) { .brickType = 3, .x = 369, .y = 178, .width = 30, .height = 10, .destroyed = 0 };
bricks[68 ] = (brick) { .brickType = 3, .x = 401, .y = 178, .width = 30, .height = 10, .destroyed = 0 };
bricks[69 ] = (brick) { .brickType = 3, .x = 433, .y = 178, .width = 30, .height = 10, .destroyed = 0 };
bricks[70 ] = (brick) { .brickType = 3, .x = 17, .y = 190, .width = 30, .height = 10, .destroyed = 0 };
bricks[71 ] = (brick) { .brickType = 3, .x = 49, .y = 190, .width = 30, .height = 10, .destroyed = 0 };
bricks[72 ] = (brick) { .brickType = 3, .x = 81, .y = 190, .width = 30, .height = 10, .destroyed = 0 };
bricks[73 ] = (brick) { .brickType = 3, .x = 113, .y = 190, .width = 30, .height = 10, .destroyed = 0 };
bricks[74 ] = (brick) { .brickType = 3, .x = 145, .y = 190, .width = 30, .height = 10, .destroyed = 0 };
bricks[75 ] = (brick) { .brickType = 3, .x = 177, .y = 190, .width = 30, .height = 10, .destroyed = 0 };
bricks[76 ] = (brick) { .brickType = 3, .x = 209, .y = 190, .width = 30, .height = 10, .destroyed = 0 };
bricks[77 ] = (brick) { .brickType = 3, .x = 241, .y = 190, .width = 30, .height = 10, .destroyed = 0 };
bricks[78 ] = (brick) { .brickType = 3, .x = 273, .y = 190, .width = 30, .height = 10, .destroyed = 0 };
bricks[79 ] = (brick) { .brickType = 3, .x = 305, .y = 190, .width = 30, .height = 10, .destroyed = 0 };
bricks[80 ] = (brick) { .brickType = 3, .x = 337, .y = 190, .width = 30, .height = 10, .destroyed = 0 };
bricks[81 ] = (brick) { .brickType = 3, .x = 369, .y = 190, .width = 30, .height = 10, .destroyed = 0 };
bricks[82 ] = (brick) { .brickType = 3, .x = 401, .y = 190, .width = 30, .height = 10, .destroyed = 0 };
bricks[83 ] = (brick) { .brickType = 3, .x = 433, .y = 190, .width = 30, .height = 10, .destroyed = 0 };
bricks[84 ] = (brick) { .brickType = 4, .x = 17, .y = 202, .width = 30, .height = 10, .destroyed = 0 };
bricks[85 ] = (brick) { .brickType = 4, .x = 49, .y = 202, .width = 30, .height = 10, .destroyed = 0 };
bricks[86 ] = (brick) { .brickType = 4, .x = 81, .y = 202, .width = 30, .height = 10, .destroyed = 0 };
bricks[87 ] = (brick) { .brickType = 4, .x = 113, .y = 202, .width = 30, .height = 10, .destroyed = 0 };
bricks[88 ] = (brick) { .brickType = 4, .x = 145, .y = 202, .width = 30, .height = 10, .destroyed = 0 };
bricks[89 ] = (brick) { .brickType = 4, .x = 177, .y = 202, .width = 30, .height = 10, .destroyed = 0 };
bricks[90 ] = (brick) { .brickType = 4, .x = 209, .y = 202, .width = 30, .height = 10, .destroyed = 0 };
bricks[91 ] = (brick) { .brickType = 4, .x = 241, .y = 202, .width = 30, .height = 10, .destroyed = 0 };
bricks[92 ] = (brick) { .brickType = 4, .x = 273, .y = 202, .width = 30, .height = 10, .destroyed = 0 };
bricks[93 ] = (brick) { .brickType = 4, .x = 305, .y = 202, .width = 30, .height = 10, .destroyed = 0 };
bricks[94 ] = (brick) { .brickType = 4, .x = 337, .y = 202, .width = 30, .height = 10, .destroyed = 0 };
bricks[95 ] = (brick) { .brickType = 4, .x = 369, .y = 202, .width = 30, .height = 10, .destroyed = 0 };
bricks[96 ] = (brick) { .brickType = 4, .x = 401, .y = 202, .width = 30, .height = 10, .destroyed = 0 };
bricks[97 ] = (brick) { .brickType = 4, .x = 433, .y = 202, .width = 30, .height = 10, .destroyed = 0 };
bricks[98 ] = (brick) { .brickType = 4, .x = 17, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[99 ] = (brick) { .brickType = 4, .x = 49, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[100] = (brick) { .brickType = 4, .x = 81, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[101] = (brick) { .brickType = 4, .x = 113, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[102] = (brick) { .brickType = 4, .x = 145, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[103] = (brick) { .brickType = 4, .x = 177, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[104] = (brick) { .brickType = 4, .x = 209, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[105] = (brick) { .brickType = 4, .x = 241, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[106] = (brick) { .brickType = 4, .x = 273, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[107] = (brick) { .brickType = 4, .x = 305, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[108] = (brick) { .brickType = 4, .x = 337, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[109] = (brick) { .brickType = 4, .x = 369, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[110] = (brick) { .brickType = 4, .x = 401, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[111] = (brick) { .brickType = 4, .x = 433, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
*brickCount = 112;
}