Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import stddraw
- xc = .2
- yc = .4
- vx = .01
- vy = .02
- while True:
- stddraw.clear()
- line1 = stddraw.line(.25, .25, .5, .75)
- line2 = stddraw.line(.5, .75, .75, .25)
- line3 = stddraw.line(.25, .25, .75, .25)
- stddraw.point(xc, yc)
- stddraw.show()
- stddraw.show(10)
- if (xc + vx) >= line1 or (xc + vx) <= line2 or (xc + vx) >= line3:
- vx = -vx
- if (yc + vy) >= line1 or (yc + vy) <= line2 or (yc + vy) >= line3:
- vy = -vy
- xc = xc + vx
- yc = yc + vy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement