Mercurial > touhou
comparison pytouhou/game/background.py @ 111:340fcda8e64a
Fix a few, minor things
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Tue, 06 Sep 2011 21:28:44 +0200 |
parents | 2a03940deea3 |
children | 4300a832f033 |
comparison
equal
deleted
inserted
replaced
110:3ac41b966fed | 111:340fcda8e64a |
---|---|
37 | 37 |
38 def build_object_instances(self): | 38 def build_object_instances(self): |
39 self.object_instances = [] | 39 self.object_instances = [] |
40 for model_id, ox, oy, oz in self.stage.object_instances: | 40 for model_id, ox, oy, oz in self.stage.object_instances: |
41 self.object_instances.append((ox, oy, oz, model_id, self.models[model_id])) | 41 self.object_instances.append((ox, oy, oz, model_id, self.models[model_id])) |
42 # Z-sorting | 42 # Z-sorting: |
43 # TODO z-sorting may be needed at each iteration | |
43 def keyfunc(obj): | 44 def keyfunc(obj): |
44 bounding_box = self.stage.models[obj[3]].bounding_box | 45 return obj[2] + self.stage.models[obj[3]].bounding_box[2] |
45 return obj[2] + min(bounding_box[2], bounding_box[5]) | |
46 self.object_instances.sort(key=keyfunc, reverse=True) | 46 self.object_instances.sort(key=keyfunc, reverse=True) |
47 | 47 |
48 | 48 |
49 def build_models(self): | 49 def build_models(self): |
50 self.models = [] | 50 self.models = [] |
51 for obj in self.stage.models: | 51 for obj in self.stage.models: |
52 quads = [] | 52 quads = [] |
53 for script_index, ox, oy, oz, width_override, height_override in obj.quads: | 53 for script_index, ox, oy, oz, width_override, height_override in obj.quads: |
54 #TODO: per-texture rendering | |
55 sprite = Sprite() | 54 sprite = Sprite() |
56 anm_runner = ANMRunner(self.anm_wrapper, script_index, sprite) | 55 anm_runner = ANMRunner(self.anm_wrapper, script_index, sprite) |
57 anm_runner.run_frame() | 56 anm_runner.run_frame() |
58 sprite.update(width_override, height_override) | 57 sprite.update(width_override, height_override) |
59 quads.append((ox, oy, oz, width_override, height_override, sprite)) | 58 quads.append((ox, oy, oz, width_override, height_override, sprite)) |