一个自编跑酷GAME,希望大家喜欢
空格跳跃,方块能回血或涨积分
更多游戏请关注我的分享!!!
游戏的不足可以在下面指出!
更多惊喜尽在游戏中!
#include<bits/stdc++.h>
#include<conio.h>
#include<windows.h>
using namespace std;
int dt[25]={},x=0,hehe,sl=10,jf=0;
bool ty;
void out(string a)
{
int l=a.length();
for(int i=0;i<l;i++)
{
cout<<a[i];
Sleep(10);
}
cout<<endl;
}
void gotoxy(int x, int y)
{
COORD coord;
HANDLE hscr;
coord.X=x;
coord.Y=y;
hscr=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hscr, coord);
}
void Color(int a)
{
if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
if(a==7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN);
if(a==8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==9) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY);
if(a==10) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|BACKGROUND_GREEN);
if(a==11) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_BLUE|BACKGROUND_GREEN);
if(a==12) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|BACKGROUND_GREEN);
if(a==13) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE|BACKGROUND_INTENSITY|BACKGROUND_BLUE);
if(a==14) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE|BACKGROUND_INTENSITY|BACKGROUND_RED);
}
int main()
{
system("mode con cols=50 lines=20");
CONSOLE_CURSOR_INFO cursor_info={1,0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
srand(unsigned(time(NULL)));
out("meng bank出品——猴猴酷跑");
Sleep(1000);
system("cls");
for(;;)
{
CONSOLE_CURSOR_INFO cursor_info={1,0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
gotoxy(0,0);
cout<<"血量;"<<sl<<" "<<endl;
cout<<"积分"<<jf<<" "<<endl;
for(int i=1;i<=5-x;i++)
cout<<" "<<endl;
if(rand()%2+1==1)
cout<<" o "<<endl,
cout<<" /|) "<<endl,
cout<<" ┦ "<<endl;
else
cout<<" o "<<endl,
cout<<" /|) "<<endl,
cout<<" ╯> "<<endl;
for(int i=1;i<=x;i++)
cout<<" "<<endl;
for(int i=1;i<=20;i++)
if(dt[i]==0) cout<<"==";
else if(dt[i]==2) Color(13),cout<<"■",Color(8);
else if(dt[i]==3) Color(12),cout<<"■",Color(8);
else cout<<"▲";
Sleep(50);
for(int i=1;i<=19;i++)
dt[i]=dt[i+1];
if(rand()%10+1==1) dt[20]=1;
else if(rand()%50+1==2) dt[20]=2;
else if(rand()%50+1==2) dt[20]=3;
else dt[20]=0;
if(kbhit())
{
char k=getch();
if(k==' ')
{
if(x<5)
ty=true;
hehe=0;
cin.clear();
}
}
if(ty) hehe++;
if(hehe<=3&&ty&&x<5) x++;
else if(hehe>3&&ty) x--;
if(hehe==6) ty=false,x=0,hehe=0;
if(dt[5]==1&&x==0) sl--;
if(dt[5]==2&&x==0) jf=jf+3,dt[5]=0;
if(dt[5]==3&&x==0) sl=sl+3,dt[5]=0;
if(rand()%50+1==2) jf++;
if(sl<=0) {
system("cls");
out("you are die");
out("你的积分为");
cout<<jf;
return 0;
}
}
}
偷偷皮一下
*
改代码了吧?
呵呵,当然*
一直按空格可以一直飞啊hh
对对对
一个bug
自己编的呀,挺nb嘛
呵呵
兄啊,这万能头十分影响程序运行啊= =
有吗
其他头文件我都不会打啊
有可能是我电脑太烂了= =总之c++报错说包含的头太多了
O_O
啊?
同学乱码,运行不出来…QAQ
?