C++实现推箱子游戏分享!

Main:

  #include<iostream>  #include<string.h>  using namespace std;  #pragma warning (disable:4996)  #define M 10  #define N 10     //定义一个10*10地图,1表示墙,0表示空地,2表示人  //3表示箱子,4表示成功点  //1.人物可以站到成功点中,显示人  //2.箱子推入成功点后,可以推出来  //3.记录步数,显示在控制台上  //4.界面:提示(■代表墙....)/游戏开始界面  //5.最终提示全部推入,提示成功  //周围都是墙,中间都是空地  #include"Map.h"  #include"Game.h"  int main()  {   Map _map;   //_map.Init();   int map[M][N];   char filename[] = "map/map_0";   int custom = 2;   while (custom <= 5)   {   char buffer[80];   sprintf(buffer, "%s%d", filename, custom);   //连接filename和custom,以字符串保存到buffer中   strcat(buffer, ".txt");       //字符串连接   _map.ReadMapFile(map, N, buffer);   Game game;   int step = 0;   while (game.juide(map))       //游戏胜利,跳出循环   {   system("cls");   game.Drop(map, custom);   char ch = _getch();       //按键输入   step = game.Move(map, ch);   system("cls");   }   custom++;       //关卡+1   cout << "你赢了!" << endl;   cout << "共走:" << step << "步" << endl;;   system("pause");      }         return 0;  }

三、实现效果

项目目录图片

C++实现推箱子游戏

地图文件图片

C++实现推箱子游戏

实现效果

C++实现推箱子游戏

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持<计算机技术网(www.ctvol.com)!!>。

—-想了解C++实现推箱子游戏分享!全部内容且更多的C语言教程关注<计算机技术网(www.ctvol.com)!!>

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/c-cdevelopment/483241.html

(0)
上一篇 2020年11月9日
下一篇 2020年11月9日

精彩推荐