-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockbuster.py
61 lines (51 loc) · 1.58 KB
/
blockbuster.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
"""
The main file of the BlockBuster. Run it to play and have fun!
"""
from gamedata import Assets
from gameclock import GameClock
from pygame import init
from pygame.display import set_caption, set_icon, set_mode, get_surface, flip
from pygame.event import get
from constants import LEVEL_WIDTH, LEVEL_HEIGHT
from GameStateMenu import GameStateMenu
import Tkinter as Tk
if __name__ == '__main__':
ROOT = Tk.Tk()
ROOT.withdraw()
init()
Assets.load_images()
GAME_ICON = Assets.gameIcon
set_caption('BlockBuster')
set_icon(GAME_ICON)
# WINDOW = set_mode((LEVEL_WIDTH, LEVEL_HEIGHT))
set_mode((LEVEL_WIDTH, LEVEL_HEIGHT))
SCREEN = get_surface()
flip()
CONTEXT = dict()
GAMESTATE = GameStateMenu(CONTEXT, SCREEN)
CONTEXT["gamestate"] = GAMESTATE
# noinspection PyUnusedLocal
def _update(_):
"""
Pump events to the current GameState and tell its objects to update
:param _: unused dt provided by GameClock
:return:
"""
events = get()
CONTEXT["gamestate"].handle_input(events)
CONTEXT["gamestate"].update()
# gamestate.handle_input(events)
# gamestate.update()
# noinspection PyUnusedLocal
def _draw(_):
"""
Ask the current GameState to redraw itself
:param _: unused interp provided by GameClock
:return:
"""
# gamestate.draw()
CONTEXT["gamestate"].draw()
flip()
CLOCK = GameClock(max_ups=60, max_fps=60, update_callback=_update, frame_callback=_draw)
while True:
CLOCK.tick()