FNAF 1是一款游戏,不知道的可以上网查。这个2014年的游戏有4个玩偶,移动是随机的,并且保安(玩家)可以做6种操作。那么,如果用4个int变量定义位置,2个表示时间的变量,1个表示电量(powerleft)的变量,加上一个while循环,这个游戏便在C++中实现了。
注:因为网上没有对电量、时间的公式计算,所以本游戏还是有一些bug的,恐怖气氛可能更小了。
代码如下:
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
void slowsay(string a)
{
int l=a.size();
for(int i=0;i<=l;i++)
{
cout<<a[i];
Sleep(70);
}
}
int job,s1,s2,s3,s4,pj;
int main()
{
int freddy=1,bonnie=1,chika=1,fox=1;
double f=0,b=0,c=0;
double powerleft=100,foxrun=95.00;
string start;char g;
bool LL=false,RL=false,LD=false,RD=false,Cam=false;
int night;
int ussage=1;
bool custom=false,bonniebreak=0,chikabreak=0;
int hour=0,minute=0,sum=0;
slowsay("Five");cout<<endl;slowsay("Nights");cout<<endl;slowsay("At");cout<<endl;slowsay("Freddy 's");cout<<endl;cout<<endl;slowsay("New Game");cout<<endl;slowsay("Custom Night");cout<<endl;
while(g!='\n')
{
cin>>start;g=getchar();
}
if(start=="Game")
{
slowsay("选择一夜(1-6)");cout<<endl;
cin>>night;
if(night==1) sum=6;
if(night==2) sum=5;
if(night==3) sum=4;
if(night==4) sum=3;
if(night==5) sum=2;
if(night==6) sum=1;
slowsay("12:00");slowsay("a.m.");cout<<endl;
slowsay("Night");cout<<" ";cout<<night<<endl;
}
else if(start=="Night")
{
slowsay("输入4个等级");slowsay("为四人组顺序");
cin>>s1>>s2>>s3>>s4;
sum=(s1+s2+s3+s4)/4;
}
while(freddy!=8 &am