2022-06-04 14:15:13 +00:00
|
|
|
|
#include "block.h"
|
2022-06-05 15:35:53 +00:00
|
|
|
|
#include "draw.h"
|
2022-06-04 14:15:13 +00:00
|
|
|
|
|
2022-06-05 15:35:53 +00:00
|
|
|
|
Group piece;
|
|
|
|
|
unsigned char regenPieceFlag = 0;
|
|
|
|
|
unsigned char base[8][11]={0}; //x*y
|
2022-06-04 14:15:13 +00:00
|
|
|
|
|
|
|
|
|
void blockInit()
|
|
|
|
|
{
|
2022-06-05 15:35:53 +00:00
|
|
|
|
|
|
|
|
|
base[0][0]=1;
|
|
|
|
|
base[0][1]=1;
|
|
|
|
|
base[0][2]=1;
|
|
|
|
|
// genPiece();
|
2022-06-04 14:15:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-05 15:35:53 +00:00
|
|
|
|
void blockDestroy()
|
2022-06-04 14:15:13 +00:00
|
|
|
|
{
|
2022-06-05 15:35:53 +00:00
|
|
|
|
piece.type=none;
|
2022-06-04 14:15:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-05 15:35:53 +00:00
|
|
|
|
void genPiece()
|
2022-06-04 14:15:13 +00:00
|
|
|
|
{
|
|
|
|
|
//<2F><>Ҫһ<D2AA><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2022-06-05 15:35:53 +00:00
|
|
|
|
int random = rand() % 4;
|
|
|
|
|
int len = 2 + rand() % 3;
|
|
|
|
|
|
2022-06-04 14:15:13 +00:00
|
|
|
|
|
2022-06-05 15:35:53 +00:00
|
|
|
|
piece.mother.x=4;
|
|
|
|
|
piece.mother.y=8;
|
2022-06-04 14:15:13 +00:00
|
|
|
|
|
2022-06-05 15:35:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if(len == 2)
|
|
|
|
|
{
|
|
|
|
|
if(random % 2 == 0)
|
|
|
|
|
{
|
|
|
|
|
piece.type = two_v; //
|
|
|
|
|
} //
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
piece.type = two_h; ////
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if(len == 3)
|
|
|
|
|
{
|
|
|
|
|
if(random == 0)
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
piece.type = three_h; //
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
else if(random == 1)
|
|
|
|
|
{
|
|
|
|
|
piece.type = three_v; //////
|
|
|
|
|
}
|
|
|
|
|
else if(random == 2)
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
piece.type = three_l; ////
|
|
|
|
|
}
|
|
|
|
|
else if (random == 3)
|
|
|
|
|
{
|
|
|
|
|
piece.type = three_r; //
|
|
|
|
|
} ////
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if(len == 3)
|
|
|
|
|
{
|
|
|
|
|
piece.type = four; ////
|
|
|
|
|
} ////
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void dropPiece()
|
|
|
|
|
{
|
|
|
|
|
piece.mother.y--;
|
|
|
|
|
// int i;
|
|
|
|
|
// for(i = 0; i < len; i++)
|
|
|
|
|
// {
|
|
|
|
|
// //<2F><><EFBFBD><EFBFBD><D7BB><EFBFBD><EFBFBD><EFBFBD>base<73><65><EFBFBD><EFBFBD>
|
|
|
|
|
// if(piece.list[i].x == 0 || base[piece.list[i].x][piece.list[i].y - 1] == 1)
|
|
|
|
|
// {
|
|
|
|
|
// for(i = 0; i < len;i++)
|
|
|
|
|
// {
|
|
|
|
|
// //ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>Ƶ<EFBFBD>base
|
|
|
|
|
// base[piece.list[i].x][piece.list[i].y] == 1;
|
|
|
|
|
// }
|
|
|
|
|
// //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// genPiece();
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// piece.list[i].y--;
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void drawBlock()
|
|
|
|
|
{
|
|
|
|
|
int i,j;
|
|
|
|
|
for(i=0;i<8;i++)
|
|
|
|
|
for(j=0;j<8;j++)
|
|
|
|
|
if(base[i][j]==1)
|
|
|
|
|
placeIMG_BLOCK(i,j);
|
|
|
|
|
placeIMG_BLOCK(piece.mother.x,piece.mother.y);
|
2022-06-04 14:15:13 +00:00
|
|
|
|
}
|