找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 文档 工具 设计
查看: 135|回复: 0

[分享] 迷宫小游戏源代码

[复制链接]

2万

主题

1249

回帖

2万

积分

超级版主

教育辅助界扛把子

附加身份标识
精华
1
热心
7
听众
1
威望
48
贡献
14307
违规
0
书币
49981
注册时间
2020-4-8

论坛元老灌水之王

发表于 2022-7-30 08:57 | 显示全部楼层 |阅读模式
[分享] 迷宫小游戏源代码


[C++] 纯文本查看 复制代码
#include"stdio.h"
#include"bios.h"
#include "conio.h"
#include   "dos.h"
#include
#include
#define LEFT 75        /*  左方向键的宏定义  */
#define RIGHT 77       /*  右方向键的宏定义  */
#define UPPER 72       /*  上方向键的宏定义  */
#define DOWN 80        /*  下方向键的宏定义  */
#define ESC 27         /*  ESC键的宏定义     */
void putchxy(int y,int x,char ch,char fc,char bc);
int djs()
{
int i,x=0,y=0;
printf("\n\t\t\tJu Li Tui Chu Shi Jian:");       /*游戏结束的倒记时6秒钟*/
for(i=6;i>=0;i--)
{
sleep(1);
printf("%d\b",i);
if(i==0)
exit();   /*结束时间*/
}
}
/*

void show()
{
textcolor(GREEN);
printf("\n\n\n\n\n\n\n\t\t    ");
cprintf("********************************");
printf("\n\t\t    ");               /*游戏开始界面以及判断是否进入游戏*/
cprintf("*   Huan Ying Play Mi Gong!!!  *");
printf("\n\t\t    ");
cprintf("*   Maker:Lihong               *");
printf("\n\t\t    ");
cprintf("********************************");
printf("\n\t\t    ");
cprintf("         Are You Ready          ");
printf("\n\n\t\t    ");
cprintf("              y/n               ");
}
void gameover()
{
printf("\n\n\n\n\n\n\n");
printf("\t\t    ********************************\n");
printf("\t\t    *           Game Over          *\n");
printf("\t\t    *                              *\n");       /*游戏结束的界面*/
printf("\t\t    *     Huan Ying Xia Ci Zai Wan *\n");
printf("\t\t    ********************************\n");
djs();
}
union keyboard               /*定义读取键盘码的共用体类型*/
{
int KeyIn;
char KeyBit[2];
};
int GetKey()                     /*定义读取键盘码的函数*/
{
union keyboard unKey1;                    /*定义读取键盘码的共用体变量*/
unKey1.KeyIn=bioskey(0);                                       /*读取按键信息*/
return(unKey1.KeyBit[0]==0?unKey1.KeyBit[1]:unKey1.KeyBit[0]);   /*返回ASCII码或扩
}
char far *screen=(char far* )0xb8000000;
void putchxy(int y,int x,char ch,char fc,char bc)  /*写屏函数,刚学会的*/
{
  screen[(x*160)+(y<<1)+0]=ch;
  screen[(x*160)+(y<<1)+1]=(bc*16)+fc;
}
void printwall(int x,int y)
{
    putchxy(x,y,100,GREEN,GREEN);
}

int Tong()
{
clrscr();
printf("\n\n\n\n\n\n\t\t\tGong Xi Ni Tong Guan!!!\n");
printf("\n\n\t\t\t  Chong Xin Kai Shi?\n\n\t\t\t\t   y/n  ?\n\n");        /*游戏通关界面以及判断是否继续*/
printf("\t\t\t\t    ");
if(getchar()=='Y'||getchar()=='y')
{clrscr();
Map1();
}
else
exit();
}
int Map3()                                /*第三关的地图*/
{
char Humen=2;
int Key,x=22,y=12;
int Map[20][60]={                   /*第一個[]高,第二個[]寬*/
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},/*1*/
{0,1,1,1,1,1,0,1,0,0,1,1,1,0,0,0,1,1,1,0,0,1,0,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,1,1,0,0,0,0,0,1,1,1,0,0,1,0,0,1,1,1,1,0,0},/*2*/
{0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,1,1,1,0,1,0,0,1,0,1,0,0,1,0,0,1,0,1,0,1,0,1,1,1,1,1,1,0,1,0,0,0,1,1,1,0,0,1,1,0},/*3*/
{0,1,0,1,0,1,0,1,0,0,1,0,1,0,0,1,1,0,1,1,0,0,0,0,1,1,0,1,0,1,1,1,1,0,0,1,0,1,0,1,0,1,0,0,0,1,0,1,1,1,1,1,0,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20*/
};
int i,j;
  while(1)
  {
  for(i=0;i<20;i++)
  {
   gotoxy(10,5+i);
   for(j=0;j<60;j++)
    {
     if(Map[j]==0)
     printwall(j+9,i+4);
     if(Map[j]==1)
        printf(" ");
     if(Map[j]==2)
        printf(" ");
    }

  }
  if(Map[y-5][x-10]==2)
  {
    clrscr();
    Tong();
  }
  gotoxy(x,y);
  printf("%c\b",Humen);
  Key=GetKey();
  if(Key==LEFT&&Map[y-5][x-1-10]!=0)
     x--;
  if(Key==RIGHT&&Map[y-5][x+1-10]!=0)
     x++;
  if(Key==UPPER&&Map[y-1-5][x-10]!=0)
     y--;
  if(Key==DOWN&&Map[y+1-5][x-10]!=0)
     y++;
  if(Key==ESC)
  {
    clrscr();
    gameover();
    break;
  }
  clrscr();
  }
getch();
}
int Map2()                                                              /*第二关的地图*/
{
char Humen=2;
int Key,x=11,y=6;
int Map[20][60]={                                           /*第一個[]高,第二個[]寬*/
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},/*0*/
{0,1,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0},/*2*/
{0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0},/*3*/
{2,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,0,1,1,0,1,0,1,0,0,0,1,0,1,1,1,1,1,1,1,1,0,0,1,0,1,0},/*4*/
{0,0,1,1,1,1,0,0,0,0,0,0,0,1,0,1,0,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j=0;j<60;j++)
    {
     if(Map[j]==0)
     printwall(j+9,i+4);
     if(Map[j]==1)
        printf(" ");
     if(Map[j]==2)
        printf(" ");
    }

  }
  if(Map[y-5][x-10]==2)
  {
    clrscr();
    Map3();
    exit();
  }
  gotoxy(x,y);
  printf("%c\b",Humen);
  Key=GetKey();
  if(Key==LEFT&&Map[y-5][x-1-10]!=0)
     x--;
  if(Key==RIGHT&&Map[y-5][x+1-10]!=0)
     x++;
  if(Key==UPPER&&Map[y-1-5][x-10]!=0)
     y--;
  if(Key==DOWN&&Map[y+1-5][x-10]!=0)
     y++;
  if(Key==ESC)
  {
    clrscr();
    gameover();
    break;
  }
  clrscr();
  }
