Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualBeerNutts

Posted 10 January 2013 - 04:31 PM

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;
};
 
Do you understand why that does, and understand why they are group'd together?  
 
Then, look at the array of bricks, and the loop that initializes the brick array:

#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
  }
}
 
Do you know what that is doing?  And slowly go form there.  Just break up " a lot of code" into small pieces of code.  read the comments in the code.  It explains every thing.
 
If you have questions about certain parts of it, ask about it.  it's better than staring at something not understanding what it's doing.
 
I graduated from California state san bernardino

 

Really?  BS in CS?  Do you have a job as a programmer now?
 

#2BeerNutts

Posted 10 January 2013 - 04:30 PM

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;
};
 
Do you understand why that does, and understand why they are group'd together?  
 
Then, look at the array of bricks, and the loop that initializes the brick array:

#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
  }
}
 
Do you know what that is doing?  And slowly go form there.  Just break up " a lot of code" into small pieces of code.  read the comments in the code.  It explains every thing.
 
If you have questions about certain parts of it, ask about it.  it's better than staring at something not understanding what it's doing.
 
 
I graduated from California state san bernardino

 

Really?  BS in CS?  Do you have a job as a programmer now?
 

#1BeerNutts

Posted 10 January 2013 - 04:29 PM

Start with the structures:

 
</p><div>struct TBrick {</div>
<div>  int XPosition;</div>
<div>  int YPosition;</div>
<div>  int XSize;</div>
<div>  int YSize;</div>
<div>  uint32_t Color;</div>
<div>  uint32_t ActiveState;  // 0 is deactive; If it takes multiple hits to kill a brick, it can start greater than 1</div>
<div>};</div>
<div> </div>
<div>struct TBall {</div>
<div>  int XPosition;</div>
<div>  int YPosition;</div>
<div>  int XSize;</div>
<div>  int YSize;</div>
<div>  int XSpeed;</div>
<div>  int YSpeed;</div>
<div>};</div>
<div>
 
Do you understand why that does, and understand why they are group'd together?  
 
Then, look at the array of bricks, and the loop that initializes the brick array:
</div>
<div>
<div>#define BRICK_COLUMNS 20 // how many bricks in a column</div>
<div>#define BRICK_ROWS 10 // how many bricks ina  row</div>
<div>#define BRICK_START_X 60 // Where the bricks start on the x-axis</div>
<div>#define BRICK_START_Y 40 // Where the bricks start on the y-axis</div>
<div>#define BRICK_WIDTH 30 // brick width in pixels</div>
<div>#define BRICK_HEIGHT 15 // brickheight in pixels</div>
</div>
<div> </div>
<div>
<div>// make this a global array</div>
<div>TBrick BrickArray[BRICK_COLUMNS][BRICK_ROWS];</div>
<div> </div>
<div>// Initialize the Brick Array somewhere at the start of your code</div>
<div>for (int x = 0; x < BRICK_COLUMNS; x++) {</div>
<div>  for (int y = 0; y < BRICK_ROWS; y++) {</div>
<div>    BrickArray[x][y].XSize = BRICK_WIDTH;</div>
<div>    BrickArray[x][y].YSize = BRICK_HEIGHT;</div>
<div>    BrickArray[x][y].XLocation = BRICK_START_X + x*BRICK_WIDTH;</div>
<div>    BrickArray[x][y].YLocation = BRICK_START_Y + y*BRICK_HEIGHT;</div>
<div>    BrickArray[x][y].Color = 0xFFFFFFFF; // white</div>
<div>    BrickArray[x][y].ActiveState = 1; // 1 hit to turn off brick</div>
<div>  }</div>
<div>}</div>
<div>
 
Do you know what that is doing?  And slowly go form there.  Just break up " a lot of code" into small pieces of code.  read the comments in the code.  It explains every thing.
 

I graduated from California state san bernardino

Really?  BS in CS?  Do you have a job as a programmer now?
 

PARTNERS