forked from kunwon1/UGUIR
/
helloworld.py
executable file
·69 lines (62 loc) · 1.86 KB
/
helloworld.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
68
69
import pyglet
from pyglet.window.key import *
from spritesheet import *
from gamemap import *
from constants import *
from msgbox import msgBox
from minimap import miniMap
mbox = msgBox()
map = Map(width=60, height=70)
map.updateViewport(VIEWPORT_W,VIEWPORT_H)
minimap = miniMap(map=map, pos=MINIMAP_POS)
window = pyglet.window.Window(width=WINDOW_W, height=WINDOW_H)
outline = pyglet.resource.image('outline.png')
outline = pyglet.sprite.Sprite(outline)
outline.set_position(OUTLINE_X, OUTLINE_Y)
@window.event
def on_text_motion(motion):
if map.player.dead:
return
if motion == MOTION_UP:
map.player.moveOrAttack(map, UP)
elif motion == MOTION_RIGHT:
map.player.moveOrAttack(map, RIGHT)
elif motion == MOTION_DOWN:
map.player.moveOrAttack(map, DOWN)
elif motion == MOTION_LEFT:
map.player.moveOrAttack(map, LEFT)
else:
return
@window.event
def on_key_press(symbol, modifiers):
if map.player.dead:
return
if symbol == NUM_1:
map.player.moveOrAttack(map, DOWN_LEFT)
elif symbol == NUM_7:
map.player.moveOrAttack(map, UP_LEFT)
elif symbol == NUM_9:
map.player.moveOrAttack(map, UP_RIGHT)
elif symbol == NUM_3:
map.player.moveOrAttack(map, DOWN_RIGHT)
elif symbol == NUM_8:
map.player.moveOrAttack(map, UP)
elif symbol == NUM_6:
map.player.moveOrAttack(map, RIGHT)
elif symbol == NUM_2:
map.player.moveOrAttack(map, DOWN)
elif symbol == NUM_4:
map.player.moveOrAttack(map, LEFT)
else:
return
@window.event
def on_draw():
window.clear()
outline.draw()
map.updateViewport(VIEWPORT_W,VIEWPORT_H)
mbox.draw()
map.batch.draw()
map.player.draw()
map.player.statuswindow.draw()
minimap.draw()
pyglet.app.run()