久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標(biāo)題:
基于AT89c51單片機(jī)制作的俄羅斯方塊游戲 T6963C液晶顯示源碼
[打印本頁(yè)]
作者:
CHAHANYU
時(shí)間:
2017-4-24 12:12
標(biāo)題:
基于AT89c51單片機(jī)制作的俄羅斯方塊游戲 T6963C液晶顯示源碼
注明:只能按2鍵往左移
按4鍵往右移
按8鍵變換
無(wú)快速下降鍵
0.png
(54.54 KB, 下載次數(shù): 77)
下載附件
2017-4-24 17:34 上傳
部分源碼預(yù)覽:
#include "t6963c.h"
#include "typedef.h"
#include "key.h"
#define X_START 5
#define Y_START 0
#define MIN_SLOW_SPEED 300
#define BX_START 30
#define BY_START 15
#define Nothing 100
//全局?jǐn)?shù)據(jù)
code uchar Game_Char[]={0x27,0x41,0x4d,0x45};
code uchar Over_Char[]={0x2f,0x56,0x45,0x52};
static uchar xx,yy; //方塊的位置
static uint Game_Score=0;
static uchar xdata Platform[14][21]; //游戲平臺(tái)數(shù)據(jù)
static uchar This_shape; //當(dāng)前形狀
static uchar Next_shape=0;
static uint Game_Speed=MIN_SLOW_SPEED; //等級(jí)速度,正常情況,方塊下降的速度
static uchar Game_Stop=1;
static uchar Game_Level=0;
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////方塊形狀的定義//////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
struct POINT{
uchar x;
uchar y;
};
struct SHAPE{
struct POINT point[4];
uchar next; //下一個(gè)形狀
}
xdata shape[19]={
{ 1,0,0,1,1,1,2,1,1 },
{ 1,0,1,1,2,1,1,2,2 },
{ 0,0,1,0,2,0,1,1,3 },
{ 1,0,0,1,1,1,1,2,0 },
{ 1,0,2,0,1,1,1,2,5 },
{ 0,0,1,0,2,0,2,1,6 },
{ 2,0,2,1,2,2,1,2,7 },
{ 0,0,0,1,1,1,2,1,4 },
{ 1,0,2,0,2,1,2,2,9 },
{ 2,0,0,1,1,1,2,1,10 },
{ 1,0,1,1,1,2,2,2,11 },
{ 0,0,1,0,2,0,0,1,8 },
{ 0,0,0,1,1,1,1,2,13 },
{ 1,0,2,0,0,1,1,1,12 },
{ 2,0,1,1,2,1,1,2,15 },
{ 0,0,1,0,1,1,2,1,14 },
{ 1,0,1,1,1,2,1,3,17 },
{ 0,1,1,1,2,1,3,1,16 },
{ 1,0,2,0,1,1,2,1,18 },
};
////////////////////////////////////////////////////////////////////////////
//**************************************************************************
//= 函數(shù)原型:void Init_GamePlatform()
//= 功 能: 初始化游戲平臺(tái)
//= 參 數(shù): 無(wú)
//= 返 回 值: 無(wú)
//= 函數(shù)性質(zhì):公有函數(shù)
//= 注 意:
//***************************************************************************
void Show_score(uchar);
void Init_GamePlatform()
{
uchar i;
uchar j;
uchar N_Hanzi;
Wr_line(1,33,13,64,1 ); //初始化游戲平臺(tái)邊界 畫游戲區(qū)域
Wr_line(1,33,14,64,1 ); //畫上橫線
Wr_line(0,33,15,100,1);
Wr_line(0,34,15,100,1); //畫左豎線
Wr_line(1,33,115,64,1);
Wr_line(1,33,116,64,1); //畫下橫線
Wr_line(0,95,15,100,1);
Wr_line(0,96,15,100,1); //畫右豎線
//--------------------------------------------------------
for(i=1;i<13;i++) //游戲平臺(tái)數(shù)據(jù)清零
{
for(j=0;j<20;j++)
{
Platform[i][j]=0;
}
}
for(i=1;i<13;i++)
{
Platform[i][20]=1; //游戲平臺(tái)最下面一行的每一個(gè)方塊位置為1,作為下邊界
}
for(j=0;j<20;j++) //游戲平臺(tái)左右方塊位置置1,作為左右邊界
{
Platform[0][j]=1;
Platform[13][j]=1;
}
//---------------------------------------------------------
N_Hanzi=0;
for(j=3;j<=12;j=j+2) //
{
hanzhi(1,j,N_Hanzi,1);
N_Hanzi++; //指向下一個(gè)漢字
}
hanzhi(13,3,6,1); //輸入“分”漢字
hanzhi(13,8,8,1); //輸入“級(jí)”漢字
Show_score(0); //顯示初始分?jǐn)?shù)
Show_num(13,11,Game_Level); //顯示初始等級(jí)水平
Game_Speed=MIN_SLOW_SPEED/(Game_Level+1); //根據(jù)水平確定速度
//------------------------------------------------------------------
Game_Score=0;
xx=X_START ;
yy=Y_START ;
}
////////////////////////Init_Game/////////////////////
void Init_Game()
{
Game_Stop=1;
Init_GamePlatform();
hanzhi(7,3,9,1); //輸入“按”漢字
Show_num(7,6,7); //顯示7
hanzhi(7,8,10,1); //輸入“開”漢字
hanzhi(7,10,11,1); //輸入“始”漢字
}
//**************************************************************************
//= 函數(shù)原型:void XiaoFengKuai(uchar x,uchar y,uchar mode)
//= 功 能: 顯示一個(gè)小方塊
//= 參 數(shù): 小方塊的橫x,堅(jiān)坐標(biāo)y,mode=1:顯示小方塊,mode=0:刪除小方塊
//= 返 回 值:
//= 函數(shù)性質(zhì):私有函數(shù)
//= 注 意:
//***************************************************************************
void XiaoFengKuai(uchar x,uchar y,bit mode)
{
uchar x1=5*x+BX_START; //將方塊在平臺(tái)的位置轉(zhuǎn)化成LCD的點(diǎn)坐標(biāo)(地址轉(zhuǎn)換)
uchar y1=5*y+BY_START;
uchar i;
if(mode==1)
{
for(i=0;i<5;i++)
{
Point(x1+i,y1,1); //畫一條橫線
}
y1+=4;
for(i=0;i<5;i++)
{
Point(x1+i,y1,1); //畫第二條橫線
}
for(i=0;i<5;i++)
{
Point(x1,y1-i,1); //畫第1條堅(jiān)線
}
x1+=4;
for(i=0;i<5;i++)
{
Point(x1,y1-i,1); //畫第2條堅(jiān)線
}
y1-=4;
for(i=0;i<5;i++)
{
Point(x1-i,y1+i,1); //畫斜線
}
}
else
{
for(i=0;i<5;i++)
{
Point(x1+i,y1,0); //畫一條橫線
}
y1+=4;
for(i=0;i<5;i++)
{
Point(x1+i,y1,0); //畫第二條橫線
}
for(i=0;i<5;i++)
{
Point(x1,y1-i,0); //畫第1條堅(jiān)線
}
x1+=4;
for(i=0;i<5;i++)
{
Point(x1,y1-i,0); //畫第2條堅(jiān)線
}
y1-=4;
for(i=0;i<5;i++)
{
Point(x1-i,y1+i,0); //畫斜線
}
}
}
//////////////////////////////////////////////////////////////////////////
////////////////左沖突檢測(cè)//////////////////////////////////////////////
bit Left_Anti()
{
uchar i;
for(i=0;i<4;i++)
{
if(Platform[xx+shape[This_shape].point[i].x-1][yy+shape[This_shape].point[i].y]==1)
return 1;
}
return 0;
}
////////////////右沖突檢測(cè)///////////////////////////////////////////
bit Right_Anti()
{
uchar i;
for(i=0;i<4;i++)
{
if(Platform[xx+shape[This_shape].point[i].x+1][yy+shape[This_shape].point[i].y]==1)
return 1;
}
return 0;
}
////////////////////////////////////////下沖突檢測(cè)//////////////////////////
bit Bottom_Anti()
{
uchar i;
for(i=0;i<4;i++)
{
if(Platform[xx+shape[This_shape].point[i].x][yy+shape[This_shape].point[i].y+1]==1)
return 1;
}
return 0;
}
//////////////////////////////////改變形狀時(shí)產(chǎn)生的沖突檢測(cè)////////////////////
bit Change_Shape_Anti()
{
uchar i;
for(i=0;i<4;i++)
{
if(Platform[xx+shape[shape[This_shape].next].point[i].x][yy+shape[shape[This_shape].next].point[i].y]==1)
return 1; //檢測(cè)一個(gè)形狀的沖突情況
}
return 0;
}
//////////////////////////////////產(chǎn)生一個(gè)隨機(jī)數(shù),返回一個(gè)隨機(jī)數(shù)///////////////
uchar Random()
{
static uchar m;
m+=49;
return (m%19);
}
//////////////計(jì)分函數(shù),參數(shù)為 消行行數(shù)n///////////////////////////////////////
void Show_score(uchar n)
{
Game_Score=Game_Score+10*n;
if(Game_Score<10)
{
Show_num(13,6,Game_Score%10); //顯示個(gè)位
}
else if(Game_Score<100)
{
Show_num(14,6,Game_Score%10);
Show_num(13,6,Game_Score/10%100); //顯示個(gè)位,十位
}
else if(Game_Score<1000)
{
Show_num(14,6,Game_Score%10);
Show_num(13,6,Game_Score/10%10);
Show_num(12,6,Game_Score/100%10); //顯示個(gè)位 ,十位,百位
}
else
{
Show_num(15,6,Game_Score%10);
Show_num(14,6,Game_Score/10%10);
Show_num(13,6,Game_Score/100%10); //顯示個(gè)位 ,十位,百位,千位
Show_num(12,6,Game_Score/1000);
}
if(Game_Score%1000==0)
{
if(Game_Score>0)
{
Game_Level++;
if(Game_Level==10)
{
Game_Stop=1;
hanzhi(7,5,12,1); // 輸出“太棒了"
hanzhi(7,7,13,1);
hanzhi(7,9,14,1);
}
Show_num(13,11,Game_Level); //顯示水平
}
}
}
//**************************************************************************
//= 函數(shù)原型:void Undisplay_line()
//= 功 能: 消除行
//= 參 數(shù): 無(wú)
//= 返 回 值: 無(wú)
//= 函數(shù)性質(zhì):私有函數(shù)
//= 注 意:
//***************************************************************************
void UnDisplay_line()
{
uchar Del_Line; //標(biāo)識(shí)要?jiǎng)h除的行
uchar Del_Line_Num=0; //標(biāo)識(shí)刪除的行數(shù)
uchar i,j,k;
bit HavePoint; //標(biāo)識(shí)一行中是否有空白點(diǎn)
for(i=0;i<4;i++)
{
for(j=1;j<13;j++)
{
if(Platform[j][yy+i]==0)
break; //如果這一行中有一個(gè)為空,則退出這一行的循環(huán)
else if(j==12)
{
Del_Line=yy+i; //確定要?jiǎng)h除的行
if(Del_Line<20)
{
Del_Line_Num++; //計(jì)算共刪除的行數(shù)
for(k=1;k<13;k++)
{
XiaoFengKuai(k,Del_Line,0); //刪除行
Platform[k][Del_Line]=0; //平臺(tái)數(shù)據(jù)清零
}
while(1) //下移
…………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼
下載:
俄羅斯方塊.zip
(139.26 KB, 下載次數(shù): 56)
2017-4-24 12:12 上傳
點(diǎn)擊文件名下載附件
小游戲,可移交作業(yè)用!
下載積分: 黑幣 -5
作者:
rrqxx
時(shí)間:
2018-9-29 22:01
謝謝樓主分享
歡迎光臨 (http://www.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
黄色成人免费在线观看
|
中文字幕一区二区三区四区五区
|
高清久久久
|
天堂久久天堂综合色
|
免费观看一级毛片
|
日日干日日操
|
亚洲一区二区久久
|
国产精品久久久久久二区
|
日韩亚洲视频在线
|
久久久久久国产精品免费免费男同
|
亚洲免费成人
|
99热视
|
国产精品一区二
|
1000部精品久久久久久久久
|
在线播放一区二区三区
|
亚洲精品色
|
日本精品网站
|
日韩中文字幕2019
|
一级a性色生活片久久毛片波多野
|
免费人成激情视频在线观看冫
|
秋霞电影院午夜伦
|
国产四区
|
日韩电影中文字幕
|
日韩在线一区二区三区
|
久久精品免费观看
|
www.一区二区三区
|
精品国模一区二区三区欧美
|
一区二区福利视频
|
欧美成人精品一区二区男人看
|
精品九九
|
久久综合狠狠综合久久综合88
|
一区二区三区视频在线
|
黄色小视频入口
|
亚洲美女av网站
|
精品久久一区二区三区
|
中文字幕第十页
|
亚洲成人精品国产
|
日本三级在线视频
|
日韩有码在线观看
|
日韩在线观看
|
日韩精品一
|