📄 box.c
字号:
/**********************************************************************
1.方块图标坐标举例:
7高位4 3低位0
┌─────────┐
│□□□□ ○■□□│
│□□□□ ■■■□│
│□□□□ □□□□│
│□□□□ □□□□│
└─────────┘
对于上幅方块图像,,,○所示处为(0,0)点,,,
2.RAM坐标举例 31X40(x,y):
|┌──────────────┐|
|│(0, 1) (0,1) ... (0, 40) │|
|│(1, 1) │|
|│ . │|
|│ . │|
|│ . │|
|│(30,1) ... (30,40) │|
|└──────────────┘|
|________________________________|
第0列第41列第31行为游戏的边界线
*/
//line:31 colum:5*8
unsigned char idata tidu[31][5]={
0x01,0x00,0x00,0x00,0x00,
0x02,0x00,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,
0x08,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,
0x02,0x00,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x00,
};
3.
(x,y)x:line.y:colum
(0,0) ||(0,1)----------------------------(0,40)|| (0,41)
(1,0) ||(1,1)----------------------------(1,40)|| (1,41)
(2,0) ||(2,1)----------------------------(2,40)|| (2,41)
----- ||---------------------------------------||-----
(30,0)||(30,1)--------------------------(30,40)|| (30,41)
______________________________________________________
--------------------------------------------------------
(31,0)||(31,1)--------------------------(31,40)||(31,41)
外面为游戏边界区:第0列,第41列,第31行
里面为游戏区:第0列,第41列,第31行之间的区域
4 http://blog.ednchina.com/zook0k/
***********************************************************************/
/**********************************************************************
* 功能: 方块的图形代码,,每四个字节表示一个图形
* 每行表示一个内容,,只表示了第一个状态的样子
* 其它按顺时针转图形可得
***********************************************************************/
unsigned char code TtrsBlck[]={ //
/* ■
■■■ Middle 0 0
*/
0x04,0x0E,0x00,0x00,0x08,0x0C,0x08,0x00,0x0E,0x04,0x00,0x00,0x04,0x0C,0x04,0x00,
/*■
■■■ Left 16 1
*/
0x08,0x0E,0x00,0x00,0x0C,0x08,0x08,0x00,0x0E,0x02,0x00,0x00,0x04,0x04,0x0C,0x00,
/*■■■
■ Right 32 2
*/
0x02,0x0E,0x00,0x00,0x08,0x08,0x0C,0x00,0x0E,0x08,0x00,0x00,0x0C,0x04,0x04,0x00,
/*■■
■■ Z 48 3
*/
0x0C,0x06,0x00,0x00,0x04,0x0C,0x08,0x00,
/* ■■
■■ Z_Reversal 56 4
*/
0x06,0x0C,0x00,0x00,0x08,0x0C,0x04,0x00,
/*■■■■ Line 64 5
*/
0x0F,0x00,0x00,0x00,0x08,0x08,0x08,0x08,
/*■■
■■ Stone 72 6
*/
0x0C,0x0C,0x00,0x00
};
/********************************************************************
* 功能: 图形指针数组
* 指示了各种方块在图形代码里的最初指针
***********************************************************************/
char code TtrsBlckPoint[ ]={ 0, //Middle
16, //Left
32, //Right
48, //Z
56, //Z-twist
64, //Line
72 //Stone
};
/********************************************************************
* 名称: INT8U code TtrsBlckStsNum[]
* 功能: 方块状态个数
* 表示每种方块的状态的个数
***********************************************************************/
char code TtrsBlckStsNum[ ]={ 4, //Middle
4, //Left
4, //Right
2, //Z
2, //Z-twist
2, //Line
1 //Stone
};
typedef struct
{
unsigned char BlckIndex :4; //对象序号0~6
unsigned char Status :4; //每个对象当前形状0~3
unsigned char code * pPIC; //对应于图形区的指针
unsigned char x,y; //位置
}TETRIS;
TETRIS this;
char code fig[10][17]={ {0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00},//0
{0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00},
{0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00},
{0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00},
{0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00},
{0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00},
{0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00},
{0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00},
{0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00},
{0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00}};//9
void Box_Generate(void);
void Write_Box_ditu(void);
/*
初始化
while(1)
{
生成一个方块,如失败结束
while(1)
{
检测按键并移动方块
如果方块不能移动则
判断有无重复行并消除程序跳出循环
}
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -