• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Oct 23rd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import tkinter
2. import random
3. canvas = tkinter.Canvas(height=500,width=500)
4. canvas.pack()
5.
6. pocet_bodov=0
7. x=random.randrange(500)
8. y=20
9. a=0
10. b=490
11. lop_x=random.randrange(500)
12. lop_y=20
13. def kresli_lopticku(x, y):
14.     canvas.create_oval(x-10,y-10,x+10,y+10,fill='red')
15.
16.
17. def kresli_kurzor(a, b):
18.     canvas.create_line(a,b,a+70,b,fill='blue',width=10)
19.
20.
21. def vypis_body(pocet_bodov):
22.     canvas.create_text(100,10,text='pocet bodov')
23.     canvas.create_text(200,10,text=pocet_bodov)
24.
25.
26. def timer1():
27.     global lop_x,lop_y,a,b
28.     canvas.delete('all')
29.     lop_x=lop_x
30.     lop_y=lop_y+7
31.     kresli_lopticku(lop_x, lop_y)
32.     kresli_kurzor(a, b)
33.     if lop_y>480:
34.         lop_y=20
35.         lop_x=random.randrange(500)
36.
37.
38.     canvas.after(10, timer1)
39.
40.
41. def posun(klaves):
42.     global a,b,lop_x,lop_y
43.     if klaves.keysym=='Left':
44.         a=a-10
45.     if klaves.keysym=='Right':
46.         a=a+10
47.     canvas.delete('all')
48.     kresli_lopticku(lop_x,lop_y)
49.     kresli_kurzor(a,b)
50.     vypis_body(pocet_bodov)
51.
52.
53.
54.
55.
56. timer1()
57. canvas.bind_all('<Left>', posun)
58. canvas.bind_all('<Right>', posun)
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.

Top