forked from AzyCrw4282/CS1830-papaya
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.py
54 lines (38 loc) · 1.22 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
53
54
import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
from Vector import Vector
from Weapon import Weapon
from WeaponCollision import WeaponCollision
from Wall import Wall
import random
CANVAS_WIDTH = 1600
CANVAS_HEIGHT = 900
rockets = []
C = WeaponCollision()
w2 = Wall(500, 5, 'red')
w4 = Wall(1200, 5, 'red')
C.addWall(w2)
C.addWall(w4)
def spawn(key):
global CANVAS_WIDTH, CANVAS_HEIGHT
if key == simplegui.KEY_MAP['space']:
missile = Weapon(Vector((CANVAS_WIDTH/2, CANVAS_HEIGHT/2)), Vector((random.randint(-5,5), random.randint(-5,5))), 'https://i.imgur.com/RVi7F76.png',
4, 4)
C.addWeapon(missile)
def up(key):
pass
def draw(canvas):
global CANVAS_WIDTH, CANVAS_HEIGHT
if rockets.__len__() == 5:
rockets[0].explosion = True
for missile in rockets:
if missile.explosion:
C.weapons.remove(missile)
else:
missile.update()
missile.draw(canvas)
frame = simplegui.create_frame("Test", CANVAS_WIDTH, CANVAS_HEIGHT)
frame.set_draw_handler(C.draw)
frame.set_keydown_handler(spawn)
frame.set_keyup_handler(up)
# Start the frame animation
frame.start()