?? fangkuai.c
字號(hào):
#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ù): 無
//= 返 回 值: 無
//= 函數(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);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -