本文实例为大家分享了C语言实现弹跳球游戏的具体代码,供大家参考,具体内容如下
#include
#include
int main()
{
// 球的坐标
int pos_x,pos_y;
//球坐标的变化
int x =0;
int y = 5;
// 定义一个球的速度
int velocity_x=1;
int velocity_y=1;
//定义一个球运动的范围
int top=0;
int botton=20;
int lift=0;
int right=20;
//让球循环来回的跳动
while(1)
{
//x轴的速度变化
x = x + velocity_x;
y = y +velocity_y;
//清屏,用于每次绘图,清除上一次球的位置。
system("cls");
for (pos_x=0 ; pos_x < x; pos_x ++)
{
// y轴每行画换行符。
printf("\n");
}
for ( pos_y =0; pos_y
{
// x轴进行空格即可
printf(" ");
}
//利用速度velocity来控制球移动的