def load_game_object(buf, o) :
   o.m.r.width = fp.read_named_float(buf, "width=")
   o.m.r.height = fp.read_named_float(buf, "height=")
   tex = Texture()
   il.load_image(fp.read_named_string(buf, "tex="), tex)
   o.set_texture(tex)
   sdanim = fp.read_named_string(buf, "dest_anim=") 
   sdsound = fp.read_named_string(buf, "dest_sound=")
   if len(sdanim) != 0 :
      o.dest_anim = AnimationLoader.load(sdanim)
   if len(sdsound) != 0 :
      o.dest_sound = sl.load(sdsound)
Exemple #2
0
 def test(self) :
    StateMachine.Kamera.forward_position = -4.0
    self.bb = Billboard()
    self.bb2 = Billboard()
    self.bba = []
    self.ship = load_ship("object/crusader.txt")
    self.tex = Texture()
    self.tex2 = Texture()
    self.aie = []
    input_nums = [sdl.SDL_SCANCODE_UP, sdl.SDL_SCANCODE_DOWN, sdl.SDL_SCANCODE_RIGHT, sdl.SDL_SCANCODE_LEFT, sdl.SDL_SCANCODE_W, sdl.SDL_SCANCODE_S, sdl.SDL_SCANCODE_D, sdl.SDL_SCANCODE_A]
    m = StateMachine.Kamera.mov
    StateMachine.Kamera.follow(self.ship.m)
    movs = [m.fwd, m.bwd, m.tr, m.tl]
    m = self.ship.m
    bbmovs = [m.fwd, m.bwd, m.tr, m.tl]
    movs += bbmovs
    bbmovs += movs
    for i in range(7) :
       self.aie.append(InputEvt())
       self.aie[i].input_nr = input_nums[i]
       ActionEvtModel.add_trigger(self.aie[i])
       self.keyb.register_input_evt(self.aie[i])
       self.aie[i].add_action(bbmovs[i])
    # weapon trigger test
    self.shoot_evt = InputEvt()
    #self.shoot_evt.input_nr = sdl.SDL_SCANCODE_SPACE
    self.shoot_evt.input_nr = 1
    ActionEvtModel.add_trigger(self.shoot_evt)
    self.mouse.register_input_evt(self.shoot_evt)
    self.shoot_evt.add_action(self.ship.children[0])
    self.shoot_evt.add_action(self.ship.children[1])
    #self.shoot_evt.add_action(self.ship.children[2])
    ImgLoader.load_image("image/crusader.png", self.tex)
    ImgLoader.load_image("image/1.png", self.tex2)
    self.bb.set_texture(self.tex)
    self.bb.gen_vbo()
    self.bb2.set_texture(self.tex2)
    for i in range(30) :
       self.bba.append(load_ship("object/crusader.txt"))
       self.bba[i].containers.append(self.bba)
       #self.bba[i].gen_dl()
       self.bba[i].gen_vbo()
       #self.bba[i].gen_va()
       self.rand_vector(self.bba[i], 5.0)
       Collider.add(self.bba[i])
       RenderQueue.enqueue(self.bba[i])
    self.anim = AnimationLoader.load("object/bomb_anim.txt")
    self.anim.st.start()
    RenderQueue.enqueue(self.anim)
    RenderQueue.enqueue(self.bb2)
    RenderQueue.enqueue(self.ship)
    RenderQueue.enqueue(self.bb)
    UpdateEvent.add_trigger(StateMachine.Kamera)
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