SaveText.Ru

Без имени
  1. from random import *
  2. from turtle import *
  3. from time import sleep
  4. tracer(0, 0)
  5. def bg():
  6.     goto(0, -500)
  7.     color('black')
  8.     begin_fill()
  9.     circle(10000)
  10. score = 0
  11. x1 = 0
  12. y1 = 0
  13. size1 = 50
  14. hideturtle()
  15. width(5)
  16.  
  17. sc = getscreen()
  18.  
  19. def rect(x, y, size = 50):
  20.     goto(x, y)
  21.     penup()
  22.     fd(size / 2)
  23.     rt(90)
  24.     fd(size / 2)
  25.     rt(90)
  26.     pendown()
  27.     color('red')
  28.     begin_fill()
  29.     for i in range(4):
  30.         fd(size)
  31.         rt(90)
  32.     color('blue')
  33.     end_fill()
  34.     penup()
  35.  
  36. def start(x, y):
  37.    
  38.     global x1, y1, size1, score
  39.     if x < x1 + size1/2 and x > x1 - size1/2 and y < y1 + size1/2 and y > y1 - size1/2:
  40.         x1 = randint(-400, 400)
  41.         y1 = randint(-400, 400)
  42.         size1 = randint(50, 150)
  43.         score +=1
  44.        
  45.     #clear()
  46.     sleep(0.1)
  47.     #bg()
  48.     rect(x1, y1, size1)
  49.     goto(250, 250)
  50.    
  51.     rect(265, 265, 75)
  52.     goto(250, 250)
  53.     color('pink')
  54.     write(score, False, align='left', font=('Arial', 25,'normal'))
  55.     update()
  56. sc.onclick(start, btn = 1, add = None)
  57.  
  58. update()

Share with your friends:

Print