当前位置:首页 > 代码 > 正文

2m游戏源代码(源代码电影2)

admin 发布:2022-12-19 19:29 132


本篇文章给大家谈谈2m游戏源代码,以及源代码电影2对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

(完整word版)纯C语言写的一个小型游戏 源代码

"扫雷"小游戏C代码

#includestdio.h

#includemath.h

#includetime.h

#includestdlib.h

main( )

{char a[102][102],b[102][102],c[102][102],w;

int i,j;  /*循环变量*/

int x,y,z[999];  /*雷的位置*/

int t,s;  /*标记*/

int m,n,lei;  /*计数*/

int u,v;  /*输入*/

int hang,lie,ge,mo;  /*自定义变量*/

srand((int)time(NULL));  /*启动随机数发生器*/

leb1:  /*选择模式*/

printf("\n   请选择模式:\n   1.标准  2.自定义\n");

scanf("%d",mo);

if(mo==2)  /*若选择自定义模式,要输入三个参数*/

{do

{t=0; printf("请输入\n行数 列数 雷的个数\n");

scanf("%d%d%d",hang,lie,ge);

if(hang2){printf("行数太少\n"); t=1;}

if(hang100){printf("行数太多\n");t=1;}

if(lie2){printf("列数太少\n");t=1;}

if(lie100){printf("列数太多\n");t=1;}

if(ge1){printf("至少要有一个雷\n");t=1;}

if(ge=(hang*lie)){printf("雷太多了\n");t=1;}

}while(t==1);

}

else{hang=10,lie=10,ge=10;}  /*否则就是选择了标准模式(默认参数)*/

for(i=1;i=ge;i=i+1)  /*确定雷的位置*/

{do

{t=0; z[i]=rand( )%(hang*lie);

for(j=1;ji;j=j+1){if(z[i]==z[j]) t=1;}

}while(t==1);

}

for(i=0;i=hang+1;i=i+1)  /*初始化a,b,c*/

{for(j=0;j=lie+1;j=j+1) {a[i][j]='1'; b[i][j]='1'; c[i][j]='0';} }

for(i=1;i=hang;i=i+1)

{for(j=1;j=lie;j=j+1) {a[i][j]='+';} }

for(i=1;i=ge;i=i+1)  /*把雷放入c*/

{x=z[i]/lie+1; y=z[i]%lie+1; c[x][y]='#';}

for(i=1;i=hang;i=i+1)  /*计算b中数字*/

{for(j=1;j=lie;j=j+1)

{m=48;

if(c[i-1][j-1]=='#')m=m+1; if(c[i][j-1]=='#')m=m+1;

if(c[i-1][j]=='#')m=m+1;  if(c[i+1][j+1]=='#')m=m+1;

if(c[i][j+1]=='#')m=m+1;  if(c[i+1][j]=='#')m=m+1;

if(c[i+1][j-1]=='#')m=m+1; if(c[i-1][j+1]=='#')m=m+1;

b[i][j]=m;

}

}

for(i=1;i=ge;i=i+1)  /*把雷放入b中*/

{x=z[i]/lie+1; y=z[i]%lie+1; b[x][y]='#';}

lei=ge;  /*以下是游戏设计*/

do

{leb2:  /*输出*/

system("cls");printf("\n\n\n\n");

printf("    ");

for(i=1;i=lie;i=i+1)

{w=(i-1)/10+48; printf("%c",w);

w=(i-1)%10+48; printf("%c  ",w);

}

printf("\n   |");

for(i=1;i=lie;i=i+1){printf("---|");}

printf("\n");

for(i=1;i=hang;i=i+1)

{w=(i-1)/10+48; printf("%c",w);

w=(i-1)%10+48; printf("%c |",w);

for(j=1;j=lie;j=j+1)

{if(a[i][j]=='0')printf("   |");

else printf(" %c |",a[i][j]);

}

if(i==2)printf(" 剩余雷个数");

if(i==3)printf(" %d",lei);

printf("\n   |");

for(j=1;j=lie;j=j+1){printf("---|");}

printf("\n");

}

scanf("%d%c%d",u,w,v);  /*输入*/

u=u+1,v=v+1;

if(w!='#'a[u][v]=='@')

goto leb2;

if(w=='#')

{if(a[u][v]=='+'){a[u][v]='@'; lei=lei-1;}

else if(a[u][v]=='@'){a[u][v]='?'; lei=lei+1;}

else if(a[u][v]=='?'){a[u][v]='+';}

goto leb2;

}

a[u][v]=b[u][v];

leb3:  /*打开0区*/

t=0;

if(a[u][v]=='0')

{for(i=1;i=hang;i=i+1)

{for(j=1;j=lie;j=j+1)

{s=0;

if(a[i-1][j-1]=='0')s=1; if(a[i-1][j+1]=='0')s=1;

if(a[i-1][j]=='0')s=1;  if(a[i+1][j-1]=='0')s=1;

if(a[i+1][j+1]=='0')s=1; if(a[i+1][j]=='0')s=1;

if(a[i][j-1]=='0')s=1;  if(a[i][j+1]=='0')s=1;

if(s==1)a[i][j]=b[i][j];

}

}

for(i=1;i=hang;i=i+1)

{for(j=lie;j=1;j=j-1)

{s=0;

if(a[i-1][j-1]=='0')s=1; if(a[i-1][j+1]=='0')s=1;

if(a[i-1][j]=='0')s=1;  if(a[i+1][j-1]=='0')s=1;

if(a[i+1][j+1]=='0')s=1; if(a[i+1][j]=='0')s=1;

if(a[i][j-1]=='0')s=1;   if(a[i][j+1]=='0')s=1;

if(s==1)a[i][j]=b[i][j];

}

}

for(i=hang;i=1;i=i-1)

{for(j=1;j=lie;j=j+1)

{s=0;

if(a[i-1][j-1]=='0')s=1; if(a[i-1][j+1]=='0')s=1;

if(a[i-1][j]=='0')s=1;  if(a[i+1][j-1]=='0')s=1;

if(a[i+1][j+1]=='0')s=1; if(a[i+1][j]=='0')s=1;

if(a[i][j-1]=='0')s=1;  if(a[i][j+1]=='0')s=1;

if(s==1)a[i][j]=b[i][j];

}

}

for(i=hang;i=1;i=i-1)

{for(j=lie;j=1;j=j-1)

{s=0;

if(a[i-1][j-1]=='0')s=1; if(a[i-1][j+1]=='0')s=1;

if(a[i-1][j]=='0')s=1;  if(a[i+1][j-1]=='0')s=1;

if(a[i+1][j+1]=='0')s=1;if(a[i+1][j]=='0')s=1;

if(a[i][j-1]=='0')s=1;  if(a[i][j+1]=='0')s=1;

if(s==1)a[i][j]=b[i][j];

}

}

for(i=1;i=hang;i=i+1)  /*检测0区*/

{for(j=1;j=lie;j=j+1)

{if(a[i][j]=='0')

{if(a[i-1][j-1]=='+'||a[i-1][j-1]=='@'||a[i-1][j-1]=='?')t=1;

if(a[i-1][j+1]=='+'||a[i-1][j+1]=='@'||a[i-1][j+1]=='?')t=1;

if(a[i+1][j-1]=='+'||a[i+1][j-1]=='@'||a[i+1][j-1]=='?')t=1;

if(a[i+1][j+1]=='+'||a[i+1][j+1]=='@'||a[i+1][j+1]=='?')t=1;

if(a[i+1][j]=='+'||a[i+1][j]=='@'||a[i+1][j]=='?')t=1;

if(a[i][j+1]=='+'||a[i][j+1]=='@'||a[i][j+1]=='?')t=1;

if(a[i][j-1]=='+'||a[i][j-1]=='@'||a[i][j-1]=='?')t=1;

if(a[i-1][j]=='+'||a[i-1][j]=='@'||a[i-1][j]=='?')t=1;

}

}

}

if(t==1)goto leb3;

}

n=0;  /*检查结束*/

for(i=1;i=hang;i=i+1)

{for(j=1;j=lie;j=j+1)

{if(a[i][j]!='+'a[i][j]!='@'a[i][j]!='?')n=n+1;}

}

}

while(a[u][v]!='#'n!=(hang*lie-ge));

for(i=1;i=ge;i=i+1)  /*游戏结束*/

{x=z[i]/lie+1; y=z[i]%lie+1; a[x][y]='#'; }

printf("    ");

for(i=1;i=lie;i=i+1)

{w=(i-1)/10+48; printf("%c",w);

w=(i-1)%10+48; printf("%c  ",w);

}

printf("\n   |");

for(i=1;i=lie;i=i+1){printf("---|");}

printf("\n");

for(i=1;i=hang;i=i+1)

{w=(i-1)/10+48; printf("%c",w);

w=(i-1)%10+48; printf("%c |",w);

for(j=1;j=lie;j=j+1)

{if(a[i][j]=='0')printf(" |");

else  printf(" %c |",a[i][j]);

}

if(i==2)printf(" 剩余雷个数");

if(i==3)printf(" %d",lei); printf("\n   |");

for(j=1;j=lie;j=j+1) {printf("---|");}

printf("\n");

}

if(n==(hang*lie-ge)) printf("你成功了!\n");

else printf("    游戏结束!\n");

printf("    重玩请输入1\n");

t=0;

scanf("%d",t);

if(t==1)goto leb1;

}

