1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
class Brick
{
int width, height;
int x, y;
int type;
SDL_Rect box;
bool visible;
public:
Brick(int xPos, int yPos, int brickType)
{ width = brickWidth; height = brickHeight;
x = xPos; y = yPos;
type = brickType; visible = true;
box.x = x; box.y = y;
box.w = width; box.h = height; }
int getX(){return box.x;}
int getY(){return box.y;}
int getWidth(){return box.w;}
int getHeight(){return box.h;}
void show() {
if(visible) {
switch(type) {
case 1:
applySurface(x,y,brick1,screen); break;
case 2:
applySurface(x,y,brick2,screen); break;
case 3:
applySurface(x,y,brick3,screen); break;
case 4:
applySurface(x,y,brick4,screen); break;
}
}
}
void destroyBrick() {
visible = false;
//This should move the SDL_Rect for collision outside of the normal
// bricks region. Which should let the ball pass through the bricks
// after one disappears. Though.. this is messy.
box.x = 0; box.y = 0;
box.w = 0; box.h = 0;
//Adjusts the score following a collision.
switch(type) {
case 1: myScore.addScore(500); break;
case 2: myScore.addScore(300); break;
case 3: myScore.addScore(200); break;
case 4: myScore.addScore(100); break;
}
//Refreshes the score string where we display Score: 500, etc.
myScore.updateScore();
}
SDL_Rect *getBox(){return &box;}
};
vector<Brick> brickLayout;
vector<Brick>::iterator it;
|