feat(MCU课设): 增加方块种类,优化存储逻辑

This commit is contained in:
iridiumR 2022-06-08 00:00:27 +08:00
parent b774eb6b4f
commit 765045e00a
1 changed files with 43 additions and 28 deletions

View File

@ -53,7 +53,7 @@ void genPiece()
char i, j;
//需要一点随机性
int random = TH0 % 10;
int random = TH0 % 16;
if(blockGameStatus == over)
@ -106,13 +106,53 @@ void genPiece()
}
else if (random == 8)
{
base[4][9] = 2;
base[4][10] = 2;
base[3][9] = 2;
base[4][9] = 2;
}
else if (random == 9)
{
base[4][9] = 2;
base[3][10] = 2;
base[4][10] = 2;
}
else if (random == 10)
{
base[3][9] = 2;
base[3][10] = 2;
base[4][10] = 2;
}
//当四个方块的情况
else if(random == 9)
else if(random == 11)
{
base[3][10] = 2;
base[4][10] = 2;
base[3][9] = 2;
base[4][9] = 2;
}
else if(random == 12)
{
base[3][10] = 2;
base[4][10] = 2;
base[3][9] = 2;
base[4][11] = 2;
}
else if(random == 13)
{
base[3][10] = 2;
base[4][10] = 2;
base[3][11] = 2;
base[4][9] = 2;
}
else if(random == 14)
{
base[3][10] = 2;
base[4][10] = 2;
base[4][9] = 2;
base[5][9] = 2;
}
else if(random == 15)
{
base[3][10] = 2;
base[4][10] = 2;
@ -284,31 +324,6 @@ void blockGameOver()
//结束则填满
if(blockGameStatus == over)
{
//дÈëÅÅÐаñ
if(addBest(score))
{
IapEraseSector(IAP_ADDRESS);
IapProgramByte(IAP_ADDRESS + 0, bestScore[0] >> 8);
IapProgramByte(IAP_ADDRESS + 1, bestScore[0] % 256);
IapProgramByte(IAP_ADDRESS + 2, bestScore[1] >> 8);
IapProgramByte(IAP_ADDRESS + 3, bestScore[1] % 256);
IapProgramByte(IAP_ADDRESS + 4, bestScore[2] >> 8);
IapProgramByte(IAP_ADDRESS + 5, bestScore[2] % 256);
IapProgramByte(IAP_ADDRESS + 6, bestScore[3] >> 8);
IapProgramByte(IAP_ADDRESS + 7, bestScore[3] % 256);
IapProgramByte(IAP_ADDRESS + 8, bestScore[4] >> 8);
IapProgramByte(IAP_ADDRESS + 9, bestScore[4] % 256);
IapProgramByte(IAP_ADDRESS + 10, bestScore[5] >> 8);
IapProgramByte(IAP_ADDRESS + 11, bestScore[5] % 256);
IapProgramByte(IAP_ADDRESS + 12, bestScore[6] >> 8);
IapProgramByte(IAP_ADDRESS + 13, bestScore[6] % 256);
IapProgramByte(IAP_ADDRESS + 14, bestScore[7] >> 8);
IapProgramByte(IAP_ADDRESS + 15, bestScore[7] % 256);
IapProgramByte(IAP_ADDRESS + 16, bestScore[8] >> 8);
IapProgramByte(IAP_ADDRESS + 17, bestScore[8] % 256);
IapProgramByte(IAP_ADDRESS + 18, bestScore[9] >> 8);
IapProgramByte(IAP_ADDRESS + 19, bestScore[9] % 256);
}
for(j = 0; j < MAX_Y; j++)
for(i = 0; i < MAX_X; i++)
{