/*注:在DEV c++上运行通过。行号和列号都从0开始,比如要确定第0行第9列不是“雷”,就在0和9中间加入一个字母,可以输入【0a9】三个字符再按回车键。3行7列不是雷,则输入【3a7】回车;第8行第5列是雷,就输入【8#5】回车,9行0列是雷则输入【9#0】并回车*/

跪求C++大神,只需要写一个小游戏源代码,事成有现金酬谢。

#include iostream

using namespace std;

double shengmingli=2000;//定义主角初始生命力

int gongjili=150;//定义主角初始攻击力

int fangyuli=200;//定义主角初始防御力

int money=20;//定义主角初始金钱数量

bool guoguan;//定义是否通关判定

void wuqidian();//定义武器店函数

void yaodian();//定义药店函数

void guaiwu1();//定义小怪物函数

void guaiwu2();//定义大怪物函数

int main()

{

cout"欢迎你开始玩打怪物小游戏!\n";

cout"小镇\n";

cout"一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店"endl;

cout"和一家武器店。\n";

int xiaozhen;//定义选择项目

cout"1.去武器店"endl;

cout"2.去药品店"endl;

cout"3.去打小怪物"endl;

cout"4.去打大怪物"endl;

cout"5.退出游戏"endl;

cout"6.显示你的状态"endl;

cinxiaozhen;

while(xiaozhen!=5)//输入5时退出游戏

{

if(shengmingli=0)//主角生命力小于等于0时游戏结束

{

cout"你死啦!"endl;

break;

}

if(guoguan)

{

cout"恭喜通关!"endl;

break;

}

if(xiaozhen==6)//输入6可检测自己的状态

{

cout"你的生命力:"shengmingliendl;

cout"你的攻击力:"gongjiliendl;

cout"你的防御力:"fangyuliendl;

cout"你拥有的钱:"moneyendl;

}

else

switch(xiaozhen)

{

case 1 : wuqidian();break;

case 2 : yaodian();break;

case 3 : guaiwu1();break;

case 4 : guaiwu2();break;

default : cout"请不要乱选!"endl;break;

}

cinxiaozhen;

}

if(xiaozhen==5)

{

cout"正在退出游戏……"endl;

}

cin.get();

cin.get();

return 0;

}

