НП
Size: a a a
НП
OM
КК
O
O
OM
OM
НП
from tkinter import *
from random import randrange as rnd, choice
root = Tk()
root.geometry('800x600+500+50')
canv = Canvas(root, bg='white')
canv.pack(fill=BOTH, expand=1)
colors = ['red', 'orange', 'yellow', 'green', 'blue']
x, y, r = 0, 0, 0
goal = 0
def new_ball():
global x, y, r
x = rnd(100, 700)
y = rnd(100, 500)
r = rnd(30, 50)
new_ball_id = canv.create_oval(x - r, y - r, x + r, y + r, fill=choice(colors), width=0)
def new_score(event):
global goal
if ((event.x - x)**2 + (event.y - y)**2)**0.5 <= r:
goal += 1
print(goal)
canv.delete('all')
new_ball()
canv.update()
new_ball()
canv.bind('<Button-1>', new_score)
mainloop()
O
O
OM
OM
m
RC
m
RC
RC
m
m
OM