parent
54d7a02002
commit
a4a5e454b2
@ -1,5 +0,0 @@
|
|||||||
#include "bean.h"
|
|
||||||
|
|
||||||
void Bean::ClearBean(int x, int y)
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
#include "game.h"
|
|
||||||
|
|
||||||
Game::Game()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::Load()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::Loop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
char Game::GetKey()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::Begin()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::End()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Game::PlayerMove(int dir)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::PlayerGetBean()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::PlayerGetGoldBean()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Game::PlayerMeetMonster()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::MonsterMove()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::MonsterChase()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::MonsterEscape()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::MonsterPhoenix()
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
#include "map.h"
|
|
||||||
|
|
||||||
Map::Map()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::SetFrontImg(IMAGE img)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::SetGroundImg(IMAGE img)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::SetMap(int* _map)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Map::IsMapTrueArea(int x, int y)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::DrawAllArea()
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "mover.h"
|
|
||||||
|
|
||||||
class Monster :public Mover
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
@ -1,34 +0,0 @@
|
|||||||
#include "mover.h"
|
|
||||||
|
|
||||||
Mover::Mover()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mover::SetImg(IMAGE _img)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mover::SetXY(int _x, int _y)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mover::SetSpeed(int _speed)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mover::Move(int dir)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Mover::NextMove(int dir, int& nx, int& ny)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mover::Draw()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mover::DrawClear()
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
#include "player.h"
|
|
||||||
|
|
||||||
void Player::GetBean()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::GetGoldBean()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::GetMonster()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::DrawScore()
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "mover.h"
|
|
||||||
|
|
||||||
class Player : public Mover
|
|
||||||
{
|
|
||||||
private :
|
|
||||||
int score;
|
|
||||||
|
|
||||||
public :
|
|
||||||
void GetBean();
|
|
||||||
void GetGoldBean();
|
|
||||||
void GetMonster();
|
|
||||||
|
|
||||||
void DrawScore();
|
|
||||||
};
|
|
@ -1,36 +0,0 @@
|
|||||||
#include "tool.h"
|
|
||||||
|
|
||||||
Wall Tool::ImportWall(int num)
|
|
||||||
{
|
|
||||||
return Wall();
|
|
||||||
}
|
|
||||||
|
|
||||||
Bean Tool::ImportBean(int num)
|
|
||||||
{
|
|
||||||
return Bean();
|
|
||||||
}
|
|
||||||
|
|
||||||
Player Tool::ImportPlayer(int num)
|
|
||||||
{
|
|
||||||
return Player();
|
|
||||||
}
|
|
||||||
|
|
||||||
Monster Tool::ImportMonster(int num)
|
|
||||||
{
|
|
||||||
return Monster();
|
|
||||||
}
|
|
||||||
|
|
||||||
string Tool::num2str(int num)
|
|
||||||
{
|
|
||||||
return string();
|
|
||||||
}
|
|
||||||
|
|
||||||
int Tool::str2num(string str)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* Tool::str2char(string str)
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
// 系统库
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <easyx.h>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
// 项目库
|
|
||||||
#include "define.h"
|
|
||||||
#include "wall.h"
|
|
||||||
#include "bean.h"
|
|
||||||
#include "player.h"
|
|
||||||
#include "monster.h"
|
|
||||||
|
|
||||||
class Tool
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Wall ImportWall(int num);
|
|
||||||
Bean ImportBean(int num);
|
|
||||||
Player ImportPlayer(int num);
|
|
||||||
Monster ImportMonster(int num);
|
|
||||||
|
|
||||||
string num2str(int num);
|
|
||||||
int str2num(string str);
|
|
||||||
char* str2char(string str);
|
|
||||||
|
|
||||||
};
|
|
@ -1,8 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "map.h"
|
|
||||||
|
|
||||||
class Wall: public Map
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define MAP_WIDTH 10
|
||||||
|
#define MAP_HEIGHT 10
|
||||||
|
|
||||||
|
#define DIR_NONE 0
|
||||||
|
#define DIR_UP 1
|
||||||
|
#define DIR_DOWN 2
|
||||||
|
#define DIR_LEFT 3
|
||||||
|
#define DIR_RIGHT 4
|
||||||
|
|
||||||
|
#define MONSTER_CHASE_SPEED 0.2
|
||||||
|
#define MONSTER_ESCAPE_SPEED 0.05
|
||||||
|
#define MONSTER_ESCAPE_STATUS 100
|
||||||
|
|
||||||
|
#define MAP_POINT_SIZE 10
|
@ -0,0 +1,66 @@
|
|||||||
|
#include <conio.h>
|
||||||
|
#include "game.h"
|
||||||
|
#include "define.h"
|
||||||
|
|
||||||
|
void Game::Load()
|
||||||
|
{
|
||||||
|
Start();
|
||||||
|
End(Loop());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Game::Loop()
|
||||||
|
{
|
||||||
|
char key;
|
||||||
|
int dir = DIR_NONE, last_dir;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
key = GetKey();
|
||||||
|
last_dir = dir;
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case 'p': Pause(); break;
|
||||||
|
case 'q': return false; break;
|
||||||
|
case 'w': dir = DIR_UP; break;
|
||||||
|
case 's': dir = DIR_DOWN; break;
|
||||||
|
case 'a': dir = DIR_LEFT; break;
|
||||||
|
case 'd': dir = DIR_RIGHT; break;
|
||||||
|
default: dir = last_dir; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.PlayerMove(wall, dir))
|
||||||
|
{
|
||||||
|
if (player.TryEatBean(bean))
|
||||||
|
{
|
||||||
|
if (bean.IsEmpty() && goldBean.IsEmpty())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (player.TryEatGoldBean(goldBean))
|
||||||
|
{
|
||||||
|
if (bean.IsEmpty() && goldBean.IsEmpty())
|
||||||
|
return true;
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
monster[i].SetSpeed(MONSTER_ESCAPE_SPEED);
|
||||||
|
monster[i].SetStatus(MONSTER_ESCAPE_STATUS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if (monster[i].TryEatPlayer(player))
|
||||||
|
return false;
|
||||||
|
monster[i].MonsterMove(wall, player, bean, goldBean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char Game::GetKey()
|
||||||
|
{
|
||||||
|
char key = 0;
|
||||||
|
if (_kbhit())
|
||||||
|
{
|
||||||
|
key = _getch();
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
#include "monster.h"
|
||||||
|
#include "define.h"
|
||||||
|
|
||||||
|
void Monster::MonsterMove(const Map& wall, Player player, const Map& bean, const Map& goldBean)
|
||||||
|
{
|
||||||
|
int dir;
|
||||||
|
if (status < 0)
|
||||||
|
{
|
||||||
|
dir = WaitingBorn(wall);
|
||||||
|
}
|
||||||
|
else if (status > 0)
|
||||||
|
{
|
||||||
|
dir = Escape(wall, player);
|
||||||
|
status--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dir = Chase(wall, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
Move(dir);
|
||||||
|
|
||||||
|
// 恢复绘制走过的bean和goldBean
|
||||||
|
|
||||||
|
// ....
|
||||||
|
}
|
||||||
|
|
||||||
|
int Monster::Escape(const Map& wall, Player player)
|
||||||
|
{
|
||||||
|
int dir = Chase(wall, player);
|
||||||
|
|
||||||
|
// 反向逃避即可
|
||||||
|
switch (dir)
|
||||||
|
{
|
||||||
|
case DIR_UP: dir = DIR_DOWN; break;
|
||||||
|
case DIR_DOWN: dir = DIR_UP; break;
|
||||||
|
case DIR_LEFT: dir = DIR_RIGHT; break;
|
||||||
|
case DIR_RIGHT: dir = DIR_LEFT; break;
|
||||||
|
default: dir = DIR_LEFT; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
#include "mover.h"
|
||||||
|
#include "define.h"
|
||||||
|
|
||||||
|
void Mover::Move(int dir)
|
||||||
|
{
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
#include "player.h"
|
Loading…
Reference in new issue