void wuqidian()

{

cout"欢迎来到武器店!"endl;

cout"1、买小刀(1M加2攻击力)"endl;

cout"2、买短剑(2M加20攻击力)"endl;

cout"3、买大砍刀(5M加40攻击力)"endl;

cout"4、买双节棍(7M加60攻击力)"endl;

cout"5、买盾牌(2M加30防御力)"endl;

cout"6、买铠甲(5M加60防御力)"endl;

cout"7、离开武器店"endl;

int wuqidian;

cinwuqidian;

while(wuqidian!=7)//输入7时结束函数

{

switch(wuqidian)

{

case 1 : if(money10)

cout"你的钱不够"endl;//钱不够时返回Flase

else

cout"购买成功!"endl;//钱足够时返回True

gongjili+=2;

money-=1;

break;

case 2 : if(money80)

cout"你的钱不够"endl;

else

cout"购买成功!"endl;

gongjili+=20;

money-=80;

break;

case 3 : if(money140)

cout"你的钱不够"endl;

else

cout"购买成功!"endl;

gongjili+=40;

money-=140;

break;

case 4 : if(money200)

cout"你的钱不够"endl;

else

cout"购买成功!"endl;

gongjili+=60;

money-=200;

break;

case 5 : if(money60)

cout"你的钱不够"endl;

else

cout"购买成功!"endl;

fangyuli+=30;

money-=60;

break;

fangyuli+=60;

money-=100;

break;

default : cout"无"endl;

break;

}

cinwuqidian;

}

if(wuqidian==7)

{ //返回main()主函数

cout"欢迎下次再来!"endl;

cout"欢迎你开始玩打怪物小游戏!\n";

cout"小镇\n";

cout"一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店"endl;

cout"和一家武器店。\n";

cout"1.去武器店"endl;

cout"2.去药品店"endl;

cout"3.去打小怪物"endl;

cout"4.去打大怪物"endl;

cout"5.退出游戏"endl;

cout"6.显示你的状态"endl;

}

}

