基于linux环境下扫雷应用程序
《网络操作系统》报告
(应用程序开发)
题 目: 基于linux平台GCC环境下扫雷应用程 序开发 姓 名: 李磊 学 院: 理学院 专 业: 网络工程 班 级: 092 学 号: 1887090211 2012 年 01月 01 日
基于Linux平台GCC环境下扫雷应用程序开发
1 应用程序功能
通过模拟windows系统中的扫雷应用程序,在linux平台gcc环境下实现C语言扫雷应用程序。
2 硬件平台
内存2.0G,硬盘320G,CPU Pentium 4以上PC机一台
3 软件平台
3.1 操作系统平台
linux cygwin环境
3.2 应用软件平台(黑体小四号)
Visual C++ 6.0或其他C语言编译程序,linux cygwin环境,GCC编译条件
3.3 应用程序
// header file
#include
#include
#include
#include
#include
// defines
#define KEY_UP 0xE048
#define KEY_DOWN 0xE050
#define KEY_LEFT 0xE04B
#define KEY_RIGHT 0xE04D
#define KEY_ESC 0x001B
#define KEY_1 '1'
#define KEY_2 '2'
#define KEY_3 '3'
#define GAME_MAX_WIDTH 100
#define GAME_MAX_HEIGHT 100
// Strings Resource
#define STR_GAMETITLE "程序说明: 数字键1打开 \
数字键2标记 数字键3打开附近盒子"
#define STR_GAMEWIN "亲,祝贺你赢了哦,再接再厉哦!\n"
#define STR_GAMEOVER "亲,你咋那么笨呢?挂了吧!\n"
#define STR_GAMEEND " 亲,按 ESC 键退出程序\n"
//-------------------------------------------------------------
// Base class
class CConsoleWnd
{
public:
static int TextOut(const char*);
static int GotoXY(int, int);
static int CharOut(int, int, const int);
static int TextOut(int, int, const char*);
static int GetKey();
public:
};
//{{// class CConsoleWnd
//
// int CConsoleWnd::GetKey()
// Wait for standard input and return the KeyCode
//
int CConsoleWnd::GetKey()
{
int nkey=getch(),nk=0;
if(nkey>=128||nkey==0)nk=getch();
return nk>0?nkey*256+nk:nkey;
}
//
// int CConsoleWnd::GotoXY(int x, int y)
// Move cursor to (x,y)
// Only Console Application
//
int CConsoleWnd::GotoXY(int x, int y)
{
COORD cd;
cd.X = x;cd.Y = y;
return SetConsoleCursorPo