I graduated from college with a b.s. in c.s. in 2005.
Which college?
Phil, what did you not understand about this code I posted?
It gives a general idea of how to encapsulate brick's and the ball into it's own structure, and shows how to handle collisions and rendering.
Start with the structures:
struct TBrick {
int XPosition;
int YPosition;
int XSize;
int YSize;
uint32_t Color;
uint32_t ActiveState; // 0 is deactive; If it takes multiple hits to kill a brick, it can start greater than 1
};
struct TBall {
int XPosition;
int YPosition;
int XSize;
int YSize;
int XSpeed;
int YSpeed;
};
#define BRICK_COLUMNS 20 // how many bricks in a column
#define BRICK_ROWS 10 // how many bricks ina row
#define BRICK_START_X 60 // Where the bricks start on the x-axis
#define BRICK_START_Y 40 // Where the bricks start on the y-axis
#define BRICK_WIDTH 30 // brick width in pixels
#define BRICK_HEIGHT 15 // brickheight in pixels
// make this a global array
TBrick BrickArray[BRICK_COLUMNS][BRICK_ROWS];
// Initialize the Brick Array somewhere at the start of your code
for (int x = 0; x < BRICK_COLUMNS; x++) {
for (int y = 0; y < BRICK_ROWS; y++) {
BrickArray[x][y].XSize = BRICK_WIDTH;
BrickArray[x][y].YSize = BRICK_HEIGHT;
BrickArray[x][y].XLocation = BRICK_START_X + x*BRICK_WIDTH;
BrickArray[x][y].YLocation = BRICK_START_Y + y*BRICK_HEIGHT;
BrickArray[x][y].Color = 0xFFFFFFFF; // white
BrickArray[x][y].ActiveState = 1; // 1 hit to turn off brick
}
}
I graduated from California state san bernardino
yeah!! thanks for all the help, I finally solved the collision problem with the ball and bricks.
Show us your solution. I've heard you say that before, but you come back and ask the question again.
if( g_bBlock[4].m_bActive_three==true)
{
if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f)
{
ystep = -ystep;
bricks[2][4]=true;
g_bBlock[4].m_bActive_three=false;
}
}
well here it is
if( g_bBlock[4].m_bActive_three==true) { if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f) { ystep = -ystep; bricks[2][4]=true; g_bBlock[4].m_bActive_three=false; } }
Sigh.
...
Just...Sigh.
I give up. Good luck to you.