/*

yaodian()的设置与wuqidian()相同,可参照阅读.

*/

void yaodian()

{

cout"欢迎来到药品店!"endl;

cout"1、买1号补血药(10M加200生命)"endl;

cout"2、买2号补血药(50M加1000生命力)"endl;

cout"3、买3号补血药(100M加2200生命力)"endl;

cout"4、离开药品店"endl;

int yaodian;

cinyaodian;

while(yaodian!=4)

{

switch(yaodian)

{

case 1 : if(money10)

cout"你的钱不够"endl;

else

cout"购买成功!"endl;

shengmingli+=200;

money-=10;

break;

case 2 : if(money50)

cout"你的钱不够"endl;

else

cout"购买成功!"endl;

shengmingli+=1000;

money-=50;

break;

case 3 : if(money100)

cout"你的钱不够"endl;

else

cout"购买成功!"endl;

shengmingli+=2200;

money-=100;

break;

default : cout"无"endl;

break;

}

cinyaodian;

}

if(yaodian==4)

{

cout"欢迎下次再来!"endl;

cout"欢迎你开始玩打怪物小游戏!\n";

cout"小镇\n";

cout"一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店"endl;

cout"和一家武器店。\n";

cout"1.去武器店"endl;

cout"2.去药品店"endl;

cout"3.去打小怪物"endl;

cout"4.去打大怪物"endl;

cout"5.退出游戏"endl;

cout"6.显示你的状态"endl;

}

}

/*这里是两个战斗函数,使用指针来处理.避免造成内存崩溃.*/

void guaiwu1()

{

cout"开始与小怪物战斗!!!"endl;

double* g_shengmingli=new double;//定义怪物生命

int* g_gongjili=new int;//定义怪物攻击力

int* g_fangyuli=new int;//定义怪物防御力

int* g_money=new int;//定义怪物金钱

*g_shengmingli=100;

*g_gongjili=5;

*g_fangyuli=3;

*g_money=5;

double* tongji1=new double;//用来计算主角对怪物的杀伤

double* tongji2=new double;//用来计算怪物对主角的杀伤

*tongji1=0;

*tongji2=0;

int* huihe=new int;//定义回合数

*huihe=1;

cout"你开始对小怪物进行攻击!"endl;

int* xuanze=new int;

/*

攻击计算公式

杀伤=攻击力*2-防御力

玩家每回合可以选择攻击与逃跑

*/

while((*g_shengmingli)0 shengmingli0 (*xuanze)!=2)

{

cout"现在是""第"*huihe"回合!"endl;

cout"请选择你的动作:\n";

cout"1、攻击\n2、逃跑\n";

cin*xuanze;

switch((*xuanze))

{

case 1 : cout"你对小怪物发动了攻击!"endl;

*g_shengmingli-=gongjili*2-(*g_fangyuli);

*tongji1=gongjili*2-(*g_fangyuli);

cout"你打掉了小怪物"*tongji1"的生命!"endl;

cout"小怪物还剩"(*g_shengmingli)-(*tongji1)"点生命"endl;

shengmingli-=(*g_gongjili)*2-fangyuli;

*tongji2=(*g_gongjili)*2-fangyuli;

cout"小怪物对你发动了攻击!"endl;

cout"小怪物打掉了你"*tongji2"的生命!"endl;

cout"你还剩"shengmingli-(*tongji2)"点生命"endl;break;

case 2 : cout"你决定逃跑!"endl;

cout"逃跑成功!"endl;continue;

default : cout"请不要乱选!"endl;

}

(*huihe)++;

}

if((*g_shengmingli)=0)

{//杀死怪物后的返回

cout"小怪物被你杀死了!你真厉害!!!"endl;

money+=(*g_money);

cout"欢迎你开始玩打怪物小游戏!\n";

cout"小镇\n";

cout"一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店"endl;

cout"和一家武器店。\n";

cout"1.去武器店"endl;

cout"2.去药品店"endl;

cout"3.去打小怪物"endl;

cout"4.去打大怪物"endl;

cout"5.退出游戏"endl;

cout"6.显示你的状态"endl;

}

else

if(shengmingli=0)

{//被怪物杀死后的返回

cout"你被小怪物杀死了!游戏结束!!!"endl;

}

else

if((*xuanze)==2)

{//逃跑的返回

cout"你逃回了小镇!"endl;

cout"欢迎你开始玩打怪物小游戏!\n";

cout"小镇\n";

cout"一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店"endl;

cout"和一家武器店。\n";

cout"1.去武器店"endl;

cout"2.去药品店"endl;

cout"3.去打小怪物"endl;

cout"4.去打大怪物"endl;

cout"5.退出游戏"endl;

cout"6.显示你的状态"endl;

}

delete g_shengmingli;

delete g_gongjili;

delete g_fangyuli;

delete g_money;

delete tongji1;

delete tongji2;

}

/*

设置均与void函数guaiwu1()相同,可参照上例阅读.

*/

void guaiwu2()

{

cout"开始与大怪物战斗!!!"endl;

double* g_shengmingli=new double;

int* g_gongjili=new int;

int* g_fangyuli=new int;

*g_shengmingli=3600;

*g_gongjili=500;

*g_fangyuli=500;

double* tongji1=new double;

double* tongji2=new double;

*tongji1=0;

*tongji2=0;

int* huihe=new int;

*huihe=1;

cout"你开始对大怪物进行攻击!"endl;

int* xuanze=new int;

while((*g_shengmingli)0 shengmingli0 (*xuanze)!=2)

{

cout"现在是""第"*huihe"回合!"endl;

cout"请选择你的动作:\n";

cout"1、攻击\n2、逃跑\n";

cin*xuanze;

switch((*xuanze))

{

case 1 : cout"你对大怪物发动了攻击!"endl;

*g_shengmingli-=gongjili*2-(*g_fangyuli);

*tongji1=gongjili*2-(*g_fangyuli);

cout"你打掉了大怪物"*tongji1"的生命!"endl;

cout"大怪物还剩"(*g_shengmingli)-(*tongji1)"点生命"endl;

shengmingli-=(*g_gongjili)*2-fangyuli;

*tongji2=(*g_gongjili)*2-fangyuli;

cout"大怪物对你发动了攻击!"endl;

cout"大怪物打掉了你"*tongji2"的生命!"endl;

cout"你还剩"shengmingli-(*tongji2)"点生命"endl;break;

case 2 : cout"你决定逃跑!"endl;

cout"逃跑成功!"endl;continue;

default : cout"请不要乱选!"endl;

}

(*huihe)++;

}

if((*g_shengmingli)=0)

{

cout"大怪物被你杀死了!你真厉害!!!"endl;

guoguan=true;

cout"欢迎你开始玩打怪物小游戏!\n";

cout"小镇\n";

cout"一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店"endl;

cout"和一家武器店。\n";

cout"1.去武器店"endl;

cout"2.去药品店"endl;

cout"3.去打小怪物"endl;

cout"4.去打大怪物"endl;

cout"5.退出游戏"endl;

cout"6.显示你的状态"endl;

}

else

if(shengmingli=0)

{

cout"你被大怪物杀死了!游戏结束!!!"endl;

}

else

if((*xuanze)==2)

{

cout"你逃回了小镇!"endl;

cout"欢迎你开始玩打怪物小游戏!\n";

cout"小镇\n";

cout"一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店"endl;

cout"和一家武器店。\n";

cout"1.去武器店"endl;

cout"2.去药品店"endl;

cout"3.去打小怪物"endl;

cout"4.去打大怪物"endl;

cout"5.退出游戏"endl;

cout"6.显示你的状态"en;

}

delete g_shengmingli;

delete g_gongjili;

delete g_fangyuli;

delete tongji1;

delete tongji2;

}

求一些C语言小游戏的源代码,谢谢

“推箱子”C代码:

#include stdio.h

#include conio.h

#includestdlib.h

#includewindows.h

int m =0;  //m代表第几关

struct maps{short a[9][11]; };

struct maps map[5]={ 0,0,0,0,0,0,0,0,0,0,0,  //共5关,每关9行11列

              0,1,1,1,1,1,1,1,0,0,0,

              0,1,0,0,0,0,0,1,1,1,0,

              1,1,4,1,1,1,0,0,0,1,0,  //0空地,1墙

               1,5,0,0,4,0,0,4,0,1,0,  //4是箱子,5是人

              1,0,3,3,1,0,4,0,1,1,0,  //3是目的地

              1,1,3,3,1,0,0,0,1,0,0,  //7是箱子在目的地(4+3)

              0,1,1,1,1,1,1,1,1,0,0,  //8是人在目的地(5+3)

                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,0,0,0,0,0,

              0,0,1,5,0,1,1,1,0,0,0,

              0,0,1,0,4,0,0,1,0,0,0,

               0,1,1,1,0,1,0,1,1,0,0,

              0,1,3,1,0,1,0,0,1,0,0,

              0,1,3,4,0,0,1,0,1,0,0,

              0,1,3,0,0,0,4,0,1,0,0,

                0,1,1,1,1,1,1,1,1,0,0,

                0,0,0,0,0,0,0,0,0,0,0,

              0,0,0,1,1,1,1,1,1,1,0,

              0,0,1,1,0,0,1,0,5,1,0,

              0,0,1,0,0,0,1,0,0,1,0,

               0,0,1,4,0,4,0,4,0,1,0,

              0,0,1,0,4,1,1,0,0,1,0,

              1,1,1,0,4,0,1,0,1,1,0,

              1,3,3,3,3,3,0,0,1,0,0,

                1,1,1,1,1,1,1,1,1,0,0,

                0,1,1,1,1,1,1,1,1,1,0,

              0,1,0,0,1,1,0,0,0,1,0,

              0,1,0,0,0,4,0,0,0,1,0,

              0,1,4,0,1,1,1,0,4,1,0,

               0,1,0,1,3,3,3,1,0,1,0,

              1,1,0,1,3,3,3,1,0,1,1,

              1,0,4,0,0,4,0,0,4,0,1,

              1,0,0,0,0,0,1,0,5,0,1,

                1,1,1,1,1,1,1,1,1,1,1,

                0,0,0,0,0,0,0,0,0,0,0,

              0,0,0,1,1,1,1,1,1,0,0,

              0,1,1,1,0,0,0,0,1,0,0,

              1,1,3,0,4,1,1,0,1,1,0,

               1,3,3,4,0,4,0,0,5,1,0,

              1,3,3,0,4,0,4,0,1,1,0,

              1,1,1,1,1,1,0,0,1,0,0,

              0,0,0,0,0,1,1,1,1,0,0,

               0,0,0,0,0,0,0,0,0,0,0 };

void DrMap( )  //绘制地图

{ CONSOLE_CURSOR_INFO cursor_info={1,0};   //隐藏光标的设置

SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),cursor_info);

printf("\n\n \t\t\b推箱子");

printf("\n \t");

for (int i = 0; i 9; i++)

{for (int j = 0; j 11; j++)

{switch (map[m].a[i][j])

{case 0:  printf("  "); break;

case 1:  printf("■"); break;

      case 3:  printf("◎");break;

case 4:  printf("□"); break;

case 5:  printf("♀"); break;   //5是人

case 7:  printf("□"); break;  //4 + 3箱子在目的地中

case 8:  printf("♀");break;   // 5 + 3人在目的地中

}

}

printf("\n\t");

}

}

void gtxy(int x, int y)  //控制光标位置的函数

{ COORD coord;

coord.X = x;

coord.Y = y;

SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);

}

void start( )  //开始游戏

{ int r, c;  //人的下标

for (int i = 0; i 9; i++)

{ for (int j = 0; j 11; j++)

{if (map[m].a[i][j] == 5||map[m].a[i][j]==8) { r = i;  c = j; } } //i j 人的下标

}

char key;

key = getch( );

switch (key)

{case 'W':

case 'w':

case 72:

if (map[m]. a[r - 1][c] == 0|| map[m]. a [r - 1][c] == 3)

{ gtxy(2*c+8,r-1+3); printf("♀");  // gtxy(2*c+8,r-1+3)是到指定位置输出字符

       if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf("  "); }

       if(map[m]. a[r ][c] == 8){gtxy(2*c+8,r+3); printf("◎");}

        map[m]. a [r - 1][c] += 5;  map[m]. a [r][c] -= 5; }

     else  if (map[m]. a [r - 1][c] == 4 || map[m]. a [r - 1][c] == 7)

{ if (map[m]. a [r - 2][c] == 0 || map[m]. a [r - 2][c] == 3)

{ gtxy(2*c+8,r-2+3); printf("□"); gtxy(2*c+8,r-1+3); printf("♀");

           if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf("  "); }

          if(map[m]. a[r ][c] == 8){gtxy(2*c+8,r+3); printf("◎");}

          map[m]. a [r - 2][c] += 4;  map[m]. a [r - 1][c] += 1;

 map[m]. a [r][c] -= 5; }

} break;

case 'S':

case 's':

case 80:

if (map[m]. a [r + 1][c] == 0 || map[m]. a [r + 1][c] == 3)

 { gtxy(2*c+8,r+1+3); printf("♀");

         if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf("  "); }

        if(map[m]. a[r ][c] == 8){gtxy(2*c+8,r+3); printf("◎");}

        map[m]. a [r + 1][c] += 5;  map[m]. a [r][c] -= 5; }

       else if (map[m]. a [r + 1][c] == 4 || map[m]. a [r+ 1][c] == 7)

  { if (map[m]. a [r + 2][c] == 0 || map[m]. a [r + 2][c] == 3)

{ gtxy(2*c+8,r+2+3); printf("□"); gtxy(2*c+8,r+1+3); printf("♀");

           if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf("  "); }

           if(map[m]. a[r ][c] == 8){gtxy(2*c+8,r+3); printf("◎");}

           map[m]. a [r + 2][c] += 4; map[m]. a [r + 1][c] += 1;

map[m]. a [r][c] -= 5; }

  }break;

case 'A':

case 'a':

case 75:

if (map[m]. a [r ][c - 1] == 0 || map[m]. a [r ][c - 1] == 3)

 { gtxy(2*(c-1)+8,r+3); printf("♀");

        if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf("  "); }

         if(map[m]. a[r ][c] == 8){gtxy(2*c+8,r+3); printf("◎");}

        map[m]. a [r ][c - 1] += 5; map[m]. a [r][c] -= 5; }

else if (map[m]. a [r][c - 1] == 4 || map[m]. a [r][c - 1] == 7)

 {if (map[m]. a [r ][c - 2] == 0 || map[m]. a [r ][c - 2] == 3)

{ gtxy(2*(c-2)+8,r+3); printf("□"); gtxy(2*(c-1)+8,r+3); printf("♀");

           if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf("  "); }

           if(map[m]. a[r ][c] == 8){gtxy(2*c+8,r+3); printf("◎");}

           map[m]. a [r ][c - 2] += 4; map[m]. a [r ][c - 1] += 1;

map[m]. a [r][c] -= 5; }

 }break;

