comparison pytouhou/game/laser.py @ 279:3539520fff93

Fix sprite rotation/translation. ANM translations are done *after* rotation, lasers are handled differently.
author Thibaut Girka <thib@sitedethib.com>
date Wed, 08 Feb 2012 18:43:39 +0100
parents 615c0bb6064b
children 13dcde917083
comparison
equal deleted inserted replaced
278:615c0bb6064b 279:3539520fff93
20 20
21 STARTING, STARTED, STOPPING = range(3) 21 STARTING, STARTED, STOPPING = range(3)
22 22
23 23
24 class Laser(object): 24 class Laser(object):
25 def __init__(self, pos, laser_type, sprite_idx_offset, 25 def __init__(self, base_pos, laser_type, sprite_idx_offset,
26 angle, speed, start_offset, end_offset, max_length, width, 26 angle, speed, start_offset, end_offset, max_length, width,
27 start_duration, duration, stop_duration, 27 start_duration, duration, stop_duration,
28 grazing_delay, grazing_extra_duration, 28 grazing_delay, grazing_extra_duration,
29 game): 29 game):
30 self._game = game 30 self._game = game
43 self.stop_duration = stop_duration 43 self.stop_duration = stop_duration
44 self.grazing_delay = grazing_delay 44 self.grazing_delay = grazing_delay
45 self.grazing_extra_duration = grazing_extra_duration 45 self.grazing_extra_duration = grazing_extra_duration
46 46
47 self.sprite_idx_offset = sprite_idx_offset 47 self.sprite_idx_offset = sprite_idx_offset
48 self.x, self.y = pos 48 self.base_pos = base_pos
49 self.x, self.y = 0, 0
49 self.angle = angle 50 self.angle = angle
50 self.speed = speed 51 self.speed = speed
51 self.start_offset = start_offset 52 self.start_offset = start_offset
52 self.end_offset = end_offset 53 self.end_offset = end_offset
53 self.max_length = max_length 54 self.max_length = max_length
107 width = 0. 108 width = 0.
108 self._removed = True 109 self._removed = True
109 else: 110 else:
110 width = self.width * (1. - float(self.frame) / self.stop_duration) #TODO 111 width = self.width * (1. - float(self.frame) / self.stop_duration) #TODO
111 112
112 self._sprite.allow_dest_offset = True 113 offset = self.end_offset - length / 2.
113 self._sprite.dest_offset = (0., self.end_offset - length / 2., 0.) 114 self.x, self.y = self.base_pos[0] + offset * cos(self.angle), self.base_pos[1] + offset * sin(self.angle)
114 self._sprite.width_override = width or 0.01 #TODO 115 self._sprite.width_override = width or 0.01 #TODO
115 self._sprite.height_override = length or 0.01 #TODO 116 self._sprite.height_override = length or 0.01 #TODO
116 117
117 self._sprite.update_orientation(pi/2. - self.angle, True) 118 self._sprite.update_orientation(pi/2. - self.angle, True)
118 self._sprite._changed = True #TODO 119 self._sprite._changed = True #TODO