您的位置:

c语言制作小鸟,c语言小鸟游戏

本文目录一览:

c语言编程(小鸟)问题 100分求解答在线等

#includestdio.h

#includeconio.h

int main(void)

{

int i,j,t,h,n;

clrscr();

for(h=0;h12;h++)

{

for (t=15;th;t--) printf("\n");

for (n=0;n5*h;n++) printf(" ");

for (i=0;i4;i++)

{

for (j=0;j3-i;j++)printf(" ");

printf("/");

for (j=0;j2*i;j++)printf(" ");

printf("\\");

for (j=0;j2*(3-i);j++)printf(" ");

printf("/");

for (j=0;j2*i;j++)printf(" ");

printf("\\");

printf("\n");

for (n=0;n5*h;n++) printf(" ");

}

delay(650);

clrscr();

for (t=15;th;t--) printf("\n");

for (n=0;n5*h;n++) printf(" ");

for(i=0;i12;i++)printf(" ");

printf("^");

printf("\n");

for (n=0;n5*h;n++) printf(" ");

for(i=0;i10;i++)printf(" ");

printf("/\\");

printf("\n");

for (n=0;n5*h;n++) printf(" ");

for(i=0;i9;i++)printf(" ");

printf("//");

delay (650);

clrscr();

}

return 0;

}

程序如上,已经修改了,可以实现你说的。

你主要是注意两个变量的控制

for (t=15;th;t--) printf("\n");

for (n=0;n5*h;n++) printf(" ");

上面是控制从下到上的输出,

下面是控制从左到右的输出。

for (i=0;i4;i++)

{

for (j=0;j3-i;j++)printf(" ");

printf("/");

for (j=0;j2*i;j++)printf(" ");

printf("\\");

for (j=0;j2*(3-i);j++)printf(" ");

printf("/");

for (j=0;j2*i;j++)printf(" ");

printf("\\");

printf("\n");

for (n=0;n5*h;n++) printf(" ");

}

这个是鸟的输出。

主要是每一行的输出,还要输出

for (n=0;n5*h;n++) printf(" ");下一行前面的空格,就是和前面的

从左到右的控制

for (n=0;n5*h;n++) printf(" ");

其实主要是理解输出的思想。

有问题可以hi我。

用c语言编小鸟飞飞飞

#includestdio.h

#includestdlib.h

#includeconio.h

#includetime.h

#includeWindows.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 = 1, C_Gold = 0, C_Ag = 0, Score = 0, Delay_time = 1000, Max_blank = 9, Distance = 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 = 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 Grade4)

Grade++;

}

}

}

void Prt_Bg(Bg *q)

{

Bg *p = q; int i = 0, k, j;

while (++i = 5)

{

if (p-x0 p-x = 78)

{

for (k = 2; kp-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; kDistance / 3 - 2; k++)

PR_Land;

}

p = p-next;

if (p-x == 0)

{

for (j = 2; jp-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;

}

/*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 - 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-y23)

return 0;

if (Bird-x == p-xBird-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-xBird-yp-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(" Ю123 ■■■\n");

printf("\n");

printf(" ■■■ 欢迎各路大神与我探讨C、\nC++、VB、PHP、C#\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;

}

int main()

{

int i = 0; char ch;

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");

return 0;

}

C/C++游戏开发教程:C语言实现—飞翔的小鸟

在飞翔的小鸟游戏中,玩家只需通过点击方向键操纵让小鸟避开绿色管道等障碍物即可继续前进。如果小鸟碰到管道,游戏立即结束。

那么如何用Java编写一款属于自己的飞翔的小鸟游戏呢?其过程并不复杂,本课程详细讲解了飞翔的小鸟游戏的编写流程,即使你是刚入门Java的新手,只要你简单掌握了该游戏所需要的JavaSE基础知识,便可以跟随教程视频完成属于你自己的飞翔的小鸟游戏!同时还可以加深和巩固你对面向对象知识的理解。 

点击 【Java游戏项目】手把手用Java教你做游戏_FlappyBird飞翔的小鸟   学习吧~~~

       本课程主要是带你了解Java se的基础知识,即便你是零基础的新手也能很快掌握.跟随教程,很快就会制作出这款小游戏,完成属于自己的飞翔的小鸟游戏,同时加深你对基础知识的了解和掌握程度. 

       课程目标:

        1.通过本课程的学习巩固java的相关基础知识,例如循环判断,数组和集合的使用,对象的继承,接口的实现,窗口的创建,事件监听,图形绘制。

       2.完成小鸟的移动,管道自动生成、碰撞死亡,计分系统等功能实现。

        3.将java基础知识与游戏相结合,完成java的入门小游戏,提升java的学习兴趣。

        具体内容包含:

         窗口绘制,游戏背景的绘制,实现小鸟的移动,解决屏幕闪烁问题,云彩的添加与移动,云彩的自动生成与销毁,障碍物自动生成,障碍物对象池,判断小鸟与障碍物发生碰撞,计时功能,按下空格键重新开始游戏,记录的持久化,集合的使用和优化等等,涵盖了基本的游戏思想。 

c语言动画程序会挥动翅膀飞行的小鸟代码,Tc2.0下可运行!代码私信!

#include stdio.h void main()

{

int Password=0,Number=0,price=58,i=0; while( Password != 1234 )

{

if( i = 3 )

return;

i++;

puts("Please input Password: ");

scanf("%d",Password);

} i=0;

while( Number!=price )

{

do{

puts("Please input a number between 1 and 100: ");

scanf("%d",Number);

printf("Your input number is %d\n",Number);

}while( !(Number=1  Number=100) );

if( Number = 90 )

{

printf("Too Bigger! Press any key to try again!\n");

}

else if( Number = 70  Number  90 )

{

printf("Bigger!\n");

}

else if( Number = 1  Number = 30 )

{

printf("Too Small! Press any key to try again!\n");

}

else if( Number  30  Number = 50 )

{

printf("Small! Press any key to try again!\n");

}

else

{

if( Number == price )

{

printf("OK! You are right! Bye Bye!\n");

}

else if( Number  price )

{

printf("Sorry,Only a little smaller! Press any key to try again!\n"); }

else if( Number  price )

printf(" Sorry, Only a little bigger! Press any key to try again!\n");

}

getch();

}

c语言游戏编程,下落的小鸟 求代码

下落的小鸟

#includestdio.h

#includestdlib.h

#includeconio.h

#includetime.h

#includeWindows.h

int Grade = 1, Score = 0, Max_blank = 9, Distance = 18;

struct Birds{int x; int y;};  //定义一种Birds数据类型(含3个成员)

Birds *Bird = (Birds*)malloc(sizeof(Birds));  //定义Birds类型 指针变量Bird并赋初值

struct Bg{int x, y; int l_blank; Bg *pri; Bg *next;};  //定义一种Bg数据类型(含5个成员)

Bg *Bg1 = (Bg*)malloc(sizeof(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 Csh( )  //初始化界面

{

printf("══════════════════════════════════════\n");

printf(" ■■ ■■ C语言版 Flappy Bird \n");

printf(" ■■ ■■\n");

printf(" ■■ ■■\n");

printf(" ■■ ■■ 瞎搞人:yyposs原创\n");

printf(" ■■ ■■ 瞎搞日期:2014.2\n");

printf(" ■■ ■■\n");

printf(" ■■ ■■ 改编:鸣蝉百2021.7\n");

printf(" ■■ ■■ 操作:按向上方向键让小鸟起飞\n");

printf(" ■■\n");

printf(" ■■\n");

printf(" ■■ ■■\n");

printf(" ■■ ■■\n");

printf(" ■■ ■■\n");

printf(" ■■ ■■\n");

printf(" ■■ ■■ DEVc++运行通过\n");

printf("══════════════════════════════════════\n");

printf("  按键继续…");

getch( );

system("cls");

}

void PrFK( )  //输出方框(游戏范围区)

{int i;

Position(1, 1); printf("╔");  Position(79, 1); printf("╗");

Position(1, 24); printf("╚");  Position(79, 24); printf("╝");

for (i = 3; i = 78; i += 2){Position(i, 1); printf("═"); Position(i, 24); printf("═");}

for(i=2;i=23;i++)

{ Position(1,i); printf("║");if(i11)printf("0%d",i-1);else printf("%d",i-1);

Position(79,i); printf("║");

}

Position(4, 25); printf("小鸟即将出现,请准备按键起飞… ");

getch( );

Position(4, 25); printf("                                  ");

}

void CreatBg( )  //创建障碍物坐标(便于打印输出)

{Bg *Bg2 = (Bg*)malloc(sizeof(Bg));

Bg1-x = 90; Bg1-y = 8;  //确定障碍物的一对基本坐标(此时值是在游戏框之外)

Bg2-x = Bg1-x + Distance; Bg2-y = 9;  //下一障碍物的基本坐标x、y

Bg1-l_blank = Max_blank - Grade;  //障碍物上下两部分之间的空白距离l_blank

Bg2-l_blank = Max_blank - Grade;

Bg1-next = Bg2; Bg1-pri = Bg2;

Bg2-next = Bg1; Bg2-pri = Bg1;

}

void InsertBg(Bg *p)  //随机改变障碍物的y坐标,让空白通道有上下变化

{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( );  //产生一个随机数并赋值给temp

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 CreatBird( )  //建立小鸟的坐标(初始打印输出小鸟的位置)

{Bird-x = 41; Bird-y = 10;}

int CheckYN(Bg *q)  //判断游戏结束与否(值为0是要结束,为1没有要结束)

{Bg *p = q; int i = 0;

while (++i = 5)

{if (Bird-y23)return 0;

if (Bird-x == p-xBird-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-xBird-yp-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 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 Prt_Bg(Bg *q)  //打印输出障碍物(依据其x、y坐标进行相应输出)

{Bg *p = q; int i = 0, k, j;

while (++i = 5)

{if (p-x0 p-x = 78)

{for (k = 2; kp-y; k++){Position(p-x + 1, k); printf("■"); printf("■"); printf(" ");}

Position(p-x, p-y);

printf("■"); printf("■"); printf("■"); printf(" ");

Position(p-x, p-y + p-l_blank);

printf("■"); printf("■"); printf("■"); printf(" ");

k = k + p-l_blank + 1;

for (k; k = 23; k++){Position(p-x + 1, k); printf("■"); printf("■"); printf(" ");}

}

p = p-next;

if (p-x == 0)

{for (j = 2; jp-y; j++){Position(p-x + 1, j); printf(" "); printf(" ");}

Position(p-x + 1, p-y);

printf(" "); printf(" "); printf(" ");

Position(p-x + 1, p-y + Max_blank - Grade);

printf(" "); printf(" "); printf(" ");

j = j + Max_blank - Grade + 1;

for (j; j = 22; j++){Position(p-x + 1, j); printf(" "); printf(" ");}

}

}

}

void PrtBird( )  //打印输出小鸟

{Position(Bird-x, Bird-y - 1); printf(" ");

Position(Bird-x, Bird-y); printf("Ю");

Position(38, 2); printf("Score:%d", Score);

}

void Loop_Bg(Bg *q)  //障碍物x坐标左移,并记录成绩

{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 Grade4)Grade++;

}

}

}

int main( )

{int i = 0; int t;

while (1)

{

Csh( );PrFK( );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);printf(" ");

Bird-y = Bird-y - 4;

}

Sleep(200);  //程序延时200毫秒(数值大小决定游戏速度快慢)

i = 0;

}

Position(6, 25);

printf("游戏结束!  请输入:0.退出  1.重玩");

scanf("%d",t);

if (t==0)break;

system("cls"); Score = 0;

}

return 0;

}