1 Star 0 Fork 91

闫治宇 / c-game

forked from 一壶李 / c-game 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ball 675 Bytes
一键复制 编辑 原始数据 按行查看 历史
闫治宇 提交于 2020-10-09 10:24 . add ball.
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
int i,j;
int x = 0;
int y = 5;
int velocity_x = 1;
int velocity_y = 1;
int left = 0;
int right = 20;
int top = 0;
int bottom = 10;
while (1)
{
x = x + velocity_x;
y = y + velocity_y;
system("cls"); // 清屏函数
// 输出小球前的空行
for(i=0;i<x;i++)
printf("\n");
for (j=0;j<y;j++)
printf(" ");
printf("o"); // 输出小球o
printf("\n");
Sleep(50); // 等待若干毫秒
if ((x==top)||(x==bottom))
velocity_x = -velocity_x;
if ((y==left)||(y==right))
velocity_y = -velocity_y;
}
return 0;
}
1
https://gitee.com/yan-zhiyu/c-game.git
git@gitee.com:yan-zhiyu/c-game.git
yan-zhiyu
c-game
c-game
master

搜索帮助