弹跳小球
来源:互联网 发布:网络主播怎么招聘 编辑:程序博客网 时间:2024/05/17 02:15
jump_ball_1
# include <stdio.h>
# include <stdlib.h># include <conio.h>
# include <windows.h>
/*
弹跳小球:
画布 20*10
小球位置 10*5
画布 left top right bottom
速度 velocity_x velocity_y
*/
int main()
{
int ball_x = 0, ball_y = 5;
int left = 0, top = 0, right = 20, bottom = 10; //画布
int position_x = bottom / 2, position_y = right / 2; //小球的位置
int velocity_x = 1, velocity_y = 1;//速度
int bottom_black, right_black; //小球上面的空行和左面的空格
while (1)
{
ball_x = ball_x + velocity_x;
ball_y = ball_y + velocity_y;
system("cls");
for (bottom_black = 0; bottom_black <ball_x; bottom_black++)
printf("\n");
for (right_black = 0; right_black < ball_y; right_black++)
printf(" ");
printf("o");
/* 不能这样写的原因是因为小球的位置是不断变化的
//画出小球
for (bottom_black = 0; bottom_black <ball_x ; bottom_black++)
{
for (right_black = 0; right_black < ball_y; right_black++)
{
if ((bottom_black == position_x) && (right_black == position_y))
printf("o");
else printf(" ");
}
printf("\n");
}*/
Sleep(50);
if ((ball_x == top) || (ball_x == bottom))
velocity_x = -velocity_x;
if ((ball_y == left) || (ball_y == right))
velocity_y = -velocity_y;
}
_getch();
return 0;
}
此程序来自学习知乎童星老师的作品,本人由于在一个不太好的学校,所以只能靠自学来度日。
0 0
- 小球弹跳
- 弹跳小球
- 小球弹跳
- 弹跳小球 V1.0
- 弹跳的小球
- 小球弹跳递归
- 小球弹跳:UI2-2
- Java-小球弹跳问题
- 小球反复弹跳问题
- canvas例子一弹跳小球
- css3 小球 弹跳 坠落 效果
- 实例学习:弹跳的小球
- canvas demo-小球弹跳游戏
- PlayerMaker小球随机弹跳练习
- JAVA 多线程 经典实例-弹跳小球
- 【Android】弹跳的小球——SurfaceView
- HTML Canvas实例 曲线弹跳的小球
- [maya学习笔记(17)] 小球弹跳
- L1-040. 最佳情侣身高差
- matlab编程笔记
- Leetcode-103. Binary Tree Zigzag Level Order Traversal
- [BZOJ1717][Usaco2006 Dec]Milk Patterns 产奶的模式(后缀数组)
- 解决fatal: No remote repository specified. Please, specify either a URL...
- 弹跳小球
- 报数游戏,滑动解锁,蓝桥
- 数据挖掘算法之贝叶斯网络
- c语言中全局变量在多个文件中使用
- 523. Continuous Subarray Sum
- Qt5--学习笔记-调用笔记本电脑摄像头
- 提取分块图片的特征
- 近200篇机器学习&深度学习资料分享(含各种文档,视频,源码等)
- Android studio修改项目名