comparison pytouhou/game/background.py @ 332:bdcf2077e368

Add a boss rush mode
author Thibaut Girka <thib@sitedethib.com>
date Sat, 30 Jun 2012 20:10:45 +0200
parents 4300a832f033
children c9433188ffdb
comparison
equal deleted inserted replaced
331:1b4f04b08729 332:bdcf2077e368
20 20
21 class Background(object): 21 class Background(object):
22 def __init__(self, stage, anm_wrapper): 22 def __init__(self, stage, anm_wrapper):
23 self.stage = stage 23 self.stage = stage
24 self.anm_wrapper = anm_wrapper 24 self.anm_wrapper = anm_wrapper
25 self.last_frame = -1
25 26
26 self.models = [] 27 self.models = []
27 self.object_instances = [] 28 self.object_instances = []
28 self.anm_runners = [] 29 self.anm_runners = []
29 30
59 self.models.append(quads) 60 self.models.append(quads)
60 61
61 62
62 def update(self, frame): 63 def update(self, frame):
63 for frame_num, message_type, args in self.stage.script: 64 for frame_num, message_type, args in self.stage.script:
64 if frame_num == frame: 65 if self.last_frame < frame_num <= frame:
65 if message_type == 0: 66 if message_type == 0:
66 self.position_interpolator.set_interpolation_start(frame_num, args) 67 self.position_interpolator.set_interpolation_start(frame_num, args)
67 elif message_type == 1: 68 elif message_type == 1:
68 self.fog_interpolator.set_interpolation_end_values(args) 69 self.fog_interpolator.set_interpolation_end_values(args)
69 elif message_type == 2: 70 elif message_type == 2:
76 self.fog_interpolator.set_interpolation_end_frame(frame_num + duration) 77 self.fog_interpolator.set_interpolation_end_frame(frame_num + duration)
77 if frame_num > frame and message_type == 0: 78 if frame_num > frame and message_type == 0:
78 self.position_interpolator.set_interpolation_end(frame_num, args) 79 self.position_interpolator.set_interpolation_end(frame_num, args)
79 break 80 break
80 81
81 for anm_runner in tuple(self.anm_runners): 82 for i in range(frame - self.last_frame):
82 if not anm_runner.run_frame(): 83 for anm_runner in tuple(self.anm_runners):
83 self.anm_runners.remove(anm_runner) 84 if not anm_runner.run_frame():
85 self.anm_runners.remove(anm_runner)
84 86
85 self.position2_interpolator.update(frame) 87 self.position2_interpolator.update(frame)
86 self.fog_interpolator.update(frame) 88 self.fog_interpolator.update(frame)
87 self.position_interpolator.update(frame) 89 self.position_interpolator.update(frame)
88 90
91 self.last_frame = frame
92