话不多说,新增人机

玩家 1号 2号
移动 w跳ad左右移动 ↑跳←→左右移动
攻击 s
掷药 空格 0
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cstdio>
#include <cctype>
#include <string>
#include <vector>
#include <conio.h>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <sstream>
#include <utility>
#include <iostream>
#include <algorithm>
#include <windows.h>
using namespace std;const int M = 15, N = 105;
int mapp[N][M];
string s[M] = { "" , "冰冻状态" , "混淆状态" , "黑暗状态" , "漂浮状态" };int num;
bool rule_attact , rule_poison , rule_lava , rule_AI;
int lava_position , lava_down_time;
int AI_move_time;struct player {bool on;int x , y;int if_jump;int effect[M];int numm;int direction;int affect;int st , timee;bool survive;
}a[M]; void map_reset ( ) {lava_position = -5;lava_down_time = 0;num = 1;for ( int i = 1 ; i <= 100 ; i += 3 ) {for ( int j = 1 ; j <= 10 ; j ++ ) mapp[i][j] = 1;mapp[i + 1][1] = mapp[i + 1][10] = mapp[i + 2][1] = mapp[i + 2][10] = 1;mapp[i][rand () % 8 + 2] = 0;}for ( int j = 1 ; j <= 10 ; j ++ ) {mapp[100][j] = 1;}
}void player_reset ( ) {a[2].on = 0;a[1].x = a[2].x = a[3].x = 3;a[1].y = a[2].y = a[3].y = 2;a[1].if_jump = a[2].if_jump = 0;a[1].direction = a[2].direction = 1;a[1].affect = a[2].affect = a[3].affect = 0;a[1].numm = a[2].numm = a[3].numm =  0;a[1].st = a[2].st = 0;a[2].on = false;a[1].survive = a[2].survive = a[3].survive = true;for ( int i = 1 ; i <= 10 ; i ++) a[1].effect[i] = a[2].effect[i] = a[3].effect[i] = 0;
}void put_map ( ) {for ( int i = -3 ; i <= 3 ; i ++ ) {for ( int j = 1 ; j <= 10 ; j ++ ) {if ( i == 0 && j == a[1].y ) printf ( "○" );else if ( a[1].x + i <= lava_position ) printf ( "▓" );else if ( a[1].effect[3] > clock () ) printf("**");else if ( a[1].x + i == a[2].x && j == a[2].y && a[2].on ) printf ( "●" );else if ( a[1].x + i == a[3].x && j == a[3].y && rule_AI ) printf ( "▲" );else if ( mapp[a[1].x + i][j] == 1 ) printf ( "█" );else if ( mapp[a[1].x + i][j] == 2 ) printf ( "☆" );else printf( "  " );}printf( "    " );if ( a[2].on ) {for ( int j = 1 ; j <= 10 ; j ++ ) {if ( i == 0 && j == a[2].y ) printf ( "●" );else if ( a[2].x + i <= lava_position ) printf ( "▓" );else if ( a[2].effect[3] > clock () ) printf("**");else if ( a[2].x + i == a[1].x && j == a[1].y ) printf ( "○" );else if ( a[2].x + i == a[3].x && j == a[3].y && rule_AI ) printf ( "▲" );else if ( mapp[a[2].x + i][j] == 1 ) printf ( "█" );else if ( mapp[a[2].x + i][j] == 2 ) printf ( "☆" );else printf ( "  " );} }printf ( "\n" );}for ( int i = 1 ; i <= 10 ; i ++ ) {if ( a[1].effect[i] > clock () ) {cout << s[i] << "                ";}else cout << "                        ";if ( a[2].effect[i] > clock () && a[2].on ) {cout << s[i];}cout << endl;}if ( rule_poison ) {printf ( "药水:%2d" , a[1].affect);if ( a[2].on ) printf ("                  药水:%2d" , a[2].affect );printf ( "\n" );}if ( num != 1) {printf ( "圈数:%2d" , a[1].numm);if ( a[2].on ) printf ("                  圈数:%2d" , a[2].numm );printf ( "\n" );}printf ( "层数:%2d" , a[1].x / 3 );if ( a[2].on ) printf ("                  层数:%2d" , a[2].x / 3 );printf ( "\n" );printf ( "用时:%2dmin%2ds%dms" , ( a[1].st == 0 ? 0 : (a[1].numm == num ? a[1].timee : clock () - a[1].st ) ) / 60000 , ( a[1].st == 0 ? 0 : (a[1].numm == num ? a[1].timee : clock () - a[1].st ) ) % 60000 / 1000 , ( a[1].st == 0 ? 0 : (a[1].numm == num ? a[1].timee : clock () - a[1].st ) ) % 1000);if ( a[2].on ) printf ("    用时:%2dmin%2ds%dms" , (a[2].st == 0 ? 0 : (a[2].numm == num ? a[2].timee : clock () - a[2].st ) ) / 60000 , ( a[2].st == 0 ? 0 : (a[2].numm == num ? a[2].timee : clock () - a[2].st ) ) % 60000 / 1000 , ( a[2].st == 0 ? 0 : (a[2].numm == num ? a[2].timee : clock () - a[2].st ) ) % 1000 );if ( rule_AI ) {printf ( "\n" );printf ( "人机:\n" );for ( int i = 1 ; i <= 10 ; i ++ ) {if ( a[3].effect[i] > clock () ) {cout << s[i] << endl;}}if ( rule_poison )  printf ( "药水:%d\n" , a[3].affect );if ( num != 1 )printf ( "圈数:%d\n" , a[3].numm );printf ( "层数:%d\n" , a[3].x / 3 );printf ( "用时:%d分%d秒%d毫秒\n" , ( a[3].numm == num ? a[3].timee : ( clock ( ) - a[3].st ) ) / 60000 , ( a[3].numm == num ? a[3].timee : ( clock ( ) - a[3].st ) ) % 60000 / 1000 , ( a[3].numm == num ? a[3].timee : ( clock ( ) - a[3].st ) ) % 1000 );}
}void move ( ) {if ( kbhit() ) {char c = getch ();if ( a[1].effect[1] <= clock () ) {if ( a[1].effect[2] > clock () && ( c == 'a' || c == 'd' ) ) c = time (0) % 2 == 1 ? 'd' : 'a';if ( c == 'a' && a[1].y != 2 ) a[1].y -- , a[1].direction = -1;if ( c == 'd' && a[1].y != 9 ) a[1].y ++ , a[1].direction = 1;if ( c == 'w' && a[1].x % 3 == 0 ) {a[1].if_jump = clock() + 100;}if ( c == 's' && rule_attact && a[1].y + a[1].direction == a[2].y && a[2].y + a[1].direction != 1 && a[2].y + a[1].direction != 10 ) a[2].y += a[1].direction;}if ( c == -32 && a[2].effect[1] <= clock () ) {c = getch();if ( a[2].effect[2] > clock () && ( c == 75 || c == 77 ) ) c = time (0) % 2 == 1 ? 77 : 75;if ( c == 75 && a[2].y != 2 ) a[2].y -- , a[2].direction = -1;if ( c == 77 && a[2].y != 9 ) a[2].y ++ , a[2].direction = 1;if ( c == 72 && a[2].x % 3 == 0 ) {a[2].if_jump = clock() + 100;}if ( c == 80 && rule_attact && a[2].y + a[2].direction == a[1].y && a[1].y + a[2].direction != 1 && a[1].y + a[2].direction != 10 ) a[1].y += a[2].direction;}if ( c == ' ' && a[ 1 ].affect > 0) {a[ 1 ].affect --;if ( rule_AI ) {if ( a[ 2 ].on ) a[ rand ( ) % 2 + 2 ].effect[ rand () % 4 + 1 ] = clock ( ) + 3000;else a[ 3 ].effect[ rand () % 4 + 1 ] = clock ( ) + 3000;}else {a[ 2 ].effect[ rand () % 4 + 1 ] = clock ( ) + 3000;}} if ( c == '0' && a[ 2 ].affect > 0) {a[2].affect --;if ( rule_AI ) a[ rand () % 2 * 2 + 1 ].effect[rand () % 4 + 1] = clock() + 3000;else a[ 1 ].effect[rand () % 4 + 1] = clock() + 3000;} }if ( a[1].if_jump > clock() || a[1].effect[4] > clock() ) {if ( mapp[a[1].x - 1][a[1].y] != 1 && a[1].x > -1 )a[1].x --;}else if ( mapp[a[1].x + 1][a[1].y] != 1 )a[1].x ++;if ( a[2].if_jump > clock() || a[2].effect[4] > clock() ) {if ( mapp[a[2].x - 1][a[2].y] != 1 && a[2].x > -1 )a[2].x --;}else if ( mapp[a[2].x + 1][a[2].y] != 1 )a[2].x ++;
}int found ( ) {for ( int i = 2 ; i <= 9 ; i ++ ) {if ( mapp[a[ 3 ].x + ( a[ 3 ].x % 3 == 1 ? 3 : ( a[3].x % 3 == 2 ? 2 : 1 ) ) ][ i ] == 0 ) return i < a[ 3 ].y ? -1 : ( i == a[ 3 ].y ? 0 : 1 );;}
}void AI_move ( ) {if ( !a[ 3 ].survive ) return ;if ( AI_move_time <= clock ( ) && a[3].effect[1] < clock ( ) ) {if ( a[3].effect[2] > clock ( ) || a[3].effect[3] > clock ( ) ) {a[3].y += rand ( ) % 3 - 1;a[3].y = a[3].y == 0 ? 1 : a[3].y;a[3].y = a[3].y == 10 ? 9 : a[3].y;}elsea[3].y += found ( );}if ( a[3].if_jump > clock() || a[3].effect[4] > clock() ) {if ( mapp[a[3].x - 1][a[3].y] != 1 && a[3].x > -1 )a[3].x --;}else if ( mapp[a[ 3 ].x + 1][a[ 3 ].y] != 1 )a[ 3 ].x ++;if ( a[ 3 ].affect > 0 ) {a[ 3 ].affect --;if ( a[ 2 ].on )a[ rand ( ) % 2 + 1 ].effect[ rand ( ) % 4 + 1 ] = clock ( ) + 3000;else a[ 1 ].effect[ rand ( ) % 4 + 1 ] = clock ( ) + 3000;}
}void run ( ) {int t = clock () + 1000;bool flag_ = true , flag__ = true;if ( rule_lava ) lava_down_time = clock () + 300;a[3].st = clock ( );while ( ( a[1].numm < num || ( a[2].numm < num && a[2].on ) || (a[3].numm < num && rule_AI ) ) && ( a[1].survive || a[2].survive || a[3].survive ) ) {if ( clock () > lava_down_time && lava_down_time != 0) lava_position ++ , lava_down_time = clock () + rand () % 50 * 10;if ( t <= clock () && rule_poison ) {mapp[rand () % 34 * 3][rand () % 8 + 2] = 2;t = clock () + 5000;}if ( flag_ && ( a[1].x != 3 || a[1].y != 2 ) ) a[1].st = clock () , flag_ = false;if ( flag__ && ( a[2].x != 3 || a[2].y != 2 ) ) a[2].st = clock () , flag__ = false;put_map ();move ();if ( mapp[a[1].x][a[1].y] == 2 ) a[1].affect ++ , mapp[a[1].x][a[1].y] = 0;if ( mapp[a[2].x][a[2].y] == 2 ) a[2].affect ++ , mapp[a[2].x][a[2].y] = 0;if ( mapp[a[3].x][a[3].y] == 2 ) a[3].affect ++ , mapp[a[3].x][a[3].y] = 0;Sleep (100);system ( "cls" );if ( a[1].x <= lava_position ) a[1].effect[1] = 2147483647 , a[1].survive = false;if ( a[2].x <= lava_position ) a[2].effect[1] = 2147483647 , a[2].survive = false;if ( a[3].x <= lava_position ) a[3].effect[1] = 2147483647 , a[3].survive = false;if ( a[ 1 ].x == 99 ) {a[ 1 ].numm ++;a[ 1 ].x = 0;if ( a[ 1 ].numm == num ) a[ 1 ].timee = clock () - a[ 1 ].st;}if ( a[ 2 ].x == 99 ) {a[ 2 ].numm ++;a[ 2 ].x = 0;if ( a[ 2 ].numm == num ) a[ 2 ].timee = clock () - a[ 2 ].st;}if ( a[ 3 ].x == 99 ) {a[ 3 ].numm ++;a[ 3 ].x = 0;if ( a[ 3 ].numm == num ) a[ 3 ].timee = clock () - a[ 3 ].st;}if ( AI_move_time < clock ( ) && a[ 3 ].numm < num ) {AI_move ( );AI_move_time = clock ( ) + 140;}}if (rule_lava) {if ( a[ 1 ].numm == 1 ) printf ( "1号成功逃脱 " );if ( a[ 2 ].numm == 1 && a[ 2 ].on ) printf ( "2号成功逃脱" );if ( a[ 3 ].numm == 1 && rule_AI ) printf ( "3号成功逃脱" );}else if ( rule_AI || a[2].on ) {int index;int time_min;index = ( a[1].timee < a[3].timee && rule_AI ) ? ( ( a[1].timee < a[2].timee && a[2].on ) ? 1 : 2) : 3;printf ( "玩家%d赢了,用时%d分%d秒%d毫秒" , index , a[ index ].timee / 60000 , a[ index ].timee % 60000 / 1000 , a[ index ].timee % 1000 );}else printf ( "恭喜您,成功逃脱" );Sleep ( 1500 );return ;
}void set_game () {printf ( "欢迎游玩" );Sleep (3000);system ( "cls" );printf ( "请确定规则\n" );printf ( "方向键上下移动,空格更改选项,回车确认\n");printf ( "圈数:%d\n" , num );printf ( "药水:%s\n" , rule_poison ? "是" : "否" );printf ( "攻击:%s\n" , rule_attact ? "是" : "否" );printf ( "多人:%s\n" , a[2].on ? "是" : "否" );printf ( "岩浆:%s\n" , rule_lava ? "是" : "否" );printf ( "人机:%s\n" , rule_AI ? "是" : "否" );char r;HANDLE hout;COORD coord;hout = GetStdHandle(STD_OUTPUT_HANDLE);coord.X = 6;coord.Y = 2;SetConsoleCursorPosition(hout, coord);while ( r != 13 ) {r = getch ();coord.X = 3;if ( r == -32 ) {r = getch ();if ( r == 72 ) {coord.Y -= 1;if ( coord.Y == 1 ) coord.Y = 7;coord.X = 6;SetConsoleCursorPosition(hout, coord);}if ( r == 80 ) {coord.Y += 1;if ( coord.Y == 8 ) coord.Y = 2;coord.X = 6;SetConsoleCursorPosition(hout, coord);}}if ( r == ' ' && coord.Y == 2 && rule_lava == false) {num = num % 10 + 1;printf ( "%d " , num );coord.X = 6;SetConsoleCursorPosition(hout, coord);}if ( r == ' ' && coord.Y == 3 ) {rule_poison = !rule_poison;printf( "%s" , rule_poison ? "是" : "否" );coord.X = 6;SetConsoleCursorPosition(hout, coord);}if ( r == ' ' && coord.Y == 4 ) {rule_attact = !rule_attact;printf( "%s" , rule_attact ? "是" : "否" );coord.X = 6;SetConsoleCursorPosition(hout, coord);}if ( r == ' ' && coord.Y == 5 ) {a[2].on = !a[2].on;printf( "%s" , a[2].on ? "是" : "否" );coord.X = 6;SetConsoleCursorPosition(hout, coord);}if ( r == ' ' && coord.Y == 6 ) {rule_lava = !rule_lava;printf( "%s" , rule_lava ? "是" : "否" );num = 1;coord.X = 6;coord.Y = 2;SetConsoleCursorPosition(hout, coord);printf ( "1" );coord.Y = 6;SetConsoleCursorPosition(hout, coord);}if ( r == ' ' && coord.Y == 7 ) {rule_AI = !rule_AI;printf( "%s" , rule_AI ? "是" : "否" );coord.X = 6;SetConsoleCursorPosition(hout, coord);}Sleep (200);}
} int main () {srand ( unsigned ( time ( 0 ) ) );while ( true ) {system ( "cls" );player_reset ( );map_reset ( );set_game ( );run ( );}return 0;
}

