feat(MCU课设):方块增加计分

This commit is contained in:
iridiumR 2022-06-06 17:01:36 +08:00
parent 2a879fa682
commit 8c19878cc9
5 changed files with 1073 additions and 957 deletions

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@
#include <reg52.h>
char base[MAX_X][MAX_Y] = {0}; //x*y //0为空 1为下落完成 2为正在下落
enum BLK_TP type = none;
extern unsigned char score;
extern enum OPR opr;
void blockInit()
@ -162,10 +162,11 @@ void moveLeftPiece()
char i, j;
for(i = 0; i < MAX_X; i++)
for(j = 0; j < MAX_Y; j++)
if(base[i][j] == 2 && isIegal(i - 1, j))
if(base[i][j] == 2 && !isIegal(i - 1, j))
{
base[i - 1][j] = 2;
base[i][j] = 0;
return;
}
}
void moveRightPiece()
@ -199,9 +200,12 @@ void judgeBlock()
}
//计数足则整体下移
if(count == 8)
{
score++;
for(k = 0; k < MAX_X; k++)
for(h = j ; h < MAX_Y-1; h++)
base[k][h] = base[k][h + 1];
}
}
}

View file

@ -293,7 +293,8 @@ void drawVerticalDottedLine(char x)
return;
else if(x < 64)
{
CSA = 1;
CSB = 0;
}
else
{
@ -310,7 +311,7 @@ void drawVerticalDottedLine(char x)
P1 = 0xb8 + j;
write();
P1 = 0X40 + x;
write(); //<EFBFBD>³2ΑΠjΖΑA
write(); //Ò³jÁÐx
RS = 1;
RW = 0;
@ -353,3 +354,47 @@ void drawBLOCKSCORE()
write();
}
}
void drawSUPNUM(unsigned char x, unsigned char y, unsigned char num)
{
unsigned int j;
if(x < 0 || x > 127)
return;
else if(x < 64)
{
CSA = 1;
CSB = 0;
}
else
{
x = x - 63;
CSA = 0;
CSB = 1;
}
for(j = 0; j < 8; j++)
{
RS = 0;
RW = 0;
P1 = 0xb8 + y;
write();
P1 = 0X40 + x + j;
write(); //Ò³yÁÐx+j
RS = 1;
RW = 0;
P1 = SUPER_NUM0[8*num+j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + y + 1;
write();
P1 = 0X40 + x + j;
write(); //Ò³y+1ÁÐx+j
RS = 1;
RW = 0;
P1 = SUPER_NUM1[8*num+j];
write();
}
}

View file

@ -4,7 +4,7 @@
void drawNAME();
void drawNUMBER();
void drawMAINMENU(unsigned char);
void drawSUPNUM(unsigned char x,unsigned char y,unsigned char num);
////=================== 方块 ==================

View file

@ -24,7 +24,7 @@ Menu* LAST = NULL; //
enum OPR opr = idle;
static unsigned char local[10] = {0};
extern unsigned char score=0;
//初始化显示
void m_startup(struct _menu* this)
@ -122,6 +122,7 @@ void m_block(struct _menu* this)
{
opr = idle;
moveLeftPiece();
dropPiece();
drawBlock();
return;
}
@ -129,10 +130,11 @@ void m_block(struct _menu* this)
{
opr = idle;
moveRightPiece();
dropPiece();
drawBlock();
return;
}
drawSUPNUM(110, 0, score);
genPiece(); //若有需要,生成新块
dropPiece(); //若有需要,块下落
judgeBlock(); //若有需要,清除一行