getch();
}
Map1()                                                                    /*第一关的地图*/
{
char Humen=2;
int Key,x=11,y=6;                                                   /*x,y为人物移动后坐标*/
int Map[20][60]={             /*第一個[]高,第二個[]寬*/            /*用二维数组定义地图*/
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},/*1*/
{0,1,1,1,1,1,0,1,1,1,0,0,0,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0},/*2*/
{0,1,0,0,0,1,0,1,0,0,1,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,0,0,0,0,0,1,0,0,0,1,1,0,1,0,0,1,0,1,0,0,1,0,0,1,1,1,1,0,0},/*3*/
{0,1,0,1,0,1,0,1,0,0,1,0,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,1,1,0,1,0,0,1,1,0,1,0,0,1,0,0},/*4*/
{0,1,1,1,0,1,0,1,1,1,1,0,1,0,1,0,1,0,1,1,0,1,1,1,1,1,1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,1,0,1,0,0,0,0,1,1,1,1,1,0,1,0,1,0,1,0,0,1,0,1,1,0,1,1,1,0},/*13*/
{0,0,1,0,0,1,0,1,1,1,0,1,0,0,1,0,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,1,1,0,0,1,0,0,1,0,0},/*14*/
{0,1,1,1,1,1,1,1,0,1,0,1,1,0,1,0,1,1,1,1,0,0,0,0,0,1,1,0,1,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,1,1,0,0,0,1,1,1,1,0,0},/*15*/
{0,1,1,1,1,1,1,0,0,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,0,0,1,0,1,1,0,1,1,0,0,0,1,1,1,0,0,1,0,1,1,1,1,1,0,1,0,0},/*17*/
{0,1,0,0,0,0,1,0,0,1,1,1,1,0,0,0,0,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,1,0,1,0,0,1,0,0,1,1,2},/*18*/
{0,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,0,1,0,0,1,1,1,1,0,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,0,0},/*19*/
};            /*0表示墙1表示路2表示出口*/
int i,j;
  while(1)                             /*反复进行求移动的坐标运算*/
  {
  for(i=0;i<20;i++)                      /*输出新地图*/
  {
   gotoxy(10,5+i);
   for(j=0;j<60;j++)
    {
     if(Map[j]==0)
     printwall(j+9,i+4);
     if(Map[j]==1)
        printf(" ");                    /*0,1,2分别用#," "," "符号代替*/
     if(Map[j]==2)
        printf(" ");
    }

  }
  if(Map[y-5][x-10]==2)
  {                                   /*如果人的坐标和目标坐标重合就进入下一关*/
    clrscr();
    Map2();
    exit();
  }
  gotoxy(x,y);
  textcolor(YELLOW);        /*在起始(或移动后)的坐标输出人*/
  cprintf("%c\b",Humen);         /*人物用"*"号表示,并且光标退一格*/
  Key=GetKey();        /*按读取的按键信息改变坐标如果改变的坐标和0重合则不改变*/
  if(Key==LEFT&&Map[y-5][x-1-10]!=0)
     x--;
  if(Key==RIGHT&&Map[y-5][x+1-10]!=0)
     x++;
  if(Key==UPPER&&Map[y-1-5][x-10]!=0)
     y--;
  if(Key==DOWN&&Map[y+1-5][x-10]!=0)
     y++;                     /*判断按ESC键句输出结束界面并退出游戏*/
  if(Key==ESC)
  {
    clrscr();
    gameover();
    break;
  }
  clrscr();
  }
getch();
}
main()
{
show();                        /*调用游戏开始界面*/
printf("\b\b\b\b\b\b\b\b\b\b\b\b");
if(getchar()=='y')                  /*进行判断是否进入游戏*/
{clrscr();                         /*如果选y则进入游戏反之结束游戏退出*/
Map1();
}
else
exit();
}

Great works are not done by strength, but by persistence! 历尽艰辛的飞升者,成了围剿孙悟空的十万天兵之一。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则 需要先绑定手机号


免责声明:
本站所发布的第三方软件及资源(包括但不仅限于文字/图片/音频/视频等仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢某程序或某个资源,请支持正版软件及版权方利益,注册或购买,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To: admin@cdsy.xyz

QQ|Archiver|手机版|小黑屋|城东书院 ( 湘ICP备19021508号-1|湘公网安备 43102202000103号 )

GMT+8, 2024-11-21 17:19 , Processed in 0.047226 second(s), 31 queries .

Powered by Discuz! CDSY.XYZ

Copyright © 2019-2023, Tencent Cloud.

快速回复 返回顶部 返回列表