-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMapEngine.py
217 lines (170 loc) · 7.35 KB
/
MapEngine.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import pygame
from pygame.locals import *
from mapping import *
import sys
G_RESOLUTION = None
G_SCREEN = None
G_FILLSURF = None
G_BACKSURF = None
G_CLOCK = None
INIT_RUN = False
def INIT_PYGAME(RESOLUTION=(800,600)):
global INIT_RUN
if(not INIT_RUN):
pygame.init()
global G_RESOLUTION,G_SCREEN,G_FILLSURF,G_BACKSURF,G_CLOCK
G_RESOLUTION = RESOLUTION
G_SCREEN = pygame.display.set_mode(RESOLUTION)
G_SCREEN.fill((255,255,255))
G_FILLSURF = pygame.Surface(G_RESOLUTION)
G_FILLSURF.fill((255,255,255))
G_BACKSURF = pygame.Surface((10000,10000))
G_CLOCK = pygame.time.Clock()
pygame.display.update()
INIT_RUN=True
main_loop("")
def main_loop(imap):
mapp = []
pPoints = []
p2Points = []
otherPoints = []
# current_map = MAP('maps/gukbottom_1.txt')
#current_map = MAP('showeq-maps-1.0/maps/guktop.map')
current_map = MAP('showeq-maps-1.0/maps/guka.map')
current_map.render(4,False)
EXIT = False
RATIO = 1
MOVE_SPEED = 10
zoom = False
X=0
Y=0
mouse_pos = 0
while not EXIT:
G_CLOCK.tick(60)
for event in pygame.event.get():
#print event
if event.type == QUIT:
sys.exit()
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
#EXIT=True
sys.exit()
elif event.key == K_UP:
Y = Y-MOVE_SPEED*RATIO
print Y
elif event.key == K_DOWN:
Y = Y+MOVE_SPEED*RATIO
print Y
elif event.key == K_LEFT:
X = X+MOVE_SPEED*RATIO
print X
elif event.key == K_RIGHT:
X = X-MOVE_SPEED*RATIO
print X
elif event.key == K_q:
RATIO = RATIO + 1
elif event.key == K_a:
if RATIO > 0:
RATIO = RATIO - 1
elif event.key == K_z:
if zoom == False:
zoom = True
else:
zoom = False
else:
pass
if event.type == MOUSEBUTTONDOWN:
print event.button
print pygame.mouse.get_pressed()
mouse_pos = pygame.mouse.get_rel()
if event.type == MOUSEBUTTONUP:
mouse_pos = pygame.mouse.get_rel()
Y = Y + mouse_pos[1]
X = X + mouse_pos[0]
if event.type == MOUSEBUTTONDOWN and event.button == 4:
print RATIO
if RATIO > 1:
RATIO = RATIO - 1
current_map.render(RATIO,zoom)
else:
RATIO = 1
if event.type == MOUSEBUTTONDOWN and event.button == 5:
RATIO = RATIO + 1
current_map.render(RATIO,zoom)
G_SCREEN.blit(G_FILLSURF,(0,0))
G_SCREEN.blit(current_map.surface, (X,Y))
pygame.display.flip()
# mapp = []
# pPoints = []
# p2Points = []
# otherPoints = []
# fillSurf = pygame.Surface((800,600))
# fillSurf.fill((255,255,255))
# backSurf = pygame.Surface((10000,10000))
# southro = MAP('maps/mistmoore_1.txt')
# southro.render(4,False)
# EXIT = False
# RATIO = 1
# MOVE_SPEED = 10
# zoom = False
# screen.blit(fillSurf,(0,0))
# pygame.display.flip()
# clock = pygame.time.Clock()
# X=0
# Y=0
# mouse_pos = 0
# while not EXIT:
# clock.tick(60)
# for event in pygame.event.get():
# #print event
# if event.type == QUIT:
# sys.exit()
# if event.type == KEYDOWN:
# if event.key == K_ESCAPE:
# #EXIT=True
# sys.exit()
# elif event.key == K_UP:
# Y = Y-MOVE_SPEED*RATIO
# print Y
# elif event.key == K_DOWN:
# Y = Y+MOVE_SPEED*RATIO
# print Y
# elif event.key == K_LEFT:
# X = X+MOVE_SPEED*RATIO
# print X
# elif event.key == K_RIGHT:
# X = X-MOVE_SPEED*RATIO
# print X
# elif event.key == K_q:
# RATIO = RATIO + 1
# elif event.key == K_a:
# if RATIO > 0:
# RATIO = RATIO - 1
# elif event.key == K_z:
# if zoom == False:
# zoom = True
# else:
# zoom = False
# else:
# pass
# if event.type == MOUSEBUTTONDOWN:
# print event.button
# print pygame.mouse.get_pressed()
# mouse_pos = pygame.mouse.get_rel()
# if event.type == MOUSEBUTTONUP:
# mouse_pos = pygame.mouse.get_rel()
# Y = Y + mouse_pos[1]
# X = X + mouse_pos[0]
# if event.type == MOUSEBUTTONDOWN and event.button == 4:
# print RATIO
# if RATIO > 1:
# RATIO = RATIO - 1
# southro.render(RATIO,zoom)
# else:
# RATIO = 1
# if event.type == MOUSEBUTTONDOWN and event.button == 5:
# RATIO = RATIO + 1
# southro.render(RATIO,zoom)
# screen.blit(fillSurf,(0,0))
# screen.blit(southro.surface, (X,Y))
# pygame.display.flip()