case 'D':

case 'd':

case 77:

if (map[m]. a [r][c + 1] == 0 || map[m]. a [r][c + 1] == 3)

 { gtxy(2*(c+1)+8,r+3); printf("♀");

         if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf("  "); }

         if(map[m]. a[r ][c] == 8) {gtxy(2*c+8,r+3); printf("◎");}

        map[m]. a [r][c + 1] += 5;  map[m]. a [r][c] -= 5; }

else if (map[m]. a [r][c + 1] == 4 || map[m]. a [r][c + 1] == 7)

 { if (map[m]. a [r][c + 2] == 0 || map[m]. a [r][c + 2] == 3)

{ gtxy(2*(c+2)+8,r+3); printf("□"); gtxy(2*(c+1)+8,r+3); printf("♀");

           if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf("  "); }

          if(map[m]. a[r ][c] == 8){gtxy(2*c+8,r+3); printf("◎");}

          map[m]. a [r][c + 2] += 4; map[m]. a [r][c + 1] += 1;

 map[m]. a [r][c] -= 5; }

 }break;

}

}

int ifwan( )  //是否完成(1是0否)

{ if(m==0){if(map[m].a[5][2]==7 map[m].a[5][3]==7

map[m].a[6][2]==7 map[m].a[6][3]==7) return 1;}

if(m==1){if(map[m].a[5][2]==7 map[m].a[6][2]==7

map[m].a[7][2]==7) return 1;}

if(m==2){if(map[m].a[7][1]==7 map[m].a[7][2]==7 map[m].a[7][3]==7

map[m].a[7][4]==7 map[m].a[7][5]==7) return 1;}

if(m==3){if(map[m].a[4][4]==7 map[m].a[4][5]==7 map[m].a[4][6]==7

map[m].a[5][4]==7 map[m].a[5][5]==7 map[m].a[5][6]==7) return 1;}

if(m==4){if(map[m].a[3][2]==7 map[m].a[4][1]==7 map[m].a[4][2]==7

map[m].a[5][1]==7 map[m].a[5][2]==7) return 1;}

return 0;

}

int main( )  //主函数

{ while (1)

     { system("cls");

       DrMap( );

      while (1)

            { start( );

              if(ifwan()){printf("\007");break;} //完成后响铃

           }

       m+=1;

     }

  return 0;

}

什么软件可以看到游戏的源代码

一般来说,游戏都是进行过编译,加密的无法看到源代码。

如果你想查看的游戏是开源的,可以到游戏的开源网站进行查看。

一般来说,源代码的大小和实际软件的大小是不一致的。

例如我们使用的谷歌浏览器,看上去只有十几兆的大小。

但是压缩的源代码有2个多G,解压之后接近10G的大小。

如果你有16G以上内存,进行编译大概需要1个多小时。

实际上一般来说,游戏是不会进行开源的。

因为开源会让很多程序达人发现游戏中的漏洞,加以利用。

如果我的回答能够帮助到你,希望能采纳我的回答。

游戏软件怎么查看源代码?

游戏都是进行过编译,加密的无法看到源代码。如果你想查看的游戏是开源的,可以到游戏的开源网站进行查看。

查看APP应用的源代码的具体方法步骤如下:

1、首先在电脑内下载并安装获取网页源码app。

2、然后单击打开网页源码APP并在APP中的输入框内输入想要查看的网址,再在界面内找到GO选项单并单击。

3、单击后等待APP最后加载3秒就可以成功的获取APP源代码并查看了。

Android 系统源代码多大

是指sdk的源码,还是android操作系统的源码,不过都有10G左右,另外sdk的源码是用git管理的,一次下载后,用git check就可以切换到各个版本。

Android SDK是用于开发Android上JAVA应用程序的,另外发布Android NDK,可以添加一些C语言写的链接库,至于Linux代码,可以在Android源代码中找到(SDK程序中只有编译好的测试映像)。

应用程序开发用不到Linux代码(搞嵌入式开发才会用到,而SDK不负责底层开发)。

2m游戏源代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于源代码电影2、2m游戏源代码的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/20469.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载