「游戏」岩浆逃脱2.1相关推荐

  1. 「游戏」岩浆逃脱2.0

    经过一点点的努力,我把之前写的代码改精炼了些,然后也改了些内容,应该比以前要好玩些了 更新内容 去掉职业大乱斗(因为你打不到人) 改模式选择为规则调整 更改岩浆下降速度(更刺激了) 改为双视角同人物( ...

  2. 聊聊「游戏」这个磨人的小妖精

    引言:此文是我的「读书会」里一份优秀作业,刘昊男同学作品.对于游戏,我记得之前看过「六原则」,不妨放在开头: 研究不熟悉的东西使之变为熟悉的东西: 将熟悉的东西作有规律的重复: 在重复的过程中尽可能作 ...

  3. 「游戏」c++岩浆逃脱 1.0

    已更新至详见1.1 本游戏纯手打,无抄袭 单人模式(孤寂) 生存:努力逃脱上方的岩浆,取得胜利吧. 测试:测一测你究竟有多快. 双人模式(友尽) 生存:和朋友一起逃脱岩浆吧. 竞赛:互相设置陷阱,比比 ...

  4. 「游戏」游戏服务器中AOI的原理及四叉树实现

    前言 要不是想起来这篇文章想写一个关于游戏服务器开发过程中关于AOI相关的文章,我都差不点忘了我是一个游戏服务器开发人员

  5. 「游戏」寻路算法之A Star算法原理及实现

    前言 自动寻路是在一些如MMORPG等类型游戏中常见的一种功能,其给了玩家良好的游戏体验,使得玩家在游戏过程中省去了大量游戏坐标点的记录以及长时间的键盘操作,不必记忆坐标,不必担心迷路,用最快捷的方法 ...

  6. 绝版「游戏」保护计划!

    今天互联网上的内容,由于各种原因,正在以越来越快的速度消失,而新一代网民们,却并没有备份和记录的习惯及意识. 不远的将来,会有一天,当你特别想找一个东西却搜尽互联网你都找不到,本项目立足于将这样的损失 ...

  7. 「游戏」c++ 炸弹人2.0(新增人机)

    终于,经历了千辛万苦,我终于写出了人机(一个ZZ,能把自己闷在炸弹堆里)- 这个代码打得有些仓促,有问题请在评论区留言. 经典模式(1.0) CodeCodeCode #include <bit ...

  8. 「游戏」c++ 炸弹人1.0

    茫然ing N4Ig5iBcoKZaAXKBtUBLKICyIA0IAHTAJgEYAGADmIBZiBmAVgDp6A2AdnPoE4fK8IAI6ZS9EAF9c6TACdBIyCAaTpIDEo ...

  9. c语言mac小游戏,烧脑又有趣!苹果官方的「编程游戏」登陆Mac

    <Swift Playgrounds>是苹果官方推出的一款学习编程的App,它不要求用户具备编程知识,适合想要学习编程的初学者,即使是完全没有编程经验的人也可以玩得津津有味.在Apple ...

  10. 百度「造」什么车、微信读书「硬」变现、苹果手表「预测」新冠|极客一周...

    百度宣布和吉利合作成立智能汽车公司:微信读书将推硬件电子书阅读器:Apple Watch 或可提前数日检查出新冠感染. 百度也要造车了Waymo 没干的事儿,让百度干了. 1 月 11 日本周一,「腼 ...

最新文章

  1. Android之二维码生成与扫描
  2. 聊聊技术写作的个人体会
  3. 文献记录(part48)--Vector of Locally and Adaptively Aggregated Descriptors for Image Feature ...
  4. LeetCode 206. 反转链表
  5. 【iCore3 双核心板_FPGA】例程十二:Modelsim仿真实验
  6. 【例题+习题】【数值计算方法复习】【湘潭大学】(一)
  7. TokenInsight:反映区块链行业整体表现的TI指数较昨日同期上涨0.56%
  8. vue axios的路由拦截器
  9. 汇编心得(一)在32位机上实现64位数的相加
  10. 2021最新计算机二级C语言试题
  11. Abaqus帮助文档翻译——Abaqus/CAE主窗口介绍
  12. 联想计算机启机按F1,电脑开机提示按f1不能正常启动怎么办
  13. DINO 自监督算法简介
  14. Android如何实现APP自动更新
  15. Ubuntu Kylin 20_10 在VMware Workstation Pro上安装
  16. Oracle数据库11gR2完全干净卸载 - deinstall
  17. 【Linux杂篇】经常登录Linux,用户密码背后的知识了解一下
  18. [SQLAlchemy] 创建: 主键/索引/唯一约束/联合唯一约束/联合主键约束
  19. 「Medical Image Analysis」 Note on 朱文涛博士学位论文
  20. git与ssh配置方法及注意事项

热门文章

  1. 区块链最可能大规模应用场景:社交网络和共享经济
  2. 电压跌落故障Matlab,基于MATLAB的电压跌落建模仿真分析探究.pdf
  3. [554]sklearn提供的自带的数据集(make_blobs)
  4. 礼金记账本安卓_礼金记账本
  5. 实现自定义大转盘抽奖
  6. (数字ic)CDC跨时钟域可能出现的问题及解决办法总结
  7. 为什么计算机是32位64位,64位是x86还是x64_为什么64位是X64,32位是X86?
  8. 美式英语口语中连读、略读,音变的技巧
  9. 扔掉代码,程序员月薪达到了10k+
  10. JAVA面试题《下》