feat(MCU课设): 增加消除整行逻辑和部分UI
This commit is contained in:
parent
49cb727472
commit
785539a2c9
7 changed files with 863 additions and 687 deletions
File diff suppressed because it is too large
Load diff
|
@ -179,4 +179,29 @@ void moveRightPiece()
|
|||
base[i + 1][j] = 2;
|
||||
base[i][j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//判断是否需要清除一行
|
||||
void judgeBlock()
|
||||
{
|
||||
char i, j, k, h, count;
|
||||
//逐行扫描
|
||||
for(j = 0; j < MAX_Y; j++)
|
||||
{
|
||||
count = 0;
|
||||
for(i = 0; i < MAX_X; i++)
|
||||
{
|
||||
//有则计数
|
||||
if(base[i][j] == 1)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
//计数足则整体下移
|
||||
if(count == 8)
|
||||
for(k = 0; k < MAX_X; k++)
|
||||
for(h = j ; h < MAX_Y-1; h++)
|
||||
base[k][h] = base[k][h + 1];
|
||||
|
||||
}
|
||||
}
|
|
@ -33,4 +33,5 @@ void dropPiece();
|
|||
void drawBlock();
|
||||
void moveLeftPiece();
|
||||
void moveRightPiece();
|
||||
void judgeBlock();
|
||||
#endif
|
|
@ -318,4 +318,38 @@ void drawVerticalDottedLine(char x)
|
|||
write();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void drawBLOCKSCORE()
|
||||
{
|
||||
unsigned int j;
|
||||
|
||||
for(j = 0; j < 32; j++)
|
||||
{
|
||||
CSA = 0;
|
||||
CSB = 1;
|
||||
RS = 0;
|
||||
RW = 0;
|
||||
P1 = 0xb8 + 0;
|
||||
write();
|
||||
P1 = 0X40 +5+ j;
|
||||
write(); //Ò³0ÁÐ5+jÆÁB
|
||||
|
||||
RS = 1;
|
||||
RW = 0;
|
||||
P1 = FONT_SCORE0[j];
|
||||
write();
|
||||
|
||||
RS = 0;
|
||||
RW = 0;
|
||||
P1 = 0xb8 + 1;
|
||||
write();
|
||||
P1 = 0X40 + 5+ j;
|
||||
write(); //Ò³1ÁÐ5+jÆÁB
|
||||
|
||||
RS = 1;
|
||||
RW = 0;
|
||||
P1 = FONT_SCORE1[j];
|
||||
write();
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ void drawMAINMENU(unsigned char);
|
|||
|
||||
void placeIMG_BLOCK(unsigned char x,unsigned char y);
|
||||
void placeVOID_BLOCK(unsigned char x,unsigned char y);
|
||||
|
||||
void drawBLOCKSCORE();
|
||||
////=================== ¼¸ºÎ ==================
|
||||
void drawVerticalDottedLine(char x);
|
||||
#endif
|
|
@ -95,4 +95,36 @@ code unsigned char IMG_BLOCK[]={
|
|||
};
|
||||
|
||||
|
||||
code unsigned char FONT_SCORE0[]={
|
||||
0x00,0x10,0x88,0xC4,0x33,0x00,0xBE,0xAA,0xAA,0xAA,0xAA,0xAA,0xBE,0x80,0x00,0x00,
|
||||
0x80,0x40,0x20,0x90,0x88,0x86,0x80,0x80,0x80,0x83,0x8C,0x10,0x20,0x40,0x80,0x00,
|
||||
};
|
||||
code unsigned char FONT_SCORE1[]={
|
||||
0x02,0x01,0x00,0xFF,0x00,0x02,0x0A,0x12,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x00,
|
||||
0x00,0x80,0x40,0x20,0x18,0x07,0x00,0x40,0x80,0x40,0x3F,0x00,0x00,0x00,0x00,0x00,
|
||||
};
|
||||
code unsigned char SUPER_NUM0[]={
|
||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,
|
||||
0x00,0x70,0x08,0x08,0x08,0x08,0xF0,0x00,
|
||||
0x00,0x30,0x08,0x08,0x08,0x88,0x70,0x00,
|
||||
0x00,0x00,0x80,0x40,0x30,0xF8,0x00,0x00,
|
||||
0x00,0xF8,0x88,0x88,0x88,0x08,0x08,0x00,
|
||||
0x00,0xE0,0x10,0x88,0x88,0x90,0x00,0x00,
|
||||
0x00,0x18,0x08,0x08,0x88,0x68,0x18,0x00,
|
||||
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,
|
||||
0x00,0xF0,0x08,0x08,0x08,0x10,0xE0,0x00,
|
||||
};
|
||||
code unsigned char SUPER_NUM1[]={
|
||||
0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
|
||||
0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,
|
||||
0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,
|
||||
0x00,0x18,0x20,0x21,0x21,0x22,0x1C,0x00,
|
||||
0x00,0x06,0x05,0x24,0x24,0x3F,0x24,0x24,
|
||||
0x00,0x19,0x20,0x20,0x20,0x11,0x0E,0x00,
|
||||
0x00,0x0F,0x11,0x20,0x20,0x20,0x1F,0x00,
|
||||
0x00,0x00,0x00,0x3E,0x01,0x00,0x00,0x00,
|
||||
0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,
|
||||
0x00,0x01,0x12,0x22,0x22,0x11,0x0F,0x00,
|
||||
};
|
||||
#endif
|
|
@ -107,6 +107,7 @@ void m_block(struct _menu* this)
|
|||
{
|
||||
LAST = &M_BLOCK;
|
||||
drawVerticalDottedLine(64);
|
||||
drawBLOCKSCORE();
|
||||
blockInit();
|
||||
}
|
||||
//ÖØÖÃ
|
||||
|
@ -132,9 +133,10 @@ void m_block(struct _menu* this)
|
|||
return;
|
||||
}
|
||||
|
||||
genPiece();
|
||||
dropPiece();
|
||||
drawBlock();
|
||||
genPiece(); //若有需要,生成新块
|
||||
dropPiece(); //若有需要,块下落
|
||||
judgeBlock(); //若有需要,清除一行
|
||||
drawBlock(); //绘制界面
|
||||
delay(200);
|
||||
|
||||
|
||||
|
|
Reference in a new issue