def update(self, td):
        self.health.update()

        if self.state == STATE_SPAWN:
            # Stay inactive until the beaming in animation is done
            if not self.sprite.cursor.playing:
                self.state = STATE_ALIVE

        if self.state == STATE_DEAD:
            # Kill the sprite after the beaming out animation is done playing, then respawn
            if not self.sprite.cursor.playing:
                self.kill()
                statemgr.get("play").respawn()
        else:
            if self.state == STATE_ALIVE:
                self.hurt_timer -= td
                self.updateControls(td)

            was_on_ground = self.mapcollide.on_ground

            self.physics.update(td)

            if self.state == STATE_ALIVE:
                if not was_on_ground and self.mapcollide.on_ground:
                    self.sound_land.play()

                for tile, tile_pos, pixel_pos in self.mapcollide.iterTiles():
                    self.processTile(td, tile, tile_pos, pixel_pos)

            self.collider.update()
            self.collider.collide(self.obj_mgr.player_touchable)

        self.updateAnim(td)
 def update(self, td):
     self.collider.update()
     self.delay -= td
     if self.state == 0:
         # Flying down
         if self.y < self.dest_y:
             self.jet_sprite.updateAnim(td)
             self.y += self.speed * td
             if self.y > self.dest_y:
                 self.sound.stop()
                 self.y = self.dest_y
                 self.jet_sprite.setVisibility(False)
                 self.spawnPlayer()
                 statevars.variables["map"]["ship_landed"] = True
                 self.state = 1
     elif self.state == 2:
         # Flying up
         if self.y > self.dest_y:
             self.jet_sprite.updateAnim(td)
             self.y -= self.speed * td
         else:
             statemgr.get("play").nextLevel()
             pass
     else:
         pass
 def spriteCollide(self, gameobject, collider):
     """Since this is in the player_touchable group, this will only be called when the player touches the coin."""
     self.sound.play()
     self.kill()
     # Keep track of this coin being collected so it will stay gone after saving and loading.
     if statevars.variables["map"].get("coins") == None:
         statevars.variables["map"]["coins"] = [self.name]
     else:
         statevars.variables["map"]["coins"].append(self.name)
     statemgr.get("play").getCoin()
 def sideTravel(self, side, mapfile, spawnpoint):
     if self.travel_time <= 0:
         statemgr.get("play").transitionMap(mapfile, spawnpoint)
         self.state = STATE_TRAVEL
         self.anim_state = ANIM_WAIT
         self.travel_time = 1000
         if side == "left":
             self.physics.vx = -0.2
             self.physics.vy = 0
             #self.sprite.play("run_l")
         else:
             self.physics.vx = 0.2
             self.physics.vy = 0
    def update(self, td):
        self.health.update()

        if self.state == STATE_SPAWN:
            # Stay inactive until the beaming in animation is done
            if not self.sprite.cursor.playing:
                self.state = STATE_ALIVE

        elif self.state == STATE_OUTHOUSE_IN:
            if not self.sprite.cursor.playing:
                self.sprite.play("door_exit")
                self.state = STATE_OUTHOUSE_OUT

        elif self.state == STATE_OUTHOUSE_OUT:
            if not self.sprite.cursor.playing:
                self.sprite.play("stand_r")
                self.state = STATE_ALIVE
                self.anim_state = ANIM_STAND

        elif self.state == STATE_TRAVEL:
            self.travel_time -= td
            if self.travel_time < 0:
                self.state = STATE_ALIVE
                self.anim_state = ANIM_RUN
                self.solidcollider.on_ground = True
            else:
                self.x += self.physics.vx * td

        elif self.state == STATE_DEAD:
            # Kill the sprite after the beaming out animation is done playing, then respawn
            self.physics.update(td)
            if not self.sprite.cursor.playing:
                #self.kill()
                self.state = STATE_WAIT
                statemgr.get("play").respawn()
        else:
            if self.state == STATE_ALIVE:
                self.hurt_timer -= td
                self.updateControls(td)

            was_on_ground = self.solidcollider.on_ground

            self.physics.update(td)

            if self.state == STATE_ALIVE:
                if not was_on_ground and self.solidcollider.on_ground:
                    try:   
                        self.sound_land.play()
                    except:
                        print 'error playing sound'

                for tile, tile_pos, pixel_pos in self.solidcollider.mapcollider.iterTiles():
                    self.processTile(td, tile, tile_pos, pixel_pos)

            self.collider.update()
            self.collider.collide(self.obj_mgr.player_touchable)

            if self.y > self.scene.tilemap.pixel_height + 100:
                self.die()

        self.updateAnim(td)
 def enterDoor(self, mapfile, spawnpoint):
     self.sprite.play("door_enter")
     self.state = STATE_WAIT
     self.anim_state = ANIM_SPAWN
     statemgr.get("play").transitionMap(mapfile, spawnpoint)