资源简介
C++写的著名游戏flappy bird.已经通过调试。支持多种功能,难度可以调节。
代码片段和文件信息
#include
#include
#include
#include
#include
/********函数变量声明********/
#define PR_Box printf(“■“)
#define PR_Gold printf(“★“)
#define PR_Ag printf(“☆“)
#define PR_FBird printf(“Ю“)
#define PR_DBird printf(“Ф“)
#define PR_Land printf(“┳┳┯“)
#define PR_Bg_TL printf(“╔“)
#define PR_Bg_TR printf(“╗“)
#define PR_Bg_DL printf(“╚“)
#define PR_Bg_DR printf(“╝“)
#define PR_Bg_X printf(“═“)
#define PR_Bg_Y printf(“║“)
#define PR_Blank printf(“ “);
int Grade = 1 C_Gold = 0 C_Ag = 0 Score = 0 Delay_time = 1000Max_blank=9Distance=18;
struct Birds
{
int x y;
int condition;
};
Birds *Bird = (Birds*)malloc(sizeof(Birds));
struct Bg
{
int x y;
int l_blank;
int reward[9];
Bg *pri;
Bg *next;
};
Bg *Bg1 = new Bg[sizeof(Bg)];
void Position(int x int y)
{
COORD pos = { x - 1 y - 1 };
HANDLE Out = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(Out pos);
}
void CreatBird()
{
Bird->x=41;
Bird->y=10;
Bird->condition =0;
}
void CreatBg()
{
Bg *Bg2 = (Bg*)malloc(sizeof(Bg));
Bg1->x=90;Bg1->y =8;
Bg2->x=Bg1->x+Distance;Bg2->y =9;
Bg1->l_blank =Max_blank-Grade;
Bg2->l_blank =Max_blank-Grade;
Bg1->next=Bg2;
Bg1->pri=Bg2;
Bg2->next=Bg1;
Bg2->pri=Bg1;
}
void InsertBg(Bg *p)
{int temp;
Bg *Bgs = (Bg*)malloc(sizeof(Bg));
Bgs->x=p->pri->x+Distance;
Bgs->l_blank =Max_blank-Grade;
srand((int)time(0));
temp=rand();
if(temp%2==0)//++
{ if((temp%4+p->pri->y+Max_blank-Grade)<21)
Bgs->y=p->pri->y+temp%4;
else
Bgs->y=p->pri->y;
}
else
{
if((p->pri->y-temp%4)>2)
Bgs->y=p->pri->y-temp%4;
else
Bgs->y=p->pri->y;
}
Bgs->pri=p->pri;
Bgs->next =p;
p->pri->next=Bgs;
p->pri =Bgs;
}
void Check_Bg(Bg *q)
{ Bg *p=q;int i=0temp;
while(++i<=5)
{ if(p->x>-4)
p=p->next;
else
{ srand((int)time(0));
temp=rand();
if(temp%2==0)//++
{ if((temp%4+p->y+Max_blank-Grade)<21)
p->y=p->y+temp%4;
else
p->y=p->y;
p->x=p->pri->x+Distance;
p->l_blank=Max_blank-Grade;
}
else
{
if((p->y-temp%4)>2)
p->y=p->y-temp%4;
else
p->y=p->y;
p->x=p->pri->x+Distance;
p->l_blank=Max_blank-Grade;
}
}
}
}
void Loop_Bg(Bg *q)
{
Bg *p=q;int i=0;
while(++i<=5)
{p->x=p->x-1;
p=p->next ;
if(Bird->x==p->x)
{Score+=1;
if(Score%4==0&&Grade<4)
Grade++;
}
}
}
void Prt_Bg(Bg *q)
{ Bg *p=q;int i=0kj;
while(++i<=5)
{ if(p->x>0&&p->x<=78)
{ for(k=2;ky;k++)
{ Position(p->x+1k);
PR_Box;PR_
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
- c++多边形交并差运算
评论
共有 条评论