-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
97 lines (74 loc) · 2.72 KB
/
main.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
'''an attempt (however poorly) to recreate the game known as stormrunner from lego
into a python game.
TODO:::
ask pypy if it can help with @propget speeds??
remake map_overlay concept
'''
import sys
try:import cPickle___ as pickle
except: import pickle
import logging
logger = logging.getLogger('main')
import pygame
from pygame.locals import *
import config
import map
import lib.common
import tiles
import input
import load_map
import vehicle
import programmer
def main(options):
pygame.init()
screen = pygame.display.set_mode((800, 600),pygame.SRCALPHA)
#load map tiles...
tiles.find_tiles()
#load map... (can be called again(?) to change to a new map...)
load_map.load_map('test_map')
v=vehicle.rcx()
clock=pygame.time.Clock()
while True:
clock.tick(30)
events = pygame.event.get()
for event in events:
if event.type == QUIT:
pygame.quit()
return None
elif event.type == MOUSEBUTTONDOWN and event.button==1:
logger.info(map.map.click_engine(event.pos))
elif event.type == KEYDOWN:
if event.key == config.keymap['open_menu']:
##to be changed later to actually open a main menu like thingy with save and stuff...
config.change_config(screen)
elif event.key == config.keymap['open_programmer']:
##warning:: blocking code
v.code = programmer.create_programming_gui(screen,v.code)
elif event.key == K_x:
#import cPickle as pickle
f=open('data/saves/test.pkl','wb')
p=pickle.Pickler(f,0)
p.dump(map.map)
p.dump(v)
f.close()
elif event.key == K_z:
#import cPickle as pickle
f=open('data/saves/test.pkl','rb')
unp=pickle.Unpickler(f)
map.map=unp.load()
v=unp.load()
f.close()
##we clear the screen after events because anything that can occur in the events should be 'blocking'
##meaning that they actualy run thier own loop for a bit
screen.fill((0, 0, 0))
map.map.draw(screen)
map.map.update_overlays(screen)
v.events(events)
v.draw(screen)
pygame.display.flip()
if __name__ == '__main__':
if len(sys.argv) > 1:
print 'i really need to add those command line options huh?'
lib.common.debug(int(sys.argv[1]))
lib.common.debug(2)
main(None)