Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import turtle
- from random import random
- w = 1000
- h = 800
- s = turtle.Screen()
- #Блок ниже не изменять: ===================
- s.setup(w,h, 0,200) #
- s.setworldcoordinates(0, h, w, 0) #
- s.bgcolor('grey')
- s.title('Our Screen')
- #Конец блока ==============================
- ball = turtle.Turtle()
- ball.shape('circle')
- ball.color('red')
- ball.up()
- plate = turtle.Turtle()
- plate.shape('square')
- plate.shapesize(1,3)
- plate.speed(0)
- plate.color('green')
- plate.up()
- x2 = 200
- y2 = 200
- plate.setposition(x2,y2)
- x = 10
- y = 0
- dx = 10
- dy = 10
- dx2 = 10
- dy2 = 0
- count = 0
- try:
- while True:
- s.update()
- ball.setx(x)
- ball.sety(y)
- y += dy
- x += dx
- if x > w or x < 5:
- dx = -dx
- if y > h or y < 5:
- dy = -dy
- plate.setx(x2)
- plate.sety(y2)
- y2 += dy2
- x2 += dx2
- if x2 >= w-200:
- x2 = w-200
- dy2 = 10
- dx2 = 0
- if y2 > h-200:
- y2 = h - 200
- dx2 = -8
- dy2 = 0
- if x2 < 200:
- x2 = 200
- dx2 = 0
- dy2 = -10
- if y2 < 200:
- y2 = 200
- dx2 = 10
- dy2 = 0
- except Exception as ex:
- exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement