comparison pytouhou/game/background.py @ 69:a142e57218a0

Refactor. Move VMs to pytouhou.vm.
author Thibaut Girka <thib@sitedethib.com>
date Sat, 27 Aug 2011 10:58:54 +0200
parents ab826bc29aa2
children 6a08f44fa01b
comparison
equal deleted inserted replaced
68:a2459defd4b6 69:a142e57218a0
17 import os 17 import os
18 import struct 18 import struct
19 from itertools import chain 19 from itertools import chain
20 20
21 from pytouhou.utils.interpolator import Interpolator 21 from pytouhou.utils.interpolator import Interpolator
22 from pytouhou.vm.anmrunner import ANMRunner
22 from pytouhou.game.sprite import Sprite 23 from pytouhou.game.sprite import Sprite
23 24
24 25
25 class Background(object): 26 class Background(object):
26 def __init__(self, stage, anm_wrapper): 27 def __init__(self, stage, anm_wrapper):
70 self.objects = [] 71 self.objects = []
71 for i, obj in enumerate(self.stage.objects): 72 for i, obj in enumerate(self.stage.objects):
72 faces = [] 73 faces = []
73 for script_index, ox, oy, oz, width_override, height_override in obj.quads: 74 for script_index, ox, oy, oz, width_override, height_override in obj.quads:
74 #TODO: per-texture rendering 75 #TODO: per-texture rendering
75 anm, sprite = self.anm_wrapper.get_sprite(script_index) 76 sprite = Sprite()
76 if sprite.update(): 77 anm_runner = ANMRunner(self.anm_wrapper, script_index, sprite)
78 anm_runner.run_frame()
79 sprite.update()
80 if sprite._changed:
77 sprite.update_vertices_uvs_colors(width_override, height_override) 81 sprite.update_vertices_uvs_colors(width_override, height_override)
78 uvs, vertices = sprite._uvs, tuple((x + ox, y + oy, z + oz) for x, y, z in sprite._vertices) 82 uvs, vertices = sprite._uvs, tuple((x + ox, y + oy, z + oz) for x, y, z in sprite._vertices)
79 colors = sprite._colors 83 colors = sprite._colors
80 faces.append((vertices, uvs, colors)) 84 faces.append((vertices, uvs, colors))
81 self.objects.append(faces) 85 self.objects.append(faces)