Changeset 474:9e85c30dd12f


Ignore:
Timestamp:
04/09/11 19:35:28 (12 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Phase:
public
Rebase:
61376439666435396665316133306235303761373935303062366131653334393432653531383233
Message:

Animate signal fire

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/sprites/items.py

    r473 r474  
    1 from .. import engine
     1from .. import engine, data
    22from .base import Item, PC_LAYER, PROJECTILE_LAYER
     3
     4import time
    35
    46
     
    140142    image_file = 'props/signal_fire/signal_fire_unlit.png'
    141143
     144    animation_files = ['props/signal_fire/signal_fire_lit01.png',
     145            'props/signal_fire/signal_fire_lit02.png',
     146            'props/signal_fire/signal_fire_lit03.png',
     147            'props/signal_fire/signal_fire_lit04.png']
     148
     149    wants_updates = True
     150
    142151    def setup(self, litness, **opts):
    143152        super(SignalFire, self).setup(**opts)
     153        self._last_time = None
     154        self._frame = 0
     155        self.animations = [data.load_image(self.image_dir + x) for x in self.animation_files]
    144156
    145157
     
    165177            self.world.missions.fire_started_on_road = True
    166178
     179    def update(self):
     180        if self._me.litness != 'burning':
     181            return
     182        if self._last_time is None:
     183            self._last_time = time.time()
     184            return
     185        if time.time() - self._last_time > 0.1:
     186            self._last_time = time.time()
     187            self._frame += 1
     188            if self._frame >= len(self.animations):
     189                self._frame = 0
     190            pos = self.rect.midbottom
     191            self.image = self.animations[self._frame]
     192            self.rect = self.image.get_rect(midbottom=pos)
     193            self.collide_rect = self.rect.move(0, 0)
     194
    167195
    168196##################################################
Note: See TracChangeset for help on using the changeset viewer.