flappy bird c语言,Flappy Bird C语言实现
#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 = 1000, Max_blank = 9, Distance = 18;
typedef struct Birds {
int x, y;
int condition;
}Birds;
Birds * Bird;
typedef struct Bg {
int x, y;
int l_blank;
int reward[9];
struct Bg * pri;
struct Bg * next;
}Bg;
Bg * Bg1;
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 = 0, temp;
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 = 0, k, j;
while (++i <= 5) {
if (p -> x > 0 && p -> x <= 78) {
for (k = 2; k < p -> y; k++) {
Position(p -> x + 1, k);
PR_Box;
PR_Box;
PR_Blank
}
Position(p -> x, p -> y);
PR_Box;
PR_Box;
PR_Box;
PR_Blank;
Position(p -> x, p -> y + p -> l_blank);
PR_Box;
PR_Box;
PR_Box;
PR_Blank;
k = k + p -> l_blank + 1;
for (k; k <= 22; k++) {
Position(p -> x + 1, k);
PR_Box;
PR_Box;
PR_Blank;
}
Position(p -> x, 23);
for (k = 1; k < Distance / 3 - 2; k++)
PR_Land;
}
p = p -> next;
if (p -> x == 0) {
for (j = 2; j < p -> y; j++) {
Position(p -> x + 1, j);
PR_Blank;
PR_Blank;
}
Position(p -> x + 1, p -> y);
PR_Blank;
PR_Blank;
PR_Blank;
Position(p -> x + 1, p -> y + Max_blank - Grade);
PR_Blank;
PR_Blank;
PR_Blank;
j = j + Max_blank - Grade + 1;
for (j; j <= 22; j++) {
Position(p -> x + 1, j);
PR_Blank;
PR_Blank;
}
}
}
}
void PrtBg() {
int i;
Position(1, 1);
PR_Bg_TL;
Position(79, 1);
PR_Bg_TR;
Position(1, 24);
PR_Bg_DL;
Position(79, 24);
PR_Bg_DR;
for (i = 3; i <= 78; i += 2) {
Position(i, 1);
PR_Bg_X;
Position(i, 24);
PR_Bg_X;
}
}
void PrtBird() {
Position(Bird -> x, Bird -> y - 1);
PR_Blank;
Position(Bird -> x, Bird -> y);
PR_FBird;
Position(38, 2);
printf("Score:%d", Score);
}
int CheckYN(Bg * q) {
Bg * p = q;
int i = 0;
while (++i <= 5) {
if (Bird -> y > 23)
return 0;
if (Bird -> x == p -> x && Bird -> y <= p -> y)
return 0;
if ((Bird -> x == p -> x || Bird -> x == p -> x + 1 || Bird -> x == p -> x + 2) && Bird -> y == p -> y)
return 0;
if (Bird -> x == p -> x && Bird -> y > p -> y + p -> l_blank)
return 0;
if ((Bird -> x == p -> x || Bird -> x == p -> x + 1 || Bird -> x == p -> x + 2) && Bird -> y == p -> y +
p -> l_blank)
return 0;
p = p -> next;
}
return 1;
}
void Prtfirst() {
printf("══════════════════════════════════════\n");
printf(" ■■ ■■\n");
printf(" ■■ ■■\n");
printf(" ■■ ■■ C语言版 Flappy Bird\n");
printf(" ■■ ■■ 瞎搞人:yyposs\n");
printf(" ■■ ■■ 瞎搞日期:2014.2\n");
printf(" ■■ ■■ 耗时:4小时\n");
printf(" ■■■ ■■ 游戏说明:\n");
printf(" ■■ 1-按上箭头使鸟起飞\n");
printf(" ■■ 2-等级越高,难度越大!\n");
printf(" Ю ■■■\n");
printf("\n");
printf(" ■■■ 欢迎各路大神一起探讨\n");
printf(" ■■\n");
printf(" ■■\n");
printf(" ■■ ■■■ 【无版权,随意修改】\n");
printf(" ■■ ■■\n");
printf(" ■■ Ф ■■\n");
printf(" ■■ ■■\n");
printf(" ■■ ■■\n");
printf(" ■■ ■■\n");
printf(" ■■ ■■\n");
printf(" ┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳\n");
system("pause");
Position(1, 1);
int i = 0;
while (i++ < 40 * 25)
PR_Blank;
}
void main() {
int i = 0;
Bird = (Birds * ) malloc(sizeof(Birds));
Bg1 = (Bg * ) malloc(sizeof(Bg));
Prtfirst();
PrtBg();
CreatBg();
InsertBg(Bg1);
InsertBg(Bg1);
InsertBg(Bg1);
CreatBird();
while (1) {
if (!CheckYN(Bg1))
break;
Check_Bg(Bg1);
Prt_Bg(Bg1);
PrtBird();
Loop_Bg(Bg1);
Bird -> y = Bird -> y + 1;
if (GetAsyncKeyState(VK_UP)) {
Position(Bird -> x, Bird -> y - 1);
PR_Blank;
Bird -> y = Bird -> y - 4;
}
while (i++ < 500); {
Sleep(100);
}
i = 0;
}
Position(38, 10);
printf("You Lost!");
Position(1, 25);
system("pause");
}
flappy bird c语言,Flappy Bird C语言实现相关推荐
- c语言flappy bird代码,Flappy bird源代码(略吊)
[codesyntax lang="cpp"] #include #include #include #include #include /********函数变量声明****** ...
- r语言 断轴 画图_R语言基础画图/绘图/作图
R语言基础画图 R语言免费且开源,其强大和自由的画图功能,深受广大学生和可视化工作人员喜爱,这篇文章对如何使用R语言作基本的图形,如直方图,点图,饼状图以及箱线图进行简单介绍. 0 结构 每种图形构成 ...
- c语言 字母 八进制表示'/1011',C语言C语言第一课:C语言概述为什么学习C语言怎样学习C语言.DOC...
[摘要]C语言 第一课: C语言概述 为什么学习C语言 怎样学习C语言 参考资料 ----------------------------------------------------------- ...
- 学单片机需要多少C语言基础,C语言单片机编程教程
很多学员和朋友经常找我给他们推荐C语言的书,他们可能想和我当年一样,闷头大干一场,学个几个月的C语言,把C语言吃透,再开始单片机程序开发! 别!别!别! 大家千万别这么干,我当年自学了3个月的C语言, ...
- 为什么可以说Java语言是准动态语言?
什么是动态语言? 动态语言,是指程序在运行时可以改变其结构:新的函数可以被引进,已有的函数可以被删除等在结构上的变化.比如JavaScript便是一个典型的动态语言. 除此之外如Ruby.Python ...
- c语言课件 文件,C语言课件--文件.ppt
C语言课件--文件 例12-5 /*将字符串"apple", "grape", "pear" 写入到磁盘文件f12-5.txt中,然后再从该 ...
- python和c哪个适合入门-编程入门选什么语言好?C 语言还是Python ?为你解析
前面我分享过计算机行业已经成了学校选择排名第一,家长和学生都很看好计算机类专业.现在IT行业也越来越火爆,程序员越来越被人看好.面对相比同龄人高薪资的诱惑,人们很难不心动,即使秃头也值得! 那么问题来 ...
- python叫什么语言-python是什么语言编写的
python是什么语言编写的? python是C语言编写的. 自从20世纪90年代初Python语言诞生至今,它已被逐渐广泛应用于系统管理任务的处理和Web编程. Python的创始人为荷兰人吉多·范 ...
- 以下哪一个不属于python语言的特点-Python语言的特点有哪些
Python语言的特点有哪些 Python 是目前最流行的语言之一,从云计算.大数据到人工智能,Python 无处不在,Python 人才需求量也在逐年攀升,Python 为何能发展如此的迅猛,究竟有 ...
- 【计算理论】可判定性 ( 计算模型与语言 | 区分 可计算语言 与 可判定语言 | 证明 通用图灵机语言是 可计算语言 | 通用任务图灵机 与 特殊任务图灵机 )
文章目录 一.计算模型与语言 二.区分 可计算语言 与 可判定语言 三.证明 ATM\rm A_{TM}ATM 语言 可计算 四.通用 ( Universal ) 任务图灵机 与 特殊任务图灵机 一 ...
最新文章
- 程序猿面试什么最重要?
- SAP SD基础知识之文本确定(Text Determination)
- 04 - Object-C协议与代理设计
- python 如何从列表中剔除(去除)重复元素?set()
- QT的QEnableSharedFromThis类的使用
- python在mac上_在Mac上Python多版本切换
- cloud一分钟 | 腾讯云联手斗鱼、虎牙两大头部游戏直播平台开启 定制道具的创新互动...
- MongoDB索引,性能分析
- 阿里小二平时和商家交流的时候,明确告知流量喜欢什么样的产品?
- 2016/2/19:ApplePay
- fcm基本原理_FCM聚类算法介绍
- Android AIDL原理
- Android开源框架:Retrofit
- odl源码系列一restconf模块
- 趣味程序设计_出售金鱼
- python输出间隔符号_间隔符号?
- one to one
- 线性代数常见的几种行列式
- python获取内存地址上存储的值
- 只有伤心的理由,没有沉沦的借口。
热门文章
- Unix时代的开创者Ken Thompson (zz.is2120.bg57iv3)
- 2016年俄罗斯M2M市场达100亿俄罗斯卢布
- 基数树结构---radix_tree
- 机器人系统设计(五)
- 【独行秀才】macOS Big Sur 11.5 Beta 1(20G5023d)原版镜像
- python pyd_python pyd 加密相关
- python输入姓名输出欢迎你某某同学_2018-03-24 python 练习
- Springer Evolutionary Intelligence投稿,提交Latex文件记录
- A Knee_Guided Evolutionary Algorithm for Compressing Deep Neural Network (KGEA)解读
- 写代码有这16个好习惯,可以减少80%非业务的bug