俄罗斯方块c语言源代码[1].c
俄罗斯方块 c语言源代码
/********************************/
/* Desc: 俄罗斯方块游戏 */
/* By: hoodlum1980 */
/* Email: jinfd@126.com */
/* Date: 2008.03.12 22:30 */
/********************************/
#include <stdio.h>
#include <bios.h>
#include <dos.h>
#include <graphics.h>
#include <string.h>
#include <stdlib.h>
#define true 1
#define false 0
#define BoardWidth 12
#define BoardHeight 23
#define _INNER_HELPER /*inner helper method */
/*Scan Codes Define*/
enum KEYCODES
{
K_ESC =0x011b,
K_UP =0x4800, /* upward arrow */
K_LEFT =0x4b00,
K_DOWN =0x5000,
K_RIGHT =0x4d00,
K_SPACE =0x3920,
K_P =0x1970
};
/* the data structure of the block */
typedef struct tagBlock
{
char c[4][4]; /* cell fill info array, 0-empty, 1-filled */
int x; /* block position cx [ 0,BoardWidht -1] */
int y; /* block position cy [-4,BoardHeight-1] */
char color; /* block color */
char size; /* block max size in width or height */
char name; /* block name (the block's shape) */
} Block;
/* game's global info */
int FrameTime= 1300;
int CellSize= 18;
int BoardLeft= 30;
int BoardTop= 30;
/* next block grid */
int NBBoardLeft= 300;
int NBBoardTop= 30;
int NBCellSize= 10;
/* score board position */
int ScoreBoardLeft= 300;
int ScoreBoardTop=100;
int ScoreBoardWidth=200;
int ScoreBoardHeight=35;
int ScoreColor=LIGHTCYAN;
/* infor text postion */
int InfoLeft=300;
int InfoTop=200;
int InfoColor=YELLOW;
int BorderColor=DARKGRAY;
int BkGndColor=BLACK;
int GameRunning=true;
int TopLine=BoardHeight-1; /* top empty line */
int TotalScore=100;
char info_score[20];
char info_help[255];
char info_common[255];
/* our board, Board[x][y][0]-isFilled, Board[x][y][1]-fillColor */
unsigned char Board[BoardWidth][BoardHeight][2];
char BufferCells[4][4]; /* used to judge if can rotate block */
Block curBlock; /* current moving block */
Block nextBlock; /* next Block to appear */
/* function list */
int GetKeyCode();
int CanMove(int dx,int dy);
int CanRotate();
int RotateBlock(Block *block);
int MoveBlock(Block *block,int dx,int dy);
void DrawBlock(Block *block,int,int,int);
void EraseBlock(Block *block,int,int,int);
void DisplayScore();
void DisplayInfo(char* text);
void GenerateBlock(Block *block);
void NextBlock();
void InitGame();
int PauseGame();
void QuitGame();
/*Get Key Code */
int GetKeyCode()
{
int key=0;
if(bioskey(1))
{
key=bioskey(0);
}
return key;
}
/* display text! */
void DisplayInfo(char *text)
{
setcolor(BkGndColor);
outtextxy(InfoLeft,InfoTop,info_common);
strcpy(info_common,text);
setcolor(InfoColor);
outtextxy(InfoLeft,I
你可能喜欢
- c语言编写小游戏
- 贪吃蛇c语言代码
- C语言游戏源代码
- 俄罗斯方块程序报告
- C语言编程图形
- 五子棋C语言源代码
- 超市收银系统
- c语言编写的小游戏代码9页
- 第2章-用c语言编写小游戏快速入门5页
- 第1章-用c语言编写小游戏快速入门2页
- 第4章-用c语言编写小游戏快速入门8页
- c语言编写的连连看小游戏6页
- c语言编写的俄罗斯方块小游戏6页
- 简单的迷宫小游戏 C语言程序源代码2页
- C语言小游戏源代码《打砖块》3页
- C语言小游戏源代码《贪吃蛇》9页
- C语言扫雷游戏源代码20页
- 最经典的C语言拼图小游戏源代码2页
- 三连棋游戏 C语言源代码 网络提供 自行修改编译通过4页
- C语言俄罗斯方块试验报告,包括源程序17页
- 《Java程序设计》实训报告——俄罗斯方块36页
- VC++俄罗斯方块程序设计报告27页
- 游戏方向实践项目报告—《俄罗斯方块》程序版8页
- c语言俄罗斯方块游戏程序设计报告33页
- c++俄罗斯方块程序实习报告17页
- C语言实现五子棋小游戏源代码2页
- C语言游戏之五子棋源代码5页
- C语言程序源代码_五子棋游戏10页
- C语言五子棋游戏源代码12页
- 五子棋游戏 C语言 代码 源代码5页
- 五子棋C语言源代码11页
- 超市收银系统3页
- 超市收银系统35页
- 超市收银系统】2页
- 爱家生活超市收银系统方案1页
- 小型超市收银系统的设计与实现 毕业设计论文46页
- 超市收银系统27页


