Beispiel #1
0
 def stop_focusing(self):
     self.orb_dx_interpolator = Interpolator((8, ), self._game.frame,
                                             (24, ), self._game.frame + 8,
                                             lambda x: x**2)
     self.orb_dy_interpolator = Interpolator((-32, ), self._game.frame,
                                             (0, ), self._game.frame + 8)
     self.focused = False
Beispiel #2
0
 def start_focusing(self):
     self.orb_dx_interpolator = Interpolator((24, ), self._game.frame,
                                             (8, ), self._game.frame + 8,
                                             lambda x: x**2)
     self.orb_dy_interpolator = Interpolator((0, ), self._game.frame,
                                             (-32, ), self._game.frame + 8)
     self.focused = True
Beispiel #3
0
 def stop_focusing(self):
     self.orb_dx_interpolator = Interpolator((8,), self._game.frame,
                                             (24,), self._game.frame + 8,
                                             lambda x: x ** 2)
     self.orb_dy_interpolator = Interpolator((-32,), self._game.frame,
                                             (0,), self._game.frame + 8)
     self.focused = False
Beispiel #4
0
 def start_focusing(self):
     self.orb_dx_interpolator = Interpolator((24,), self._game.frame,
                                             (8,), self._game.frame + 8,
                                             lambda x: x ** 2)
     self.orb_dy_interpolator = Interpolator((0,), self._game.frame,
                                             (-32,), self._game.frame + 8)
     self.focused = True
Beispiel #5
0
class Player(PlayerBase):
    def __init__(self, number, anm, shts, character, continues):
        self.sht = shts[0]
        self.focused_sht = shts[1]

        PlayerBase.__init__(self, number, anm, character, continues, power=-1)

        self.orbs = [Orb(anm, 128, self),
                     Orb(anm, 129, self)]

        self.orbs[0].offset_x = -24
        self.orbs[1].offset_x = 24

        self.orb_dx_interpolator = None
        self.orb_dy_interpolator = None


    def start_focusing(self):
        self.orb_dx_interpolator = Interpolator((24,), self._game.frame,
                                                (8,), self._game.frame + 8,
                                                lambda x: x ** 2)
        self.orb_dy_interpolator = Interpolator((0,), self._game.frame,
                                                (-32,), self._game.frame + 8)
        self.focused = True


    def stop_focusing(self):
        self.orb_dx_interpolator = Interpolator((8,), self._game.frame,
                                                (24,), self._game.frame + 8,
                                                lambda x: x ** 2)
        self.orb_dy_interpolator = Interpolator((-32,), self._game.frame,
                                                (0,), self._game.frame + 8)
        self.focused = False


    @property
    def objects(self):
        return [self] + (self.orbs if self.power >= 8 else [])


    def update(self, keystate):
        PlayerBase.update(self, keystate)

        if self.death_time == 0 or self._game.frame - self.death_time > 60:
            if self.orb_dx_interpolator:
                self.orb_dx_interpolator.update(self._game.frame)
                dx, = self.orb_dx_interpolator.values
                self.orbs[0].offset_x = -dx
                self.orbs[1].offset_x = dx
            if self.orb_dy_interpolator:
                self.orb_dy_interpolator.update(self._game.frame)
                dy, = self.orb_dy_interpolator.values
                self.orbs[0].offset_y = dy
                self.orbs[1].offset_y = dy

        for orb in self.orbs:
            orb.update()
Beispiel #6
0
class Player(PlayerBase):
    def __init__(self, number, anm, shts, character, continues):
        self.sht = shts[0]
        self.focused_sht = shts[1]

        PlayerBase.__init__(self, number, anm, character, continues, power=-1)

        self.orbs = [Orb(anm, 128, self), Orb(anm, 129, self)]

        self.orbs[0].offset_x = -24
        self.orbs[1].offset_x = 24

        self.orb_dx_interpolator = None
        self.orb_dy_interpolator = None

    def start_focusing(self):
        self.orb_dx_interpolator = Interpolator((24, ), self._game.frame,
                                                (8, ), self._game.frame + 8,
                                                lambda x: x**2)
        self.orb_dy_interpolator = Interpolator((0, ), self._game.frame,
                                                (-32, ), self._game.frame + 8)
        self.focused = True

    def stop_focusing(self):
        self.orb_dx_interpolator = Interpolator((8, ), self._game.frame,
                                                (24, ), self._game.frame + 8,
                                                lambda x: x**2)
        self.orb_dy_interpolator = Interpolator((-32, ), self._game.frame,
                                                (0, ), self._game.frame + 8)
        self.focused = False

    @property
    def objects(self):
        return [self] + (self.orbs if self.power >= 8 else [])

    def update(self, keystate):
        PlayerBase.update(self, keystate)

        if self.death_time == 0 or self._game.frame - self.death_time > 60:
            if self.orb_dx_interpolator:
                self.orb_dx_interpolator.update(self._game.frame)
                dx, = self.orb_dx_interpolator.values
                self.orbs[0].offset_x = -dx
                self.orbs[1].offset_x = dx
            if self.orb_dy_interpolator:
                self.orb_dy_interpolator.update(self._game.frame)
                dy, = self.orb_dy_interpolator.values
                self.orbs[0].offset_y = dy
                self.orbs[1].offset_y = dy

        for orb in self.orbs:
            orb.update()
Beispiel #7
0
    def __init__(self, stage, anm):
        self.stage = stage
        self.anm = anm
        self.last_frame = -1

        self.models = []
        self.object_instances = []
        self.anm_runners = []

        self.position_interpolator = Interpolator((0, 0, 0))
        self.fog_interpolator = Interpolator((0, 0, 0, 0, 0))
        self.position2_interpolator = Interpolator((0, 0, 0))

        self.build_models()
        self.build_object_instances()
