Rogue游戏有着悠久的历史,为了向经典致敬,我也打算自己编写一个类似的游戏,这次先将游戏的框架搭建起来。
编写和运行环境是linux,用到curses.h(终端图形库),编译方法:先编写Makefile,然后make,运行方法:终端下输入./rogue
Makefile:
rogue:rogue.cpp
g++ rogue.cpp -o rogue -lncurses
clean:
rm -rf *.o rogue
rogue.cpp:
#include <stdio.h>
#include <curses.h>
#define EMPTY 0
#define ME 1
#define WALL 2
static char symbol[] = {' ', '@', '#'};
static int m_w = 10;
static int m_h = 5;
static int offset_x = 5;
static int offset_y = 5;
static int map[5][10] = {
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 0, 0, 0, 0, 0, 0, 0, 0, 2,
2, 0, 0, 0, 0, 0, 0, 0, 0, 2,
2, 0, 0, 0, 0, 0, 0, 0, 0, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2
};
void drawMap()
{
for (int i = 0;i < m_w;++i)
for (int j = 0;j < m_h;&#