feat(MCU课设): 更改分数显示方式

This commit is contained in:
iridiumR 2022-06-06 20:52:06 +08:00
parent 8c76f3a6d3
commit 5873aa5ba2
2 changed files with 25 additions and 18 deletions

View file

@ -5,12 +5,13 @@
#include "delay.h"
char base[MAX_X][MAX_Y] = {0}; //x*y //0为空 1为下落完成 2为正在下落
extern unsigned char score;
extern unsigned int score;
extern enum OPR opr;
enum GS blockGameStatus = __idle;
void blockInit()
{
score=0;
blockGameStatus = start;
}
@ -155,7 +156,10 @@ void dropPiece()
}
//有标记则转换
else if(flag == 1)
{
score++;
base[i][j] = 1;
}
}
}
}
@ -225,7 +229,7 @@ void judgeBlock()
//计数足则整体下移
if(count == 8)
{
score++;
score=score+10;
blockGameStatus = good;
for(k = 0; k < MAX_X; k++)
for(h = j ; h < MAX_Y - 1; h++)

View file

@ -15,16 +15,15 @@
Menu M_MAINMENU;//主菜单
Menu M_BLOCK; //俄罗斯方块
Menu M_BALL; //弹球
Menu M_ABOUT;
Menu M_BEST; //弹球
Menu M_ABOUT; //关于
Menu* NOW; //当前菜单指针
Menu* LAST = NULL; //上一个状态的菜单
enum OPR opr = idle;
static unsigned char local[10] = {0};
unsigned char score = 0;
unsigned int score = 0;
extern enum GS blockGameStatus;
@ -65,7 +64,7 @@ void m_mainmenu(struct _menu* this)
NOW = &M_BLOCK; //转向下一菜单
break;
case 2:
NOW = &M_BALL; //转向下一菜单
NOW = &M_BEST; //转向下一菜单
break;
case 3:
NOW = &M_ABOUT; //转向下一菜单
@ -115,23 +114,27 @@ void m_block(struct _menu* this)
switch(blockGameStatus)
{
case good:
drawGOOD(70, 2);
drawGOOD(70, 4);
blockGameStatus=start;
break;
case over:
drawGAME(70, 2);
drawOVER(70, 4);
drawGAME(70, 4);
drawOVER(70, 6);
break;
default:
drawVOID8(70, 2, 40);
drawVOID8(70, 4, 32);
drawVOID8(70, 4, 40);
drawVOID8(70, 6, 32);
}
drawSUPNUM(110, 0, score); //绘制分数
blockGameOver(); //检查是否游戏结束
genPiece(); //若有需要,生成新块
dropPiece(); //若有需要,块下落
judgeBlock(); //若有需要,清除一行
drawBlock(); //绘制界面
drawSUPNUM(70, 2, score/10000); //绘制分数
drawSUPNUM(78, 2, score/1000);
drawSUPNUM(86, 2, score/100);
drawSUPNUM(94, 2, score/10);
drawSUPNUM(102, 2, score%10);
blockGameOver(); //检查是否游戏结束
genPiece(); //若有需要,生成新块
dropPiece(); //若有需要,块下落
judgeBlock(); //若有需要,清除一行
drawBlock(); //绘制界面
delayms(400);
}