⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bounce.c

📁 This is an animation of bouncing ball..
💻 C
字号:
// bouncing BallProgram
#include <graphics.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>

main(void)
{
int maxx,maxy,area,x=25,y=25,ch,xdir=1,ydir=1;{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "");



while(!kbhit())
{
setcolor(15);
rectangle(0,0,getmaxx(),getmaxy());
outtextxy(200,1,"Press ESC to EXIT...!");

setcolor(14);

x=x+(xdir*5);
y=y+(ydir*2);

circle(x,y,25);

setfillstyle(WIDE_DOT_FILL,2);
floodfill(x+5,y+5,14);

delay(10);

setfillstyle(SOLID_FILL,0);
floodfill(x+5,y+5,14);

setcolor(0);
circle(x,y,25);
floodfill(x+2,y+2,0);

if(x>getmaxx()-25||x<25)
{
sound(5000);
delay(40);
sound(3000);
delay(40);
nosound();
xdir*=-1;
}
if(y>getmaxy()-25||y<25)
{
sound(5000);
delay(40);
sound(3000);
delay(40);
nosound();
ydir*=-1;
}
}
getch();
closegraph();
restorecrtmode();
return 0;
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -