first commit

master
bridgeL 6 years ago
commit 54d7a02002

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29318.209
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project4", "Project4\Project4.vcxproj", "{88B6082D-DD58-4BA5-B4C0-82CA75B9A262}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{88B6082D-DD58-4BA5-B4C0-82CA75B9A262}.Debug|x64.ActiveCfg = Debug|x64
{88B6082D-DD58-4BA5-B4C0-82CA75B9A262}.Debug|x64.Build.0 = Debug|x64
{88B6082D-DD58-4BA5-B4C0-82CA75B9A262}.Debug|x86.ActiveCfg = Debug|Win32
{88B6082D-DD58-4BA5-B4C0-82CA75B9A262}.Debug|x86.Build.0 = Debug|Win32
{88B6082D-DD58-4BA5-B4C0-82CA75B9A262}.Release|x64.ActiveCfg = Release|x64
{88B6082D-DD58-4BA5-B4C0-82CA75B9A262}.Release|x64.Build.0 = Release|x64
{88B6082D-DD58-4BA5-B4C0-82CA75B9A262}.Release|x86.ActiveCfg = Release|Win32
{88B6082D-DD58-4BA5-B4C0-82CA75B9A262}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0B99F3F3-805C-4132-BE71-BAB45C040DDE}
EndGlobalSection
EndGlobal

@ -0,0 +1,9 @@
#include "game.h"
int main()
{
Game game;
game.Load();
return 0;
}

@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{88B6082D-DD58-4BA5-B4C0-82CA75B9A262}</ProjectGuid>
<RootNamespace>Project4</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="APP.cpp" />
<ClCompile Include="bean.cpp" />
<ClCompile Include="game.cpp" />
<ClCompile Include="map.cpp" />
<ClCompile Include="mover.cpp" />
<ClCompile Include="player.cpp" />
<ClCompile Include="tool.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="bean.h" />
<ClInclude Include="define.h" />
<ClInclude Include="game.h" />
<ClInclude Include="map.h" />
<ClInclude Include="monster.h" />
<ClInclude Include="mover.h" />
<ClInclude Include="player.h" />
<ClInclude Include="tool.h" />
<ClInclude Include="wall.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="APP.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="mover.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="player.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="map.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="bean.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="tool.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="game.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="game.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="mover.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="tool.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="bean.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="define.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="player.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="wall.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="map.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="monster.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

@ -0,0 +1,5 @@
#include "bean.h"
void Bean::ClearBean(int x, int y)
{
}

@ -0,0 +1,10 @@
#pragma once
#include "map.h"
class Bean: public Map
{
public:
// 清除玩家在坐标(xy)上拾取到的豆子
void ClearBean(int x, int y);
};

@ -0,0 +1,22 @@
#pragma once
#define MOVER_WIDTH 50
#define MOVER_HEIGHT 50
#define DIR_NONE 0
#define DIR_UP 1
#define DIR_DOWN 2
#define DIR_LEFT 3
#define DIR_RIGHT 4
// 实际宽度为 28*50 高度为 30*50
#define MAP_WIDTH 28
#define MAP_HEIGHT 30
// 游戏界面的宽度
#define GAME_WIDTH 1400
#define GAME_HEIGHT 1800
// 展示分数的区域
#define SCORE_X 10
#define SCORE_Y 1600

@ -0,0 +1,60 @@
#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()
{
}

@ -0,0 +1,61 @@
#pragma once
// 系统库
#include <easyx.h>
// 项目库
#include "define.h"
#include "tool.h"
#include "wall.h"
#include "bean.h"
#include "player.h"
#include "monster.h"
class Game
{
private:
Wall wall;
Bean bean, goldBean;
Player p;
Monster m[4];
public:
Game();
void Load();
// 游戏主体循环
void Loop();
// 非阻塞获取键盘输入
char GetKey();
// 游戏开始、结束菜单
void Begin();
void End();
// 调用 p, wall 判断玩家这次移动是否会遇到墙,实现玩家的移动
// 若玩家移动失败(如撞墙), 返回false否则为true
bool PlayerMove(int dir);
// 调用 p, bean判断玩家这次移动是否能吃到豆子实现玩家吃豆子
void PlayerGetBean();
// 调用 p, goldBean判断玩家这次移动是否能吃到金豆子实现玩家吃金豆子
void PlayerGetGoldBean();
// 调用 p, m[4] 判断玩家是否会遇到怪物,并根据怪物状态,实现玩家吃怪物或怪物吃玩家,
// 若怪物吃掉玩家, 返回false否则为true
bool PlayerMeetMonster();
// 调用 p, m[4], wall 实现怪物移动
void MonsterMove();
// 怪物移动有三种方式
// 追逐玩家
void MonsterChase();
// 逃避玩家
void MonsterEscape();
// 返回重生区
void MonsterPhoenix();
};

@ -0,0 +1,26 @@
#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()
{
}

@ -0,0 +1,27 @@
#pragma once
// 系统库
#include <easyx.h>
// 项目库
#include "define.h"
class Map
{
protected:
IMAGE front, ground; // 前景(true)元素图案,后景(false)元素图案
bool map[MAP_WIDTH][MAP_HEIGHT];
public:
Map();
void SetFrontImg(IMAGE img);
void SetGroundImg(IMAGE img);
void SetMap(int* _map);
// 判断玩家或者怪物在xy坐标是否在map为true的区域内
bool IsMapTrueArea(int x, int y);
// 画出所有的区域
void DrawAllArea();
};

@ -0,0 +1,9 @@
#pragma once
#include "mover.h"
class Monster :public Mover
{
};

@ -0,0 +1,34 @@
#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()
{
}

@ -0,0 +1,34 @@
#pragma once
// 系统库
#include <easyx.h>
// 项目库
#include "define.h"
#include "wall.h"
class Mover
{
protected :
IMAGE img; // 图像
int x, y; // 坐标 列、行
int speed; // 移动速度
public :
Mover();
void SetImg(IMAGE _img);
void SetXY(int _x, int _y);
void SetSpeed(int _speed);
// 按dir方向移动这个操作仅仅是根据dir改变mover的坐标并没有考虑撞墙的问题
// 要想规避撞墙请完善game类里的玩家移动函数
// 以及、、清除残影。。也请完善game类里的玩家移动函数。。
void Move(int dir);
// 返回 按dir方向移动下一次的坐标
void NextMove(int dir,int& nx, int& ny);
void Draw(); // 在当前坐标画出自己图像
void DrawClear(); // 在当前坐标清除自己图像
};

@ -0,0 +1,17 @@
#include "player.h"
void Player::GetBean()
{
}
void Player::GetGoldBean()
{
}
void Player::GetMonster()
{
}
void Player::DrawScore()
{
}

@ -0,0 +1,16 @@
#pragma once
#include "mover.h"
class Player : public Mover
{
private :
int score;
public :
void GetBean();
void GetGoldBean();
void GetMonster();
void DrawScore();
};

@ -0,0 +1,36 @@
#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;
}

@ -0,0 +1,31 @@
#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);
};

@ -0,0 +1,8 @@
#pragma once
#include "map.h"
class Wall: public Map
{
};
Loading…
Cancel
Save