《俄羅斯方塊》(Tetris, 俄文:Тетрис)是一款由俄羅斯人阿列克謝·帕基特諾夫于1984年6月發明的休閑游戲。
該游戲曾經被多家公司代理過。經過多輪訴訟后,該游戲的代理權最終被任天堂獲得。 [1] 任天堂對于俄羅斯方塊來說意義重大,因為將它與GB搭配在一起后,獲得了巨大的成功。
《俄羅斯方塊》的基本規則是移動、旋轉和擺放游戲自動輸出的各種方塊,使之排列成完整的一行或多行并且消除得分。
1.硬件平臺
STM32開發板
3.5寸LCD屏(16位并口8080時序)
字庫存儲W25Q64(SPI)
4個按鍵
2.方塊示例
本設計中方塊種類共5種,根據方向的不同可分為19種可能性。
3.游戲效果圖
1.游戲結束效果。當方塊堆疊觸碰到上頂端,則游戲結束。
2.正常游戲和方塊顏色分配,下一個方塊提示,積分統計,按鍵操作說明。
3.消行效果展示,得分獲取。
軟件設計中,消除一行得1分,消除兩行得2分,消除3行得4分,消除4行得8分。
4.軟件設計
1.單個方塊繪制和清除一行處理
/*************繪制單個方塊**************/
void Lcd_DrawDiamond(u16 x,u16 y,u16 c)
{
u16 i;
LcdWriteReg(0x2A);//設置x坐標
LcdWriteData((x>>8)&0xff);//x坐標高8位
LcdWriteData(x&0xff);//x坐標低8位
LcdWriteData(((x+8)>>8)&0xff);//x坐標高8位
LcdWriteData((x+8)&0xff);//x坐標低8位
LcdWriteReg(0x2B);//設置Y坐標
LcdWriteData((y>>8)&0xff);//Y坐標高8位
LcdWriteData(y&0xff);//Y坐標低8位
LcdWriteData(((y+8)>>8)&0xff);//Y坐標高8位
LcdWriteData((y+8)&0xff);//Y坐標低8位
LcdWriteReg(0x2C);//設置x坐標
for(i=0;i<9*9;i++)LcdWriteData(c);
}
/******************消除一行*******************/
void Lcd_ClearOneLineDisplay(u16 y,u16 c)
{
u16 i=0;
for(i=2;i;i+=10)>
2.繪制各個方塊,設置方塊顏色
/*每一個種類的顏色*/
/*
1 -- DARKBLUE --Drawshape_color[0]
2,3 -- BRRED --Drawshape_color[1]
4,5,6,7 -- BLUE --Drawshape_color[2]
8,9,10,11,12,13,14,15 -- GRAY --Drawshape_color[3]
16,17,18,19 --BLACK -- Drawshape_color[4]
*/
const u16 Drawshape_color[]={DARKBLUE,BRRED,BLUE,GRAY,BLACK};
/*******************繪制一個俄羅斯方塊***************************
**形參:x,y -- 要顯示的位置
** what --要繪制的方塊序號(1~19)
** c --方塊顏色
** stat --更新到二維數組中的狀態(0表示清除,1表示寫入狀態)
*******************************************************************/
void Lcd_Drawshape(u16 x,u16 y,u8 what,u16 c,u8 stat)
{
switch (what)
{
case 1:
{
Lcd_DrawDiamond(x,y,c);
Lcd_DrawDiamond(x+10,y,c);
Lcd_DrawDiamond(x,y+10,c);
Lcd_DrawDiamond(x+10,y+10,c);
Lcd_Refreshbuff(x,y,stat);
Lcd_Refreshbuff(x+10,y,stat);
Lcd_Refreshbuff(x,y+10,stat);
Lcd_Refreshbuff(x+10,y+10,stat);
}
break;
case 2:
{
Lcd_DrawDiamond(x,y,c);
Lcd_DrawDiamond(x+10,y,c);
Lcd_DrawDiamond(x+20,y,c);
Lcd_DrawDiamond(x+30,y,c);
Lcd_Refreshbuff(x,y,stat);
Lcd_Refreshbuff(x+10,y,stat);
Lcd_Refreshbuff(x+20,y,stat);
Lcd_Refreshbuff(x+30,y,stat);
}
break;
case 3:
{
Lcd_DrawDiamond(x,y,c);
Lcd_DrawDiamond(x,y+10,c);
Lcd_DrawDiamond(x,y+20,c);
Lcd_DrawDiamond(x,y+30,c);
Lcd_Refreshbuff(x,y,stat);
Lcd_Refreshbuff(x,y+10,stat);
Lcd_Refreshbuff(x,y+20,stat);
Lcd_Refreshbuff(x,y+30,stat);
}
break;
case 4:
{
Lcd_DrawDiamond(x+10,y,c);
Lcd_DrawDiamond(x,y+10,c);
Lcd_DrawDiamond(x+10,y+10,c);
Lcd_DrawDiamond(x+20,y+10,c);
Lcd_Refreshbuff(x+10,y,stat);
Lcd_Refreshbuff(x,y+10,stat);
Lcd_Refreshbuff(x+10,y+10,stat);
Lcd_Refreshbuff(x+20,y+10,stat);
}
break;
case 5:
{
Lcd_DrawDiamond(x+10,y+10,c);
Lcd_DrawDiamond(x,y,c);
Lcd_DrawDiamond(x,y+10,c);
Lcd_DrawDiamond(x,y+20,c);
Lcd_Refreshbuff(x+10,y+10,stat);
Lcd_Refreshbuff(x,y,stat);
Lcd_Refreshbuff(x,y+10,stat);
Lcd_Refreshbuff(x,y+20,stat);
}
break;
case 6:
{
Lcd_DrawDiamond(x,y+10,c);
Lcd_DrawDiamond(x+10,y,c);
Lcd_DrawDiamond(x+10,y+10,c);
Lcd_DrawDiamond(x+10,y+20,c);
Lcd_Refreshbuff(x,y+10,stat);
Lcd_Refreshbuff(x+10,y,stat);
Lcd_Refreshbuff(x+10,y+10,stat);
Lcd_Refreshbuff(x+10,y+20,stat);
}
break;
case 7:
{
Lcd_DrawDiamond(x+10,y+10,c);
Lcd_DrawDiamond(x,y,c);
Lcd_DrawDiamond(x+10,y,c);
Lcd_DrawDiamond(x+20,y,c);
Lcd_Refreshbuff(x+10,y+10,stat);
Lcd_Refreshbuff(x,y,stat);
Lcd_Refreshbuff(x+10,y,stat);
Lcd_Refreshbuff(x+20,y,stat);
}
break;
case 8:
{
Lcd_DrawDiamond(x,y,c);
Lcd_DrawDiamond(x,y+10,c);
Lcd_DrawDiamond(x,y+20,c);
Lcd_DrawDiamond(x+10,y+20,c);
Lcd_Refreshbuff(x,y,stat);
Lcd_Refreshbuff(x,y+10,stat);
Lcd_Refreshbuff(x,y+20,stat);
Lcd_Refreshbuff(x+10,y+20,stat);
}
break;
case 9:
{
Lcd_DrawDiamond(x,y,c);
Lcd_DrawDiamond(x,y+10,c);
Lcd_DrawDiamond(x+10,y,c);
Lcd_DrawDiamond(x+20,y,c);
Lcd_Refreshbuff(x,y,stat);
Lcd_Refreshbuff(x,y+10,stat);
Lcd_Refreshbuff(x+10,y,stat);
Lcd_Refreshbuff(x+20,y,stat);
}
break;
case 10:
{
Lcd_DrawDiamond(x,y,c);
Lcd_DrawDiamond(x+10,y,c);
Lcd_DrawDiamond(x+10,y+10,c);
Lcd_DrawDiamond(x+10,y+20,c);
Lcd_Refreshbuff(x,y,stat);
Lcd_Refreshbuff(x+10,y,stat);
Lcd_Refreshbuff(x+10,y+10,stat);
Lcd_Refreshbuff(x+10,y+20,stat);
}
break;
case 11:
{
Lcd_DrawDiamond(x,y+10,c);
Lcd_DrawDiamond(x+10,y+10,c);
Lcd_DrawDiamond(x+20,y+10,c);
Lcd_DrawDiamond(x+20,y,c);
Lcd_Refreshbuff(x,y+10,stat);
Lcd_Refreshbuff(x+10,y+10,stat);
Lcd_Refreshbuff(x+20,y+10,stat);
Lcd_Refreshbuff(x+20,y,stat);
}
break;
case 12:
{
Lcd_DrawDiamond(x+10,y,c);
Lcd_DrawDiamond(x+10,y+10,c);
Lcd_DrawDiamond(x+10,y+20,c);
Lcd_DrawDiamond(x,y+20,c);
Lcd_Refreshbuff(x+10,y,stat);
Lcd_Refreshbuff(x+10,y+10,stat);
Lcd_Refreshbuff(x+10,y+20,stat);
Lcd_Refreshbuff(x,y+20,stat);
}
break;
case 13:
{
Lcd_DrawDiamond(x,y,c);
Lcd_DrawDiamond(x+10,y,c);
Lcd_DrawDiamond(x+20,y,c);
Lcd_DrawDiamond(x+20,y+10,c);
Lcd_Refreshbuff(x,y,stat);
Lcd_Refreshbuff(x+10,y,stat);
Lcd_Refreshbuff(x+20,y,stat);
Lcd_Refreshbuff(x+20,y+10,stat);
}
break;
case 14:
{
Lcd_DrawDiamond(x,y,c);
Lcd_DrawDiamond(x+10,y,c);
Lcd_DrawDiamond(x,y+10,c);
Lcd_DrawDiamond(x,y+20,c);
Lcd_Refreshbuff(x,y,stat);
Lcd_Refreshbuff(x+10,y,stat);
Lcd_Refreshbuff(x,y+10,stat);
Lcd_Refreshbuff(x,y+20,stat);
}
break;
case 15:
{
Lcd_DrawDiamond(x,y,c);
Lcd_DrawDiamond(x,y+10,c);
Lcd_DrawDiamond(x+10,y+10,c);
Lcd_DrawDiamond(x+20,y+10,c);
Lcd_Refreshbuff(x,y,stat);
Lcd_Refreshbuff(x,y+10,stat);
Lcd_Refreshbuff(x+10,y+10,stat);
Lcd_Refreshbuff(x+20,y+10,stat);
}
break;
case 16:
{
Lcd_DrawDiamond(x+10,y,c);
Lcd_DrawDiamond(x,y+10,c);
Lcd_DrawDiamond(x+10,y+10,c);
Lcd_DrawDiamond(x,y+20,c);
Lcd_Refreshbuff(x+10,y,stat);
Lcd_Refreshbuff(x,y+10,stat);
Lcd_Refreshbuff(x+10,y+10,stat);
Lcd_Refreshbuff(x,y+20,stat);
}
break;
case 17:
{
Lcd_DrawDiamond(x,y,c);
Lcd_DrawDiamond(x+10,y,c);
Lcd_DrawDiamond(x+10,y+10,c);
Lcd_DrawDiamond(x+20,y+10,c);
Lcd_Refreshbuff(x,y,stat);
Lcd_Refreshbuff(x+10,y,stat);
Lcd_Refreshbuff(x+10,y+10,stat);
Lcd_Refreshbuff(x+20,y+10,stat);
}
break;
case 18:
{
Lcd_DrawDiamond(x,y,c);
Lcd_DrawDiamond(x,y+10,c);
Lcd_DrawDiamond(x+10,y+10,c);
Lcd_DrawDiamond(x+10,y+20,c);
Lcd_Refreshbuff(x,y,stat);
Lcd_Refreshbuff(x,y+10,stat);
Lcd_Refreshbuff(x+10,y+10,stat);
Lcd_Refreshbuff(x+10,y+20,stat);
}
break;
case 19:
{
Lcd_DrawDiamond(x,y+10,c);
Lcd_DrawDiamond(x+10,y+10,c);
Lcd_DrawDiamond(x+10,y,c);
Lcd_DrawDiamond(x+20,y,c);
Lcd_Refreshbuff(x,y+10,stat);
Lcd_Refreshbuff(x+10,y+10,stat);
Lcd_Refreshbuff(x+10,y,stat);
Lcd_Refreshbuff(x+20,y,stat);
}
break;
}
}
3.方塊移動和方向切換
/******************向下移動*****************/
int Lcd_DownMove(u16 x,u16 y,u16 what,u16 c)
{
Lcd_Drawshape(x,y,what,WHITE,0);
Lcd_Drawshape(x,y+10,what,c,1);
return y+10;
}
/***************向左移動*********************/
int Lcd_LeftMove(u16 x,u16 y,u16 what,u16 c)
{
Lcd_Drawshape(x,y,what,WHITE,0);
Lcd_Drawshape(x-10,y,what,c,1);
return x-10;
}
/****************向右移動********************/
int Lcd_RightMove(u16 x,u16 y,u16 what,u16 c)
{
Lcd_Drawshape(x,y,what,WHITE,0);
Lcd_Drawshape(x+10,y,what,c,1);
return x+10;
}
/**************************改變圖形***************/
u8 Lcd_Changshape(u16 x,u16 y,u16 what,u16 c)
{
u8 stat;
switch(what)
{
case 1:stat=1;break;
case 2:
{
if(shape_place_stat[(y+40)/10][x/10] || shape_place_stat[(y+30)/10][x/10] || shape_place_stat[(y+20)/10][x/10] || shape_place_stat[(y+10)/10][x/10])
{
stat=2;
break;
}
Lcd_Drawshape(x,y,2,WHITE,0);Lcd_Drawshape(x,y,3,c,1);stat=3;break;
}
case 3:
{
if(shape_place_stat[(y+40)/10][(x+40)/10])
{
stat=3;
break;
}
Lcd_Drawshape(x,y,3,WHITE,0);Lcd_Drawshape(x,y,2,c,1);stat=2;break;
}
case 4:
{
Lcd_Drawshape(x,y,4,WHITE,0);Lcd_Drawshape(x,y,5,c,1);stat=5;break;
}
case 5:
{
Lcd_Drawshape(x,y,5,WHITE,0);Lcd_Drawshape(x,y,6,c,1);stat=6;break;
}
case 6:
{
if(shape_place_stat[y/10][(x+30)/10])
{
stat=6;
break;
}
Lcd_Drawshape(x,y,6,WHITE,0);Lcd_Drawshape(x,y,7,c,1);stat=7;break;
}
case 7:Lcd_Drawshape(x,y,7,WHITE,0);Lcd_Drawshape(x,y,4,c,1);stat=4;break;
case 8:
{
if(shape_place_stat[y/10][(x+30)/10])
{
stat=8;
break;
}
Lcd_Drawshape(x,y,8,WHITE,0);Lcd_Drawshape(x,y,9,c,1);stat=9;break;
}
case 9:
{
if(shape_place_stat[(y+30)/10][x/10])
{
stat=9;
break;
}
Lcd_Drawshape(x,y,9,WHITE,0);Lcd_Drawshape(x,y,10,c,1);stat=10;break;
}
case 10:
{
if(shape_place_stat[y/10][(x+30)/10])
{
stat=10;
break;
}
Lcd_Drawshape(x,y,10,WHITE,0);Lcd_Drawshape(x,y,11,c,1);stat=11;break;
}
case 11:
{
if(shape_place_stat[(y+30)/10][x/10])
{
stat=11;
break;
}
Lcd_Drawshape(x,y,11,WHITE,0);Lcd_Drawshape(x,y,8,c,1);stat=8;break;
}
case 12:
{
if(shape_place_stat[(y)/10][(x+30)/10] || shape_place_stat[(y+20)/10][x/10] || shape_place_stat[(y+20)/10][(x+30)/10])
{
stat=12;
break;
}
Lcd_Drawshape(x,y,12,WHITE,0);Lcd_Drawshape(x,y,13,c,1);stat=13;break;
}
case 13:
{
if(shape_place_stat[(y+30)/10][x/10])
{
stat=13;
break;
}
Lcd_Drawshape(x,y,13,WHITE,0);Lcd_Drawshape(x,y,14,c,1);stat=14;break;
}
case 14:
{
if(shape_place_stat[y/10][(x+30)/10])
{
stat=14;
break;
}
Lcd_Drawshape(x,y,14,WHITE,0);Lcd_Drawshape(x,y,15,c,1);stat=15;break;
}
case 15:
{
if(shape_place_stat[(y+30)/10][x/10])
{
stat=15;
break;
}
Lcd_Drawshape(x,y,15,WHITE,0);Lcd_Drawshape(x,y,12,c,1);stat=12;break;
}
case 16:
{
if(shape_place_stat[y/10][(x+30)/10])
{
stat=16;
break;
}
Lcd_Drawshape(x,y,16,WHITE,0);Lcd_Drawshape(x,y,17,c,1);stat=17;break;
}
case 17:
{
Lcd_Drawshape(x,y,17,WHITE,0);Lcd_Drawshape(x,y,16,c,1);stat=16;break;
}
case 18:
{
if(shape_place_stat[y/10][(x+30)/10])
{
stat=18;
break;
}
Lcd_Drawshape(x,y,18,WHITE,0);Lcd_Drawshape(x,y,19,c,1);stat=19;break;
}
case 19:
{
Lcd_Drawshape(x,y,19,WHITE,0);Lcd_Drawshape(x,y,18,c,1);stat=18;break;
}
}
return stat;
}
4.判斷得分,消行。
/***********得分判斷*********************/
u8 Lcd_GetMark(u8 *buff)
{
int i,j,k;
u8 cnt=0;//保存要消除的行數
int line=0;
/*判斷當前最高位置*/
for(i=47;i>=0;i--)//高度
{
for(j=1;j<23;j++)//每一行的方格數
{
if(shape_place_stat[i][j])break;
}
if(j==23)
{
line=i;//記錄當前方塊有多少行
break;
}
}
// printf("line=%d\r\n",line);
if(line<=1)return 0xff;//游戲結束
for(i=47;i>line;i--)
{
for(j=0;j<24;j++)
{
if(shape_place_stat[i][j]==0)break;
}
if(j==24)buff[cnt++]=i;//記錄哪一行需要消除
}
/*得分,消行*/
if(cnt)
{
for(i=0;i=0;k--)
{
for(j=buff[k];j>=line;j--)
{
for(i=0;i<24;i++)
{
shape_place_stat[j][i]=shape_place_stat[j-1][i];
}
}
line--;
}
for(i=buff[0];i>=line;i--)
{
Lcd_ClearOneLine(i);
}
}
if(cnt==0)cnt=0;
else if(cnt==1)cnt=1;//消除1行得1分
else if(cnt==2)cnt=4;//消除2行得4分
else if(cnt==3)cnt=8;
else if(cnt==4)cnt=16;
return cnt;
}
/*清空圖形掉落位置狀態信息*/
void Lcd_Clearshape(void)
{
int i,j;
for(i=0;i<48;i++)
{
for(j=1;j<23;j++)
{
shape_place_stat[i][j]=0;
}
}
}
;i++)>
5.窗口設計
/*******************************繪制顯示窗口**************************/
void Lcd_TetrisShowWind(void)
{
LCD_DrawLine(LCD_WIDTH-97, 0, LCD_WIDTH-97, LCD_HIGHT,BLACK);//畫直線
LCD_DrawLine(LCD_WIDTH-96, 0, LCD_WIDTH-96, LCD_HIGHT,BLACK);//畫直線
LCD_DrawLine(LCD_WIDTH-96, 170, LCD_WIDTH-1, 170,BLACK);
LCD_DrawLine(LCD_WIDTH-96, 171, LCD_WIDTH-1, 171,BLACK);
LCD_Display_Str(LCD_WIDTH-96+25,30,24,(u8 *)"NEXT",DARKBLUE);//顯示字符串
LCD_Display_Str(LCD_WIDTH-96+25,200,16,(u8 *)"得 分",DARKBLUE);//顯示字符串
LCD_Display_Str(LCD_WIDTH-96+96/2-12,200+30,24,(u8 *)"0",RED);//顯示字符串
LCD_Display_Str(LCD_WIDTH-96+10,320,16,(u8 *)"旋轉 KEYUP ",DARKBLUE);//顯示字符串
LCD_Display_Str(LCD_WIDTH-96+10,360,16,(u8 *)"暫停 KEY1",DARKBLUE);//顯示字符串
LCD_Display_Str(LCD_WIDTH-96+10,400,16,(u8 *)"左 KEY2 ",DARKBLUE);//顯示字符串
LCD_Display_Str(LCD_WIDTH-96+10,440,16,(u8 *)"右 KEY0",DARKBLUE);//顯示字符串
}
6.初始化硬件,開始游戲
#include "stm32f10x.h"
#include "beep.h"
#include "led.h"
#include "key.h"
#include "delay.h"
#include "usart.h"
#include "w25q64.h"
#include "timer.h"
#include
#include "nt35310.h"
#include "tetris_game.h"
#include
int main()
{
u8 buff[49];
u8 stat=1;
int x0=112,y0=0;
u16 cnt=1,cnt2=0;
u8 key;
u16 mark=0,res,mark2=0;
u16 color;//方塊顏色
u16 i=200;
Beep_Init();
Led_Init();
Key_Init();//按鍵初始化
TIMx_Init(TIM4,7200,65535);
Usartx_Init(USART1,115200,72);
printf("串口初始化完成\r\n");
W25Q64_Init();
LCD_Init();
AA:
LCD_Clear(WHITE);//清屏函數
Lcd_TetrisShowWind();
cnt=rand()%20;
if(cnt==0)cnt=1;
cnt2=rand()%20;
if(cnt2==0)cnt2=1;
Lcd_Drawshape(LCD_WIDTH-96+35,80,cnt2,BLACK,0);
/*俄羅斯方塊示例圖*/
// for(i=1;i<=19;i++)
// {
// if(i==1)color=Drawshape_color[0];
// else if(i>=2 && i<=3)color=Drawshape_color[1];
// else if(i>=4 && i<=7)color=Drawshape_color[2];
// else if(i>=8 && i<=15)color=Drawshape_color[3];
// else if(i>=16 && i<=19)color=Drawshape_color[4];
// Lcd_Drawshape(x0,y0,i,color,0);//繪制圖形
// x0+=50;
// if(x0>=260)
// {
// x0=50;
// y0+=50;
// }
// }
while(1)
{
key=Key_Getval();
if(key==3)//暫停
{
stat=!stat;
}
else if((key==1) && stat)//切換方向
{
i=0;
if(cnt==1)color=Drawshape_color[0];
else if(cnt>=2 && cnt<=3)color=Drawshape_color[1];
else if(cnt>=4 && cnt<=7)color=Drawshape_color[2];
else if(cnt>=8 && cnt<=15)color=Drawshape_color[3];
else if(cnt>=16 && cnt<=19)color=Drawshape_color[4];
cnt=Lcd_Changshape(x0,y0,cnt,color);
}
else if((key==2) && stat)//右
{
if(Lcd_Shape_GetStat(x0+shape_widht[cnt-1]*10,y0)==0)
{
if(cnt==1)color=Drawshape_color[0];
else if(cnt>=2 && cnt<=3)color=Drawshape_color[1];
else if(cnt>=4 && cnt<=7)color=Drawshape_color[2];
else if(cnt>=8 && cnt<=15)color=Drawshape_color[3];
else if(cnt>=16 && cnt<=19)color=Drawshape_color[4];
x0=Lcd_RightMove(x0,y0,cnt,color);
}
}
else if((key==4) && stat)//左
{
if(x0>=10)
{
if(Lcd_Shape_GetStat(x0-10,y0)==0)
{
if(cnt==1)color=Drawshape_color[0];
else if(cnt>=2 && cnt<=3)color=Drawshape_color[1];
else if(cnt>=4 && cnt<=7)color=Drawshape_color[2];
else if(cnt>=8 && cnt<=15)color=Drawshape_color[3];
else if(cnt>=16 && cnt<=19)color=Drawshape_color[4];
x0=Lcd_LeftMove(x0,y0,cnt,color);
}
}
}
if(i>=100 && stat)
{
i=0;
if(cnt==1)color=Drawshape_color[0];
else if(cnt>=2 && cnt<=3)color=Drawshape_color[1];
else if(cnt>=4 && cnt<=7)color=Drawshape_color[2];
else if(cnt>=8 && cnt<=15)color=Drawshape_color[3];
else if(cnt>=16 && cnt<=19)color=Drawshape_color[4];
y0=Lcd_DownMove(x0,y0,cnt,color);//向下
if(Lcd_Shape_GetLowerBoundary(x0,y0,cnt))//
{
res=Lcd_GetMark(buff);
if(res==0xff)
{
mark=0;
res=0;
LCD_Display_Str(LCD_WIDTH/2-9*12,230,24,(u8 *)"GAME OVER",RED);
LCD_Display_Str(LCD_WIDTH/2-9*12-20,265,16,(u8 *)"請按任意鍵重新開始!",RED);
while(1)
{
key=Key_Getval();
if(key)
{
Lcd_Clearshape();
goto AA;
}
}
}
mark+=res;
if(mark2!=mark)
{
mark2=mark;
snprintf((char *)buff,sizeof(buff),"%02d",mark2);
LCD_Display_Str(LCD_WIDTH-94,230,24,(u8 *)" ",WHITE);//顯示字符串
LCD_Display_Str(LCD_WIDTH-94+96/2-strlen((char *)buff)*12,230,24,buff,RED);//顯示字符串
}
// printf("得分:%d\r\n",mark);
x0=112,y0=0;
Lcd_Drawshape(LCD_WIDTH-96+35,80,cnt2,WHITE,0);
cnt=cnt2;
cnt2=rand()%20;
if(cnt2==0)cnt2=1;
Lcd_Drawshape(LCD_WIDTH-96+35,80,cnt2,BLACK,0);
}
}
Delay_Ms(1);
i++;
}
}
審核編輯:湯梓紅
-
STM32
+關注
關注
2270文章
10895瀏覽量
355729 -
游戲
+關注
關注
2文章
742瀏覽量
26312 -
開發板
+關注
關注
25文章
5032瀏覽量
97371
發布評論請先 登錄
相關推薦
評論