首页 > 其他 > 详细

弹跳的小球(bouncingball.py)

时间:2017-08-04 00:20:31      阅读:258      评论:0      收藏:0      [点我收藏+]
 1 import stddraw
 2 
 3 stddraw.setXscale(-1, 1)
 4 stddraw.setYscale(-1, 1)
 5 
 6 DT = 20.0
 7 RADIUS = 0.05
 8 rx = 0.480
 9 ry = 0.860
10 vx = 0.015
11 vy = 0.023
12 while True:
13     #Update ball position and draw it there.
14     if abs(rx + vx) + RADIUS > 1.0:
15         vx = -vx
16     if abs(ry + vy) + RADIUS > 1.0:
17         vy = -vy
18     rx = rx + vx
19     ry = ry + vy
20     stddraw.clear(stddraw.GRAY)
21     stddraw.filledCircle(rx, ry, RADIUS)
22     stddraw.show(DT)

 

弹跳的小球(bouncingball.py)

原文:http://www.cnblogs.com/cdf4745/p/7282661.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!