-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_gui.py
58 lines (35 loc) · 1.29 KB
/
main_gui.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
from pyglet.gl import glClearColor
from scenes import SceneManager, UsernameSelectScene
from constants import GRID_SIZE
import pyglet.sprite
USERNAME = ""
window = pyglet.window.Window(width=GRID_SIZE * 5, height=GRID_SIZE * 5 + 50)
window.config.alpha_size = 8
# Create a human player:
scene_manager = SceneManager()
scene_manager.add_scene("USERNAME", UsernameSelectScene(scene_manager, window))
scene_manager.change_scene("USERNAME")
@window.event
def on_mouse_drag(x, y, dx, dy, buttons, modifiers):
scene_manager.current_scene.on_mouse_drag(x, y, dx, dy, buttons, modifiers)
@window.event
def on_mouse_motion(x, y, dx, dy):
scene_manager.current_scene.on_mouse_motion(x, y, dx, dy)
@window.event
def on_mouse_release(x, y, buttons, modifiers):
scene_manager.current_scene.on_mouse_release(x, y, buttons, modifiers)
@window.event
def on_mouse_press(x, y, button, modifiers):
scene_manager.current_scene.on_mouse_press(x, y, button, modifiers)
@window.event
def on_key_press(symbol, modifiers):
scene_manager.current_scene.on_key_press(symbol, modifiers)
@window.event
def on_text(text):
scene_manager.current_scene.on_text(text)
@window.event
def on_draw():
glClearColor(0, 0, 0, 1)
window.clear()
scene_manager.current_scene.on_draw(window)
pyglet.app.run()