-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
52 lines (38 loc) · 1.31 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import tkinter as tk
import Character
import Gun
import Bullet
import Targets
import Battlefield
import Obstacle
def frame():
ball.move()
ball.jump()
gun.move()
gun.jump()
gun.move_gun()
canvas.bind('<Button-1>', lambda trigger: Bullet.create_bullets(canvas, gun.gun_end_x_axis, # creates bullets
gun.gun_end_y_axis, gun.x_axis,
gun.y_axis, battlefield_events, trigger))
[shell.bullet_fly() for shell in Bullet.bullets if Bullet.bullets]
Bullet.delete_bullets()
if battlefield_events.life_numbers == 0:
top.quit()
Targets.create_targets(canvas)
[target.move() for target in Targets.targets if Targets.targets]
Targets.delete_targets(Bullet.bullets, battlefield_events)
Obstacle.create_obstacles(canvas)
[obstacle.move() for obstacle in Obstacle.obstacles if Obstacle.obstacles]
Obstacle.delete_obstacles(ball, battlefield_events)
top.after(30, frame)
top = tk.Tk()
top.title('Ball game')
canvas = tk.Canvas(top, width=800, height=600, bg='white')
canvas.pack()
battlefield_events = Battlefield.Battlefield(canvas)
ball = Character.Character(canvas)
ball.create()
gun = Gun.Gun(canvas)
gun.create()
frame()
top.mainloop()