def get_map(self, name): map = protocol.get_map(self, name) if config.get('load_saved_map', False): cached_path = get_name(map) if os.path.isfile(cached_path): map.data = VXLData(open(cached_path, 'rb')) return map
def load_vxl(self, rot_info): try: fp = open(rot_info.get_map_filename(self.load_dir), 'rb') except OSError: raise MapNotFound(rot_info.name) self.data = VXLData(fp) fp.close()
def apply_default(self): self.map = VXLData() self.slice_map(show_dialog = False) bottom_layer = self.layers[63] bottom_layer.fill(WATER_PEN.rgba()) bottom_layer.dirty = True self.edit_widget.map_updated(self.map) self.set_dirty(False)
def get_map(self, name): map = protocol.get_map(self, name) if LOAD_SAVED_MAP_OPTION.get(): cached_path = get_name(map) print("Loading saved map for {} from {}".format(name, cached_path)) if os.path.isfile(cached_path): map.data = VXLData(open(cached_path, 'rb')) print("Saved map loaded") return map
def open_selected(self): name = QtGui.QFileDialog.getOpenFileName(self, 'Open', self.path, filter = '*.vxl')[0] if not name: return self.filename = name self.map = VXLData(open(name, 'rb')) self.slice_map() self.edit_widget.map_updated(self.map) self.set_dirty(False)
def load_map(self, name): try: data = VXLData(open('../feature_server/maps/%s.vxl' % name, 'rb')) except (IOError): print "Couldn't open map '%s'" % name return False current_time = time() self.navigation = Navigation(data) dt = time() - current_time print 'Navgraph contains %s nodes. Generation took %s' % ( self.navigation.get_node_count(), dt) return True
# pyspades is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pyspades is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with pyspades. If not, see <http://www.gnu.org/licenses/>. from pyspades.vxl import VXLData map = VXLData() for x in xrange(50, 512 - 50): for y in xrange(50, 512 - 50): for z in xrange(20, 58): map.set_point(x, y, z, (20, 20, 30, 40)) for x in range(512): for y in xrange(512): map.set_point(x, y, 62, (20, 20, 30, 40)) map.set_point(x, y, 63, (20, 20, 30, 40)) for z in range(5, 64): map.set_point(256, 256, z, (20, 20, 30, 40)) print 'generating'
from pyglet.window import key import math from pyglet.gl import * fp = None for name in ('../feature_server/maps/pyspades.vxl', './feature_server/maps/pyspades.vxl'): try: fp = open(name, 'rb') except IOError: pass if fp is None: raise SystemExit('no map file found') map = VXLData(fp) fp.close() def on_fall(damage): print 'on fall:', damage new_world = world.World() new_world.map = map character = new_world.create_object(world.Character, Vertex3(20.0, 20.0, 5.0), Vertex3(0.999992012978, 0.0, -0.00399998947978), on_fall) window = pyglet.window.Window(width = 600, height = 600, resizable=True) keyboard = key.KeyStateHandler()
def load_map_from_path(path): with open(path, 'rb') as f: return VXLData(f)