Exemple #1
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 perform(self) :
    # if reload_time has not passed return
    if self.shot_timer.get_num_passed_intervals() < 1 :
        return
    s = self.shot.copy()
    # set a starting position
    s.m.r.pos = self.m.r.pos.copy()
    s.initial_position = self.m.r.pos.copy()
    # set angle
    s.m.r.angle = self.m.r.angle.copy()
    # enqueue in movement
    UpdateEvent.add_action(s.m.fwd)
    # put shot into collider
    Collider.add(s)
    # auto destruction
    UpdateEvent.add_action(s)
    # enqueue in render queue
    RenderQueue.enqueue(s)
    # play a sound
    self.sound.play()