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 54 55 56 57 58 59 60 61 62 63 64 65 66
|
class CShape{
//class CShape checks the movement and rotation of the blocks
protected:
int x, y, bstate, fill, shape, i, j, p, q, r, s, t, count;
char solid, blank;
bool newBlock;
static const int GREEN = 10, TEAL = 11, RED = 12, PINK = 13, YELLOW = 14;
static const int occupied = 1, unoccupied = 0;
CGraphics graph;
virtual bool checkMovement();
public:
CShape(int xl = 39, int yl = 4): x(xl), y(yl){}
virtual ~CShape();
virtual int deleteBlocks(int addScore);
virtual int addUpScore(int sc);
void set_values (int xaxis, int yaxis, int st, int bl, int sh, bool nextbl)
{x = xaxis; y = yaxis; bstate = st; fill = bl; shape = sh; newBlock = nextbl;}
int xyLoc[50][25];
};
bool CShape::checkMovement()
{
//I want to change the value of x and y using the value of x and y from
//the subclass...
if((xyLoc[x][y] == 1) && (fill == solid))
return false;
graph.posShape(x,y,GREEN,fill);
if(newBlock == true){
color.xyColor[x][y] = GREEN;
}//end if
if(fill == solid)
xyLoc[x][y] = occupied;
else
xyLoc[x][y] = unoccupied;
return true;
}
class CShapeL : public CShape
{
public:
virtual bool rotateMoveBlocks();
};
bool CShapeL::rotateMoveBlocks()
{
for(i = 34; i<46; i++){
for(j=3; j<23; j++){
if(i < 35 || i > 44){
xyLoc[i][j] = 1;
}
else if(((i>34 && i<45))&&(j<4 || j>21))
xyLoc[i][j] = 1;
}//end for
}//end for
solid = (char)001; blank = (char)000;
int lBlock[4][4][3] = //assigns the xy positions of four blocks, 10 is green
{{{x-1,y,10},{x,y,10},{x+1,y,10},{x+1,y+1,10}},//stateL = 0 default position ™™|
{{x,y-1,10},{x,y,10},{x,y+1,10},{x-1,y+1,10}},//stateL = 1
{{x+1,y,10},{x,y,10},{x-1,y,10},{x-1,y-1,10}},//stateL = 2
{{x,y+1,10},{x,y,10},{x,y-1,10},{x+1,y-1,10}}};//stateL = 3
for(i = 0; i < 4; i++)
//I want the checkMovement function inherit the x, y location
//of this subclass...
CShape::checkMovement():lBlock[bstate][i][0],lBlock[bstate][i][1];
}
return true;
}
| |