环境:EasyX图形库, Visual Studio 2010
y轴方向上类似重力加速下降,有反弹.x轴方向上速度递减.也有反弹
#include#include #include int main() { float y = 50; float vy = 6; float g = 0.5; float vx = 1; float x = 20; initgraph(600, 600); while(1){ vy += g; y += vy; if(y >=580) vy = -0.95*vy; if(y > 580){ y = 580; } x += vx; if(x >= 580) vx = - 0.9*vx; if(x < 20) vx = -0.9*vx; cleardevice(); fillcircle(x, y, 20); Sleep(10); }
运行后的动态效果(没法上传视频,这里仅支持视频的链接)



