def load_shot(sbuf) : s = Shot() s.m.fwd.ups = fp.read_named_float(sbuf, "v=") s.travel_distance = fp.read_named_float(sbuf, "travel_distance=") s.damage = fp.read_named_int(sbuf, "damage=") load_game_object(sbuf, s) return s
def load_ship(filename) : s = Ship() buf = open(filename, 'r').read().replace('\n', '') s.num_slots = fp.read_named_int(buf, "num_slots=") s.hp = fp.read_named_int(buf, "hp=") s.m.fwd.ups = fp.read_named_float(buf, "vf") s.m.bwd.ups = fp.read_named_float(buf, "vb") s.m.sll.ups = s.m.slr.ups = fp.read_named_float(buf, "vslide=") s.m.tr.ups = s.m.tl.ups = fp.read_named_float(buf, "turn_rate=") s.m.max_speed = fp.read_named_float(buf, "max_speed=") s.m.dec = fp.read_named_float(buf, "dec=") UpdateEvent.add_action(s.m) load_game_object(buf, s) for i in range(s.num_slots) : wbuf = fp.read_named_string(buf, "slot{0}=".format(i+1), "[") s.children.append(load_weapon(fp.read_named_string(wbuf, "weapon="))) s.slot_positions.append(np.array([0.0, 0.0, 0.0, 1.0])) s.slot_positions[i][0] = fp.read_named_float(wbuf, "position_x") s.slot_positions[i][1] = fp.read_named_float(wbuf, "position_y") s.m.sub_movements.append(s.children[i].m) return s
def load(filename) : a = Animation() buf = open(filename, 'r').read() a.m.r.width = FileParser.read_named_float(buf, "width:", "\"") a.m.r.height = FileParser.read_named_float(buf, "height:", "\"") tex_name = FileParser.read_named_string(buf, "texture:", "\"") tex = Texture() ImgLoader.load_image(tex_name, tex) a.set_texture(tex) sp_name = FileParser.read_named_string(buf, "solid_pixel_map", "\"") if len(sp_name) > 0 : spm = SolidPixelMap() ImgLoader.load(sp_name, spm) a.spm = spm trans_name = FileParser.read_named_string(buf, "transparency_map:", "\"") if len(trans_name) > 0 : tmap = TransparencyMap() ImgLoader.load(trans_name, tmap) a.get_texture.apply_transparency_map(tmap) a.num_frames = FileParser.read_named_int(buf, "num_frames:", "\"") a.st.set_interval(FileParser.read_named_float(buf, "frame_time:", "\"")) if FileParser.read_named_int(buf, "looping:", "\"") == 1 : a.looping = True return a