小恐龙跳跳跳
#include<bits/stdc++.h>
#include<conio.h>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<windows.h>
#define set_color(d) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|d)
#define r FOREGROUND_RED
#define b FOREGROUND_BLUE
#define g FOREGROUND_GREEN
using namespace std;
//定义
int x=10,now_x=10,now,len,now_old,low_len,flat=0;
string col,man[5];
//游戏主地图
string a[15]={
{""},
{""},
{""},
{""},
{""},
{""},
{""},
{""},
{""},
{""},
{""},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉"},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉"},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉"},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉"}
};
//加载界面定义
string beginmap[40]={
{"▉ "},
{"▉▉ "},
{"▉▉▉ "},
{"▉▉▉▉ "},
{"▉▉▉▉▉ "},
{"▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ "},
{"▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉"}
};
//障碍物定义
string zai={"▉"};
int now_zai=63;
int now_zai_speed=1,now_zai_speed_begin=70;
void game();
void print();
void print_begin();
int main()
{
system("mode con cols=63 lines=20");
print_begin();
game();
return 0;
}
void game()
{
system("cls");
cout<<"Who are you?\n";
do{
getline(cin,man[len++]);
}while(len<5&&man[len-1]!="end");
man[len-1]={""};
low_len=man[len-2].size();
len-=2;
system("cls");
cout<<"What is the color of your body?\n";
cin>>col;
system("cls");
cout<<"How high can you jump?\n";
cin>>now_old;
while(now_zai_speed_begin++){
if(now>0)
{
x--;
now--;
}
else if(x<now_x)
{
x++;
}
else if(_kbhit()&&x==now_x){
char ch=getch();
if(ch==' '){
x--;
now=now_old;
}
}
print();
Sleep(100);
now_zai-=now_zai_speed;
if(now_zai<0&&flat==1)
{
flat=0;
now_zai=63;
srand(time(NULL));
now_zai_speed=rand()%5+now_zai_speed_begin/70;
}
else if(now_zai<0&&flat==0)
{
flat=1;
}
}
}
void print()
{
system("cls");
cout<<"height="<<x<<" "<<'\n';
for(int i=0;i<=10;i++)
{
if(i+len<2*x&&i+len>=x)
{
if(col=="red"||col=="RED")
set_color(r);
else if(col=="green"||col=="GREEN")
set_color(g);
else if(col=="blue"||col=="BLUE")
set_color(b);
cout<<man[i+len-x];
set_color(r|g|b);
}
if(i==10)
{
//障碍物判断
set_color(r|g|b);
if(now_zai<=low_len&&x==10)
{
system("cls");
system("color 40");
cout<<"\n\n\n\n\n\n\n\n GAMEOVER";
Sleep(5000);
system("cls");
system("color 07");
cout<<"go back turn '1':else turn '2'\n";
int aaa;
cin>>aaa;
if(aaa==1)
game();
else
{
exit(1);
}
}
else if(now_zai>low_len)
{
if(x==10)
{
for(int i=low_len;i<now_zai;i++){
cout<<" ";
}
}
else
{
for(int i=0;i<now_zai;i++){
cout<<" ";
}
}
cout<<zai;
}
else if(now_zai<low_len)
{
for(int i=0;i<now_zai;i++){
cout<<" ";
}
cout<<zai;
}
else if(now_zai==low_len&&x!=10)
{
for(int i=0;i<now_zai;i++){
cout<<" ";
}
cout<<zai;
}
}
cout<<"\n";
}
set_color(g|r|b);
for(int i=11;i<=14;i++){
cout<<a[i]<<"\n";
}
}
void print_begin()
{
system("color E0");
for(int i=0;i<40;i++){
system("cls");
cout<<" ___ ___ ___ ___ | "<<"\n";
cout<<" \ /|__ | | | | |\/| |__ | "<<"\n";
cout<<" \/\/ |___ |__ |___ |___| | | |___ . "<<"\n\n";
cout<<" ___ _ _ _ ___ "<<"\n";
cout<<" | __ /_\ |\/| |__ "<<"\n";
cout<<" |___| / \ | | |___ "<<"\n";
cout<<"\n\n name:jump!jump!jump!!!\n\n -----------------------------------------\n"<<" |"<<beginmap[i]<<" |\n -----------------------------------------\n\n\n\ncreato:Jason ";
srand(time(NULL));
Sleep(rand()%500);
}
Sleep(500);
}