From: <cd...@us...> - 2007-01-15 10:09:10
|
Revision: 36 http://eos-game.svn.sourceforge.net/eos-game/?rev=36&view=rev Author: cduncan Date: 2007-01-15 02:09:09 -0800 (Mon, 15 Jan 2007) Log Message: ----------- Cache rotated images so that the image rotations are done and stored only once per image regardless of the number of instances of that image onscreen. Modified Paths: -------------- media.py Modified: media.py =================================================================== --- media.py 2007-01-15 09:43:31 UTC (rev 35) +++ media.py 2007-01-15 10:09:09 UTC (rev 36) @@ -22,20 +22,28 @@ image.set_colorkey(transparent, RLEACCEL) return image.convert(game.screen) +_RotatedImage_cache = {} class RotatedImage: """Pre-rotated image container""" - def __init__(self, img_name, steps=300): - start_img = pygame.image.load('data/%s' % img_name).convert(game.screen) - self.step_angle = fullcircle / steps - self.steps = steps - self._rotated = {} - angle = 0 - for r in range(steps): - self._rotated[r] = optimize_image(pygame.transform.rotate( - start_img, 270 - math.degrees(angle))) - angle += self.step_angle + steps = 300 # Rotational step count + + def __init__(self, img_name): + global _RotatedImage_cache + self.step_angle = fullcircle / self.steps + if (img_name not in _RotatedImage_cache + or len(_RotatedImage_cache[img_name]) != self.steps): + start_img = pygame.image.load('data/%s' % img_name).convert(game.screen) + self._rotated = {} + angle = 0 + for r in range(self.steps): + self._rotated[r] = optimize_image(pygame.transform.rotate( + start_img, 270 - math.degrees(angle))) + angle += self.step_angle + _RotatedImage_cache[img_name] = self._rotated + else: + self._rotated = _RotatedImage_cache[img_name] def rotated(self, radians): """Return an image rotated to radians""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ob...@us...> - 2007-03-22 06:16:09
|
Revision: 150 http://eos-game.svn.sourceforge.net/eos-game/?rev=150&view=rev Author: oberon7 Date: 2007-03-21 23:16:05 -0700 (Wed, 21 Mar 2007) Log Message: ----------- Quickly fadeout the previous track when soundtrack events are coming in quickly Modified Paths: -------------- media.py Modified: media.py =================================================================== --- media.py 2007-03-22 06:03:17 UTC (rev 149) +++ media.py 2007-03-22 06:16:05 UTC (rev 150) @@ -101,5 +101,6 @@ else: sound = load_sound('suspense%02d.wav' % random.randint(1, 6)) sound.set_volume(volume) - game.soundtrack.play(sound) + game.soundtrack.fadeout(1000) + game.soundtrack.queue(sound) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cd...@us...> - 2007-03-26 06:56:18
|
Revision: 159 http://eos-game.svn.sourceforge.net/eos-game/?rev=159&view=rev Author: cduncan Date: 2007-03-25 23:50:47 -0700 (Sun, 25 Mar 2007) Log Message: ----------- - Prevent the same sound effect from being played too close together, this caused strange audio artifacts and wasted audio channels - Increase the minimum volume threshold of sounds to conserve channels. Ironically I can hear more softer sounds with this change than before. Modified Paths: -------------- media.py Modified: media.py =================================================================== --- media.py 2007-03-26 01:31:05 UTC (rev 158) +++ media.py 2007-03-26 06:50:47 UTC (rev 159) @@ -74,6 +74,7 @@ self.images.append(optimize_image(image)) _sound_cache = {} +_sound_last_played = {} def load_sound(name): global _sound_cache @@ -85,15 +86,21 @@ """Play a sound at a particular volume. Return channel where sound will play, None if sound does not actually play """ + global _sound_last_played + last_played = _sound_last_played.get(name, 0) + if game.frame_no - last_played < 4: + # Don't play same sound too close together + return if position is not None: distance = game.camera.position.distance(position) if distance > 0: volume = volume * (700 - distance) / 700 - if volume < 0.02: + if volume < 0.1: return sound = load_sound(name) sound.set_volume(volume) sound.play() # avoids the reserved soundtrack channel + _sound_last_played[name] = game.frame_no def play_soundtrack(large=False, volume=0.6): if large: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cd...@us...> - 2007-09-11 06:27:54
|
Revision: 246 http://eos-game.svn.sourceforge.net/eos-game/?rev=246&view=rev Author: cduncan Date: 2007-09-10 23:27:48 -0700 (Mon, 10 Sep 2007) Log Message: ----------- - Increase the sprite cache to help performance when lots of ships are on-screen Modified Paths: -------------- media.py Modified: media.py =================================================================== --- media.py 2007-09-11 04:32:46 UTC (rev 245) +++ media.py 2007-09-11 06:27:48 UTC (rev 246) @@ -88,7 +88,7 @@ self.purged += 1 self._aged.popitem() -_scaled_image_cache = Cache(2000) +_scaled_image_cache = Cache(6000) def scale_image(image, scale, colorkey=False): scaled_width = int(image.get_rect().width * scale) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cd...@us...> - 2007-10-26 18:45:49
|
Revision: 315 http://eos-game.svn.sourceforge.net/eos-game/?rev=315&view=rev Author: cduncan Date: 2007-10-26 11:45:46 -0700 (Fri, 26 Oct 2007) Log Message: ----------- Fix white planet pointy Modified Paths: -------------- media.py Modified: media.py =================================================================== --- media.py 2007-10-26 18:45:20 UTC (rev 314) +++ media.py 2007-10-26 18:45:46 UTC (rev 315) @@ -222,7 +222,7 @@ set_image('pointy-planet-blue', planet_pointy_image((55, 80, 216))) set_image('pointy-planet-green', planet_pointy_image((0, 155, 38))) set_image('pointy-planet-red', planet_pointy_image((216, 36, 30))) - set_image('pointy-planet-white', pointy_image((255, 255, 255))) + set_image('pointy-planet-white', planet_pointy_image((255, 255, 255))) _sound_cache = {} _sound_last_played = {} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |