转载:Flappy Bird源代码 win32 console版
#include"StdAfx.h" #include<stdio.h> #include<stdlib.h> #include<conio.h>
#include<time.h>
#include<Windows.h>
/********函数变量声明********/
#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 = , C_Gold = , C_Ag = , Score = , Delay_time = ,Max_blank=,Distance=; struct Birds
{
int x, y;
int condition;
}; Birds *Bird = (Birds*)malloc(sizeof(Birds)); struct Bg
{
int x, y;
int l_blank;
int reward[];
Bg *pri;
Bg *next;
}; Bg *Bg1 = new Bg[sizeof(Bg)]; void Position(int x, int y)
{
COORD pos = { x - , y - };
HANDLE Out = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(Out, pos);
} void CreatBird()
{
Bird->x=;
Bird->y=;
Bird->condition =;
} void CreatBg()
{
Bg *Bg2 = (Bg*)malloc(sizeof(Bg)); Bg1->x=;Bg1->y =;
Bg2->x=Bg1->x+Distance;Bg2->y =; 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());
temp=rand();
if(temp%==)//++
{
if((temp%+p->pri->y+Max_blank-Grade)<)
Bgs->y=p->pri->y+temp%;
else
Bgs->y=p->pri->y;
}
else
{
if((p->pri->y-temp%)>)
Bgs->y=p->pri->y-temp%;
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=,temp;
while(++i<=)
{
if(p->x>-)
p=p->next;
else
{
srand((int)time());
temp=rand();
if(temp%==)//++
{
if((temp%+p->y+Max_blank-Grade)<)
p->y=p->y+temp%;
else
p->y=p->y;
p->x=p->pri->x+Distance;
p->l_blank=Max_blank-Grade;
}
else
{
if((p->y-temp%)>)
p->y=p->y-temp%;
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=;
while(++i<=)
{
p->x=p->x-;
p=p->next ;
if(Bird->x==p->x)
{
Score+=;
if(Score%==&&Grade<)
Grade++;
}
}
} void Prt_Bg(Bg *q)
{
Bg *p=q;int i=,k,j;
while(++i<=)
{
if(p->x>&&p->x<=)
{ for(k=;k<p->y;k++)
{
Position(p->x+,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+;
for(k;k<=;k++)
{
Position(p->x+,k);
PR_Box;PR_Box;PR_Blank;
}
Position(p->x,);
for(k=;k<Distance/-;k++)
PR_Land;
}
p=p->next;
if(p->x==)
{
for(j=;j<p->y;j++)
{ Position(p->x+,j);
PR_Blank;PR_Blank;
}
Position(p->x+,p->y);
PR_Blank;PR_Blank;PR_Blank;
Position(p->x+,p->y+Max_blank-Grade);
PR_Blank;PR_Blank;PR_Blank;
j=j+Max_blank-Grade+;
for(j;j<=;j++)
{Position(p->x+,j);
PR_Blank;PR_Blank;
}
}
}
}
void PrtBg()
{
int i;
Position(,);PR_Bg_TL;
Position(,);PR_Bg_TR;
Position(,);PR_Bg_DL;
Position(,);PR_Bg_DR;
for(i=;i<=;i+=)
{
Position(i,);PR_Bg_X;
Position(i,);PR_Bg_X;
}
/*for(i=2;i<=23;i++)
{ Position(1,i);PR_Bg_Y;printf("%d",i-1);
Position(79,i);PR_Bg_Y;
}*/
}
void PrtBird()
{
Position(Bird->x,Bird->y-);
PR_Blank;
Position(Bird->x,Bird->y);
PR_FBird;
Position(,);
printf("Score:%d",Score);
}
int CheckYN(Bg *q)
{
Bg *p=q;int i=;
while(++i<=)
{
if(Bird->y>)
return ;
if(Bird->x==p->x&&Bird->y<=p->y)
return ;
if((Bird->x==p->x||Bird->x==p->x+||Bird->x==p->x+)&&Bird->y==p->y)
return ;
if(Bird->x==p->x&&Bird->y>p->y+p->l_blank)
return ;
if((Bird->x==p->x||Bird->x==p->x+||Bird->x==p->x+)&&Bird->y==p->y+p->l_blank)
return ;
p=p->next;
}
return ;
}
void Prtfirst()
{
printf("══════════════════════════════════════\n");
printf(" ■■ ■■\n");
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\n\n\n\n\n\n\n");
printf(" ┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳\n");
system("pause");
Position(,);
int i=;
while(i++<*)
PR_Blank;
}
void main()
{
int i=;char ch;
Prtfirst(); PrtBg();
CreatBg();
InsertBg(Bg1);
InsertBg(Bg1);
InsertBg(Bg1);
CreatBird();
while()
{
if(!CheckYN(Bg1))
break;
Check_Bg(Bg1);
Prt_Bg(Bg1);
PrtBird();
Loop_Bg(Bg1);
Bird->y=Bird->y+;
if(GetAsyncKeyState(VK_UP))
{
Position(Bird->x,Bird->y-);
PR_Blank;
Bird->y=Bird->y-;
}
while(i++<);
{
Sleep();
}
i=;
}
Position(,);
printf("You Lost!");
Position(,);
system("pause");
}
在校内上看到这份代码,对vs进行些配置后可以运行,mark在此。
转载:Flappy Bird源代码 win32 console版的更多相关文章
- Flappy bird源代码(略吊)
#include<stdio.h> #include<stdlib.h> #include<conio.h> #include<time.h> #inc ...
- HTML5 版的flappy bird
Flappy Bird这款简单的小游戏累计下载量已经超过5000万次,每天收入至少5万美元.然而,2月10日其开发者Dong Nguyen却将Flappy Bird从苹果App Store和Googl ...
- C语言版flappy bird黑白框游戏
在此记录下本人在大一暑假,2014.6~8这段时间复习C语言,随手编的一个模仿之前很火热的小游戏----flappy bird.代码bug基本被我找光了,如果有哪位兄弟找到其他的就帮我留言下吧,谢谢了 ...
- 也来山寨一版Flappy Bird (js版)
随着Flappy Bird的火爆,各种实现的版也不断出现,于是也手痒简单实现了一版. 其实本来只是想实现一下这只笨鸟的飞翔运动的,后来没忍住,就直接实现一个完整游戏了…… 因为这个游戏本身实现起来就没 ...
- flappy bird游戏源代码揭秘和下载
转:http://blog.csdn.net/touchsnow/article/details/19071961 背景: 最近火爆全球的游戏flappy bird让笔者叹为观止,于是花了一天的时间山 ...
- 教你从头到尾利用DQN自动玩flappy bird(全程命令提示,GPU+CPU版)【转】
转自:http://blog.csdn.net/v_JULY_v/article/details/52810219?locationNum=3&fps=1 目录(?)[-] 教你从头到尾利用D ...
- cocos2dx-html5 实现网页版flappy bird游戏
我也是第一次使用cocos2d_html5,对js和html5也不熟,看引擎自带的例子和引擎源码,边学边做,如果使用过cocos2d-x的话,完成这个游戏还是十分简单的.游戏体验地址: http:// ...
- [Win32::Console]Perl终端版生命游戏
环境,WinXP/Win7 Perl 5.16 默认循环1000次,按ESC提前退出 use strict; use Term::ReadKey; use Win32::Console; use T ...
- 自己动手写游戏:Flappy Bird
START:最近闲来无事,看了看一下<C#开发Flappy Bird游戏>的教程,自己也试着做了一下,实现了一个超级简单版(十分简陋)的Flappy Bird,使用的语言是C#,技术采用了 ...
随机推荐
- 【莫队】bzoj4866: [Ynoi2017]由乃的商场之旅
莫队的一些套路 Description 由乃有一天去参加一个商场举办的游戏.商场派了一些球王排成一行.每个人面前有几堆球.说来也巧,由乃和你 一样,觉得这游戏很无聊,于是决定换一个商场.另一个商场是D ...
- Python正则表达式详解——re库
一.简介 1.1.相关链接 官方文档: Python2:https://docs.python.org/2/library/re.html Python3:https://docs.python.or ...
- 【mysql】mysql 备份脚本
#! /bin/bash HOST=localhost USER=root PASSWORD=password DATE_STR=$(date '+%F--%T') ERROR_LOG=/usr/ ...
- linux中怎样关闭ICMP回应功能
引用自:http://blog.csdn.net/qq844352155/article/details/49700121 linux中怎样关闭ICMP回应功能 输入: echo 1 > ...
- manjaro kde tim QQ
deepin-wine-tim
- python模块之datetime
相比于time模块,datetime模块的接口则更直观.更容易调用 datetime模块定义了下面这几个类: datetime.date:表示日期的类.常用的属性有year, month, day: ...
- NTC温度采集之数据拟合——freemat软件实现
在stm32温度采样的过程中,使用到了NTC传感器,上拉接6.2K的电阻,信号给AD采样端口,通过NTC的电阻阻值表中,计算得到下面两端数据,在freemat中实现数据拟合,用于程序中温度和电压信号的 ...
- HDU:1269-迷宫城堡(tarjan模板)
迷宫城堡 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Descri ...
- MySQL使用yum安装
1.下载mysql的repo源 $ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 2.安装mysql-comm ...
- ubuntu12.04安装wireshark
1 安装 $ sudo apt-get install wireshark 2 启动 $ sudo wireshark 3 启动报错