数据结构—课程设计——游戏——老鼠走迷宫

  • 7jotVDGR0a
    了解作者
  • C/C++
    开发工具
  • 72.9MB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 5 积分
    下载积分
  • 0
    下载次数
  • 2022-05-28 17:24
    上传日期
很好的C++小游戏代码可以用来学习使用c++图形界面
老鼠走迷宫3.rar
内容介绍
//==============================预制区======================================================== #include<graphics.h> #include<conio.h> #include<Windows.h> #include<iostream> #include<math.h> #include"EasyXPng.h" #include<queue> #include<stack> #define PI 3.1415926 #pragma comment(lib,"Winmm.lib") using namespace std; //===============================全局变量==================================================== IMAGE wall, wall_2, granary, granary_Png, granary2, granary2_Png, mouse_up, mouse_down, mouse_left, mouse_right, cover, cover1, cover2, cover3, cover4, cover5, cover6, cover7, mouse_right_Png, mouse_left_Png, mouse_down_Png, mouse_up_Png; int imSize = 30;//图片大小 int key = 0;//关卡数 int direction = 2;//默认方向 int bound = 0;//数组边界 int score = 0;//得分 int width = 800;//画面宽度 int deepth = 630;//画面高度 int item = 0;//item为3进入编辑模式,item = 4退出编辑模式;item = 5进入全部路径模式,item = 4退出全部路径。 int copyMap[25][25];//勿忘初心数组(找完需求路径后返还给数组原来的值) ExMessage m;//定义一个消息变量 //-------------------------------结构体------------------------------------------------- struct Player//玩家坐标 { int i; int j; }; struct Granary//粮仓坐标 { int i; int j; }; struct Granary2//粮仓坐标 { int i; int j; }; Player player; Granary granarys; Granary2 granarys2; //-------------------------------初始化的迷宫地图--------------------------------------- int map[12][25][25] = { //关卡1地图 {//21*21 {3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3}, {3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3}, {3,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3}, {3,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,3}, {3,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,3}, {3,1,0,1,0,1,1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,1,1,1,1,1,1,1,1,1,1,1,3}, {3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3}, {3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3}, {3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3}, {3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3}, {3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3}, {3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3}, {3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3}, {3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,3}, {3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3}, }, }; //================================函数区================================================ //--------------------------------图片加载函数------------------------------------------ void LoadImage() { loadimage(&mouse_up, "老鼠上1.jpg", imSize, imSize);// loadimage(&mouse_down, "老鼠下1.jpg", imSize, imSize); loadimage(&mouse_left, "老鼠左1.jpg", imSize, imSize); loadimage(&mouse_right, "老鼠右1.jpg", imSize, imSize); //========================================================================PNG loadimage(&mouse_up_Png, "老鼠上1.png", imSize, imSize); loadimage(&mouse_down_Png, "老鼠下1.png", imSize, imSize); loadimage(&mouse_left_Png, "老鼠左1.png", imSize, imSize); loadimage(&mouse_right_Png, "老鼠右1.png", imSize, imSize); loadimage(&granary_Png, "粮仓.png", imSize, imSize);//4 loadimage(&granary2_Png, "粮仓().png", imSize, imSize);//5 //========================================================================== loadimage(&granary, "粮仓.jpg", imSize, imSize);//4 loadimage(&granary2, "粮仓().jpg", imSize, imSize);//5 loadimage(&wall, "墙1.jpg", imSize, imSize); loadimage(&wall_2, "墙2.jpg", imSize, imSize); loadimage(&cover, "cover.jpg", width, deepth); loadimage(&cover1, "cover1.jpg", width, deepth); loadimage(&cover2, "cover2.jpg", width, deepth); loadimage(&cover3, "cover3.jpg", width, deepth); loadimage(&cover4, "cover4.jpg", width, deepth); loadimage(&cover5, "cover5.jpg", width, deepth); loadimage(&cover6, "cover6.jpg", width, deepth); loadimage(&cover7, "cover7.jpg", width, deepth); } //--------------------------------计时函数(效果不好已废弃)---------------------------- void Time() { TCHAR str3[20]; clock_t now; now = clock(); double duration = double(now) / CLOCKS_PER_SEC; _stprintf_s(str3, _T("剩余时间:%d秒"), int(duration)); settextstyle(30, 0, _T("隶书")); outtextxy(width - 300, deepth - 600, str3); } //--------------------------------绘制整体框架函数-------------------------------------- void Frame() { setlinecolor(GREEN); setlinestyle(30); rectangle(0, 0, 630, 800);//游戏区
评论
    相关推荐
    • WP7连连看游戏
      该源码实现一款现在很流行的一种游戏,WP7连连看游戏游戏玩法很简单,只要我们需要找到相同的两张牌用三根以内的直线连在一起就可以消除,非常好玩,并且游戏的源码比较齐全,喜欢wp游戏开发的朋友可以下载学习看...
    • H5游戏实战
      H5游戏 HTM5 游戏开发实战.pdf
    • 游戏程序游戏程序游戏程序
      游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序游戏程序
    • matador:游戏游戏游戏
      斗牛士 @sambwrs 的游戏开发中 正在使用的库慢跑卢阿瓦
    • 游戏程序设计
      使用VC6.0开发的一款游戏程序,地图无限大,人物运动及人物升级设计都有,适合初学游戏程序设计的同学,简单的尝试一些游戏代码的功能
    • 打字游戏程序
      游戏运用到了线程和集合,使用的集合是Dictionary,它用于存放存放所有运行中的线程,而游戏中出现的字母是定义了Label控件,产生随机数的方法实现的,而让字母自由落下用的timer控件,调用它的线程并对自由下落...
    • 游戏引擎剖析
      这种模块化,可伸缩和扩展的设计观念可以让游戏玩家和程序设计者深入到游戏核心,用新的模型,场景和声音创造新的游戏, 或向已有的游戏素材中添加新的东西。大量的新游戏根据已经存在的游戏引擎开发出来,而大多数...
    • 网络 游戏 引擎 游戏引擎下载
      网络 游戏 引擎 游戏引擎下载网络 游戏 引擎 游戏引擎下载网络 游戏 引擎 游戏引擎下载网络 游戏 引擎 游戏引擎下载网络 游戏 引擎 游戏引擎下载网络 游戏 引擎 游戏引擎下载网络 游戏 引擎 游戏引擎下载网络 游戏 ...
    • 乒乓球游戏
      一款不错的体育类的游戏源码,乒乓球游戏源码,我们知道体育类的游戏游戏开发中占有的比例相对少,所有大家可以参考一下吧,该游戏可以实现支持人机对战玩法,以及双人对战等,球撞击的力度跟拍子的移动的速度有关...
    • chunzhou游戏开发
      游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发游戏开发...