-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_test1.py
162 lines (114 loc) · 4.81 KB
/
main_test1.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
import sys
import os
import threading
from Queue import Queue
import pygame
from pygame.locals import *
from mapping import *
pygame.init()
screen = pygame.display.set_mode((800,600))
screen.fill((255,255,255))
pygame.display.update()
mapp = []
pPoints = []
p2Points = []
otherPoints = []
fillSurf = pygame.Surface((800,600))
fillSurf.fill((255,255,255))
backSurf = pygame.Surface((10000,10000))
INPT ="DEFAULT"
class IOFace(threading.Thread):
def run(self):
print "ioface run!"
global INPT
try:
INPT = input(">")
print INPT
except:
print "bad!"
MAP_LIST = []
def loadMaps(location):
try:
for f in os.listdir(location):
m = MAP(location+'/'+f)
MAP_LIST.append(m)
except:
print "DOH!"
loadMaps('maps')
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
class MAIN(threading.Thread):
def run(self):
global X,Y,RATIO,MOVE_SPEED,zoom,clock
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()
q = Queue(2)
INP = IOFace()
M = MAIN()
INP.start()
M.start()
INP.join()
M.join(0.01)