SHARE
TWEET

Untitled

a guest Feb 27th, 2020 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import turtle
  2. from random import random
  3. w = 1000
  4. h = 800
  5. s = turtle.Screen()
  6. #Блок ниже не изменять: ===================
  7. s.setup(w,h, 0,200)            #
  8. s.setworldcoordinates(0, h, w, 0)  #
  9. s.bgcolor('grey')
  10. s.title('Our Screen')
  11.  
  12. #Конец блока ==============================
  13.  
  14. ball = turtle.Turtle()
  15. ball.shape('circle')
  16. ball.color('red')
  17. ball.up()
  18.  
  19. plate = turtle.Turtle()
  20. plate.shape('square')
  21. plate.shapesize(1,3)
  22. plate.speed(0)
  23. plate.color('green')
  24. plate.up()
  25. x2 = 200
  26. y2 = 200
  27. plate.setposition(x2,y2)
  28.  
  29. x = 10
  30. y = 0
  31. dx = 10
  32. dy = 10
  33.  
  34. dx2 = 10
  35. dy2 = 0
  36.  
  37.  
  38. count = 0
  39. try:
  40.     while True:
  41.         s.update()
  42.         ball.setx(x)
  43.         ball.sety(y)
  44.         y += dy
  45.         x += dx
  46.         if x > w or x < 5:
  47.             dx = -dx
  48.         if y > h or y < 5:
  49.             dy = -dy
  50.         plate.setx(x2)
  51.         plate.sety(y2)
  52.         y2 += dy2
  53.         x2 += dx2
  54.         if x2 >= w-200:
  55.             x2 = w-200
  56.             dy2 = 10
  57.             dx2 = 0
  58.         if y2 > h-200:
  59.             y2 = h - 200
  60.             dx2 = -8
  61.             dy2 = 0
  62.         if x2 < 200:
  63.             x2 = 200
  64.             dx2 = 0
  65.             dy2 = -10
  66.         if y2 < 200:
  67.             y2 = 200
  68.             dx2 = 10
  69.             dy2 = 0        
  70.            
  71. except Exception as ex:
  72.     exit()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top