Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. import stddraw
  2.  
  3. xc = .2
  4. yc = .4
  5. vx = .01
  6. vy = .02
  7.  
  8. while True:
  9.     stddraw.clear()
  10.     line1 = stddraw.line(.25, .25, .5, .75)
  11.     line2 = stddraw.line(.5, .75, .75, .25)
  12.     line3 = stddraw.line(.25, .25, .75, .25)
  13.     stddraw.point(xc, yc)
  14.     stddraw.show()
  15.     stddraw.show(10)
  16.     if (xc + vx) >= line1 or (xc + vx) <= line2 or (xc + vx) >= line3:
  17.         vx = -vx
  18.     if (yc + vy) >= line1 or (yc + vy) <= line2 or (yc + vy) >= line3:
  19.         vy = -vy
  20.     xc = xc + vx
  21.     yc = yc + vy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement