1 Star 0 Fork 0

陈安平 / good

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
xiaoniaoshengjiban.cpp 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
陈安平 提交于 2019-06-16 10:14 . auto
#include <graphics.h>
#include <conio.h>
#pragma comment(lib,"Winmm.lib")
IMAGE img_bk, img_bd1, img_bd2, img_bar_up1, img_bar_up2, img_bar_down1, img_bar_down2; int bird_x;
int bird_y;
void startup()
{
initgraph(350, 600);
loadimage(&img_bk, "C:\\fly bird\\background.jpg");
loadimage(&img_bd1, "C:\fly bird\\bird1.jpg");
loadimage(&img_bd2, "C:\\fly bird\\bird2.jpg");
loadimage(&img_bar_up1, "C:\\fly bird\\bar_up1.gif");
loadimage(&img_bar_up2, "C:\\fly bird\\bar_up2.gif");
loadimage(&img_bar_down1, "C:\\fly bird\\bar_down1.gif");
loadimage(&img_bar_down2, "C:\\fly bird\\bar_down2.gif");
bird_x = 50;
bird_y = 200;
BeginBatchDraw();
mciSendString("open C:\\fly bird\\background.mp3 alias bkmusic", NULL, 0, NULL);
mciSendString("play bkmusic repeat", NULL, 0, NULL);
}
void show()
{
putimage(0, 0, &img_bk);
putimage(150, -300, &img_bar_up1, NOTSRCERASE);
putimage(150, -300, &img_bar_up2, SRCINVERT);
putimage(150, 400, &img_bar_down1, NOTSRCERASE);
putimage(150, 400, &img_bar_down2, SRCINVERT);
putimage(bird_x, bird_y, &img_bd1, NOTSRCERASE);
putimage(bird_x, bird_y, &img_bd2, SRCINVERT);
FlushBatchDraw();
Sleep(50);
}
void updateWithoutInput()
{
if (bird_y < 500)
bird_y = bird_y + 3;
}
void updateWithInput()
{
char input;
if (_kbhit())
{
input = _getch();
if (input == ' ' && bird_y > 20)
{
bird_y = bird_y - 60;
mciSendString("close jpmusic", NULL, 0, NULL);
mciSendString("open C:\\fly bird\\Jump.mp3 alias jpmusic", NULL, 0, NULL);
mciSendString("play jpmusic", NULL, 0, NULL);
}
}
}
void gameover()
{
EndBatchDraw();
_getch();
closegraph();
}
int main()
{
startup();
while (1)
{
show();
updateWithoutInput();
updateWithInput();
}
gameover();
return 0;
}
C
1
https://gitee.com/chenanping/good.git
git@gitee.com:chenanping/good.git
chenanping
good
good
master

搜索帮助