Beispiel #8
0
    def __init__(self, stage, anm):
        self.stage = stage
        self.anm = anm
        self.last_frame = -1

        self.models = []
        self.object_instances = []
        self.anm_runners = []

        self.position_interpolator = Interpolator((0, 0, 0))
        self.fog_interpolator = Interpolator((0, 0, 0, 0, 0))
        self.position2_interpolator = Interpolator((0, 0, 0))

        self.build_models()
        self.build_object_instances()
Beispiel #9
0
class Background:
    def __init__(self, stage, anm):
        self.stage = stage
        self.anm = anm
        self.last_frame = -1

        self.models = []
        self.object_instances = []
        self.anm_runners = []

        self.position_interpolator = Interpolator((0, 0, 0))
        self.fog_interpolator = Interpolator((0, 0, 0, 0, 0))
        self.position2_interpolator = Interpolator((0, 0, 0))

        self.build_models()
        self.build_object_instances()

    def build_object_instances(self):
        self.object_instances = []
        for model_id, ox, oy, oz in self.stage.object_instances:
            self.object_instances.append(
                (ox, oy, oz, model_id, self.models[model_id]))
        # Z-sorting:
        # TODO z-sorting may be needed at each iteration
        def keyfunc(obj):
            return obj[2] + self.stage.models[obj[3]].bounding_box[2]

        self.object_instances.sort(key=keyfunc, reverse=True)

    def build_models(self):
        self.models = []
        for obj in self.stage.models:
            quads = []
            for script_index, ox, oy, oz, width_override, height_override in obj.quads:
                sprite = Sprite(width_override, height_override)
                anm_runner = ANMRunner(self.anm, script_index, sprite)
                quads.append(
                    (ox, oy, oz, width_override, height_override, sprite))
                self.anm_runners.append(anm_runner)
            self.models.append(quads)

    def update(self, frame):
        for frame_num, message_type, args in self.stage.script:
            if self.last_frame < frame_num <= frame:
                if message_type == 0:
                    self.position_interpolator.set_interpolation_start(
                        frame_num, args)
                elif message_type == 1:
                    self.fog_interpolator.set_interpolation_end_values(args)
                elif message_type == 2:
                    self.position2_interpolator.set_interpolation_end_values(
                        args)
                elif message_type == 3:
                    duration, = args
                    self.position2_interpolator.set_interpolation_end_frame(
                        frame_num + duration)
                elif message_type == 4:
                    duration, = args
                    self.fog_interpolator.set_interpolation_end_frame(
                        frame_num + duration)
            if frame_num > frame and message_type == 0:
                self.position_interpolator.set_interpolation_end(
                    frame_num, args)
                break

        for i in range(frame - self.last_frame):
            for anm_runner in tuple(self.anm_runners):
                if not anm_runner.run_frame():
                    self.anm_runners.remove(anm_runner)

        self.position2_interpolator.update(frame)
        self.fog_interpolator.update(frame)
        self.position_interpolator.update(frame)

        self.last_frame = frame
Beispiel #10
0
class Background:
    def __init__(self, stage, anm):
        self.stage = stage
        self.anm = anm
        self.last_frame = -1

        self.models = []
        self.object_instances = []
        self.anm_runners = []

        self.position_interpolator = Interpolator((0, 0, 0))
        self.fog_interpolator = Interpolator((0, 0, 0, 0, 0))
        self.position2_interpolator = Interpolator((0, 0, 0))

        self.build_models()
        self.build_object_instances()


    def build_object_instances(self):
        self.object_instances = []
        for model_id, ox, oy, oz in self.stage.object_instances:
            self.object_instances.append((ox, oy, oz, model_id, self.models[model_id]))
        # Z-sorting:
        # TODO z-sorting may be needed at each iteration
        def keyfunc(obj):
            return obj[2] + self.stage.models[obj[3]].bounding_box[2]
        self.object_instances.sort(key=keyfunc, reverse=True)


    def build_models(self):
        self.models = []
        for obj in self.stage.models:
            quads = []
            for script_index, ox, oy, oz, width_override, height_override in obj.quads:
                sprite = Sprite(width_override, height_override)
                anm_runner = ANMRunner(self.anm, script_index, sprite)
                quads.append((ox, oy, oz, width_override, height_override, sprite))
                self.anm_runners.append(anm_runner)
            self.models.append(quads)


    def update(self, frame):
        for frame_num, message_type, args in self.stage.script:
            if self.last_frame < frame_num <= frame:
                if message_type == 0:
                    self.position_interpolator.set_interpolation_start(frame_num, args)
                elif message_type == 1:
                    self.fog_interpolator.set_interpolation_end_values(args)
                elif message_type == 2:
                    self.position2_interpolator.set_interpolation_end_values(args)
                elif message_type == 3:
                    duration, = args
                    self.position2_interpolator.set_interpolation_end_frame(frame_num + duration)
                elif message_type == 4:
                    duration, = args
                    self.fog_interpolator.set_interpolation_end_frame(frame_num + duration)
            if frame_num > frame and message_type == 0:
                self.position_interpolator.set_interpolation_end(frame_num, args)
                break

        for i in range(frame - self.last_frame):
            for anm_runner in tuple(self.anm_runners):
                if not anm_runner.run_frame():
                    self.anm_runners.remove(anm_runner)

        self.position2_interpolator.update(frame)
        self.fog_interpolator.update(frame)
        self.position_interpolator.update(frame)

        self.last_frame = frame