def load(self): """Load assets saved in asset list. Checks for duplicates and allowed extensions.""" for order in self.manifest: cat = order[1] path = order[0] if cat == 'image': asset = PAL.load_image(path) elif cat == 'audio': asset = PAL.load_sound(path) else: raise Exception('Unsupported asset type.') self.assets[path] = asset
def new_file(self, cv5=None, vf4=None, vx4=None, vr4=None, dddata=None, wpe=None): if cv5: self.cv5 = cv5 else: self.cv5 = CV5() if vf4: self.vf4 = vf4 else: self.vf4 = VF4() if vx4: self.vx4 = vx4 else: self.vx4 = VX4() if vr4: self.vr4 = vr4 else: self.vr4 = VR4() if dddata: self.dddata = dddata else: self.dddata = DDDataBIN() if wpe: self.wpe = wpe else: self.wpe = PAL.Palette()
def __init__(self, level, config, adapter_class): """Setup engine components according to provided configuration and platform.""" # Initialize Platform Abstracion Layer PAL.init() # Setup engine for level self.config = config self.renderer = Renderer(config.resolution, config.fullscreen, theme.white) self.level = level self.level_queue = [] # Set timeout self.timer = PAL.get_clock() # objects = [units.Home(side='left', color=theme.red, rate=10, build_queue=[units.Bot for i in xrange(100)])] self.object_manager = ObjectManager() self.entity_manager = EntityManager() self.interaction_manager = InteractionManager() self.asset_manager = AssetManager(self.level.assets) self.event_manager = EventManager()
def load_file(self, cv5, vf4=None, vx4=None, vr4=None, dddata=None, wpe=None): path = None name = None if isstr(cv5): path = os.path.dirname(cv5) name = os.path.basename(cv5) if name.split(os.extsep)[-1].lower() == 'cv5': name = name[:-4] if not vf4: if not path or not name: raise vf4 = os.path.join(path, '%s%svf4' % (name, os.extsep)) if not vx4: if not path or not name: raise vx4 = os.path.join(path, '%s%svx4ex' % (name, os.extsep)) # Check for and prefer expanded vx4 files if not os.path.exists(vx4): vx4 = os.path.join(path, '%s%svx4' % (name, os.extsep)) if not vr4: if not path or not name: raise vr4 = os.path.join(path, '%s%svr4' % (name, os.extsep)) if not dddata: if not path or not name: raise dddata = os.path.join(path, name, 'dddata%sbin' % os.extsep) if not wpe: if not path or not name: raise wpe = os.path.join(path, '%s%swpe' % (name, os.extsep)) self.cv5 = CV5() self.cv5.load_file(cv5) self.vf4 = VF4() self.vf4.load_file(vf4) self.vx4 = VX4() self.vx4.load_file(vx4) self.vr4 = VR4() self.vr4.load_file(vr4) self.dddata = DDDataBIN() self.dddata.load_file(dddata) self.wpe = PAL.Palette() self.wpe.load_file(wpe) self.cv5_path = cv5 if isstr(cv5) else None self.vf4_path = vf4 if isstr(vf4) else None self.vx4_path = vx4 if isstr(vx4) else None self.vr4_path = vr4 if isstr(vr4) else None self.dddata_path = dddata if isstr(dddata) else None self.wpe_path = wpe if isstr(wpe) else None
def get_target(self): return PAL.get_pointer_position()
def update(self, delta): new_position = PAL.get_pointer_position() self.move(new_position[0]-self.position[0], new_position[1]-self.position[1]) return []
def flip(self): PAL.flip()
def clear(self): PAL.clear_screen(self.surface, self.clear_color)
def quit(self): PAL.quit() sys.exit()
def __init__(self, resolution, fullscreen, clear_color): self.clear_color = clear_color self.surface = PAL.create_surface(resolution, fullscreen)
def get(self): return PAL.get_events()