-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
67 lines (59 loc) · 1.59 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
55
56
57
58
59
60
61
62
63
64
65
66
67
from random import randint
from time import sleep
import graphics
import engine
def main():
winX = 440
winY = 660
winCenter = graphics.Point(winX / 2, winY / 2)
winName = "| bullet.heck |"
menu = engine.Menu()
hud = engine.Hud()
player = engine.Player()
window = graphics.GraphWin(winName, winX, winY, autoflush=False)
wallpaper = graphics.Image(winCenter, "assets/space.gif")
window.setBackground("black")
wallpaper.draw(window)
while (window):
menu.main(window)
player.score = 0
player.lives = 4
patternNumber = 0
nextSpawn = randint(125, 160)
player = engine.Player()
patternList = list()
player.draw(window)
hud.draw(window)
hud.update_bar(window, player)
hud.update_score(window, player.score)
while (player.lives > 0):
# Game loop starts here.
press = window.checkKey()
if (player.score % nextSpawn == 0):
nextSpawn = randint(125, 160)
patternList.append(engine.build_attack())
player.hit = False
player.move(press)
for i in range (len(patternList)):
patternList[i].fire(window)
patternList[i].move()
if (patternList[i].detect_hit(player)):
player.hit = True
player.score = player.score + 1
player.update_hitframes()
player.update_lives()
player.update_shield(window)
hud.update_bar(window, player)
hud.update_score(window, player.score)
hud.pause(press, window)
if (player.lives == 0):
for i in range (len(patternList)):
patternList[i].undraw()
player.undraw()
hud.undraw(window)
menu.game_over(window, player.score)
sleep(.03)
graphics.update(30)
# Game loop ends here.
return
main()