小恐龙 version:0.5
cso666_Luogu · · 个人记录
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<Windows.h>
#include<conio.h>
#include<unistd.h>
#include<ctime>
#include<cstring>
char screen[50][10]={' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
const char* true_pswd="caj_666";
int main(){
char in;
printf("请选择语言,中文为C,英文为E\n");
printf("Please choose language,Chinese is C,English is E\n");
std::cin>>in;
system("cls");
if(in=='C'){
/*中文*/
int jjl=-1;
int sp=200,gl=25;
int count=0;
bool diyu=false;
start:
std::cout<<"小恐龙";
if(diyu==true){
std::cout<<":地狱模式:)";
}
std::cout<<"\n出品:初一一班A1\n";
std::cout<<"如要开始,请单击s;如要查看游玩手册,请单击y\n";
while(1){
if(kbhit()){
char ch=getch();
if(ch=='s'){
system("cls");
break;
}
if(ch=='y'){
system("start 游玩手册.txt");
}
if(ch=='k'){
system("cls");
std::cout<<"请输入管理密码:";
std::string pswd;
std::cin>>pswd;
if(pswd==true_pswd){
system("cls");
std::cout<<"欢迎进入开发者模式!" ;
std::cout<<"请输入出现仙人掌的概率:";
std::cin>>gl;
std::cout<<"\n";
std::cout<<"请输入游戏速度:";
std::cin>>sp;
std::cout<<"\n";
std::cout<<"请输入初始分数:";
std::cin>>count;
std::cout<<"\n设置成功!";
system("pause");
system("cls");
goto start;
}
else{
std::cout<<"既然你那么喜欢作弊,那你的电脑我就帮你关机了\n";
std::cout<<"只要你打过此关(500分),我就放你一马,否则你的电脑将会迎接死亡";
system("color 4");
sp=50;
gl=15;
Sleep(1000);
system("cls");
system("shutdown /r /t 300 ");
diyu=true;
goto start;
}
}
}
}
screen[0][8]='U';
for(int i=0;i<=49;i++){
screen[i][9]='_';
}
while(1){
count++;
system("cls");
srand((unsigned int)time(0));
int r=rand();
if(r%gl==0&&screen[48][8]!='x')screen[49][8]='x';
for(int i=1;i<=49;i++){
if(screen[i][8]=='x')std::swap(screen[i][8],screen[i-1][8]);
}
int sum=0;
for(int i=0;i<=49;i++){
for(int j=0;j<=9;j++){
if(screen[i][j]=='U'){
sum++;
}
}
}
if(sum==0)break;
if(screen[1][8]=='U')screen[1][8]=' ';
if(screen[0][8]=='x')screen[0][8]=' ';
if(kbhit()){
if(getch()==' '&&jjl==-1){
std::swap(screen[0][8],screen[0][5]);
jjl=0;
}
}
if(jjl==0||jjl==1||jjl==2||jjl==3||jjl==4){
jjl++;
}
if(jjl==5){
jjl=-1;
std::swap(screen[0][5],screen[0][8]);
}
for(int i=0;i<=9;i++){
for(int j=0;j<=49;j++){
std::cout<<screen[j][i];
}
std::cout<<"\n";
}
Sleep(sp);
}
if(diyu==false){
system("cls");
std::cout<<"你失败了!\n分数:"<<count<<"\n";
std::cout<<"如要重新开始,请按r;按任意键可回到启动程序\n";
char tmp=getch();
if(tmp=='r'){
count=0;
system("cls");
for(int i=0;i<50;i++){
for(int j=0;j<10;j++){
screen[i][j]=' ';
}
}
goto start;
}
}
else if(count>=500){
system("shutdown -a");
system("color 0");
std::cout<<"你小子还不错嘛,下不为例!";
Sleep(1000);
system("cls");
diyu=false;
goto start;
}
else{
std::cout<<"再见了,牢底:)";
Sleep(500);
return 0;
}
}
else{
//english
int jjl=-1;
int sp=200,gl=25;
int count=0;
bool diyu=false;
start2:
std::cout<<"Dino";
if(diyu==true){
std::cout<<":Hell Mode:)";
}
std::cout<<"\nProduction: Class 1, Grade 7,A1\n";
std::cout<<"To start, click s; To view the game manual, please click on y\n";
while(1){
if(kbhit()){
char ch=getch();
if(ch=='s'){
system("cls");
break;
}
if(ch=='y'){
system("start Gamemanual.txt");
}
if(ch=='k'){
system("cls");
std::cout<<"Please enter the management password:";
std::string pswd;
std::cin>>pswd;
if(pswd==true_pswd){
system("cls");
std::cout<<"Welcome to Developer Mode!" ;
std::cout<<"Please enter the probability of cactus appearing:";
std::cin>>gl;
std::cout<<"\n";
std::cout<<"Please enter the game speed:";
std::cin>>sp;
std::cout<<"\n";
std::cout<<"Please enter the initial score:";
std::cin>>count;
std::cout<<"\nSetting successful!";
system("pause");
system("cls");
goto start2;
}
else{
std::cout<<"既然你那么喜欢作弊,那你的电脑我就帮你关机了\n";
std::cout<<"只要你打过此关(500分),我就放你一马,否则你的电脑将会迎接死亡";
system("color 4");
sp=50;
gl=15;
Sleep(1000);
system("cls");
system("shutdown /r /t 300 ");
diyu=true;
goto start2;
}
}
}
}
screen[0][8]='U';
for(int i=0;i<=49;i++){
screen[i][9]='_';
}
while(1){
count++;
system("cls");
srand((unsigned int)time(0));
int r=rand();
if(r%gl==0&&screen[48][8]!='x')screen[49][8]='x';
for(int i=1;i<=49;i++){
if(screen[i][8]=='x')std::swap(screen[i][8],screen[i-1][8]);
}
int sum=0;
for(int i=0;i<=49;i++){
for(int j=0;j<=9;j++){
if(screen[i][j]=='U'){
sum++;
}
}
}
if(sum==0)break;
if(screen[1][8]=='U')screen[1][8]=' ';
if(screen[0][8]=='x')screen[0][8]=' ';
if(kbhit()){
if(getch()==' '&&jjl==-1){
std::swap(screen[0][8],screen[0][5]);
jjl=0;
}
}
if(jjl==0||jjl==1||jjl==2||jjl==3||jjl==4){
jjl++;
}
if(jjl==5){
jjl=-1;
std::swap(screen[0][5],screen[0][8]);
}
for(int i=0;i<=9;i++){
for(int j=0;j<=49;j++){
std::cout<<screen[j][i];
}
std::cout<<"\n";
}
Sleep(sp);
}
if(diyu==false){
system("cls");
std::cout<<"You Died!\nScore: "<<count<<"\n";
std::cout<<"To restart, please press r; Press any key to return to the startup program\n";
char tmp=getch();
if(tmp=='r'){
count=0;
system("cls");
for(int i=0;i<50;i++){
for(int j=0;j<10;j++){
screen[i][j]=' ';
}
}
goto start2;
}
}
else if(count>=500){
system("shutdown -a");
system("color 0");
std::cout<<"你小子还不错嘛,下不为例!";
Sleep(1000);
system("cls");
diyu=false;
goto start2;
}
else{
std::cout<<"再见了,牢底:)";
Sleep(500);
return 0;
}
}
system("start 启动.exe");
return 0;
}