Changeset 36

Show
Ignore:
Timestamp:
08/29/08 14:38:04 (4 months ago)
Author:
skit
Message:

Refacto de la partie engine + particle

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • project/trunk/example/particle/explosion.py

    r35 r36  
    55from pyxoo.particle import DisplayObjectParticle 
    66 
    7 RESOLUTION = 1680, 105
    8 COLOR = 255,150,
     7RESOLUTION = 800, 60
     8MAX_FPS = 12
    99 
    10 class App(pyxoo.engine.Application): 
    11     def init(self): 
     10class ExplosionSample(pyxoo.engine.Application): 
     11    def onInitApp(self, event): 
    1212        if sys.platform == "win32": 
    1313            os.environ["SDL_VIDEODRIVER"] = "windib"         
    1414        pygame.init() 
    15         self.screen = pygame.display.set_mode(RESOLUTION,pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.FULLSCREEN, 32) 
     15        self.screen = pygame.display.set_mode(RESOLUTION, pygame.HWSURFACE | pygame.DOUBLEBUF, 32) 
    1616        self.bg = pygame.Surface(self.screen.get_size()).convert() 
    1717         
    18         self.input_dispatcher.add_event_listener(pyxoo.event.onQuitEVENT, self.onQuit) 
    19         self.input_dispatcher.add_event_listener(pyxoo.event.onKeyboardKeyDownEVENT, self.onQuit) 
    20         self.input_dispatcher.add_event_listener(pyxoo.event.onMouseButtonDownEVENT, self.onClick) 
     18        self.add_event_listener(pyxoo.event.onQuitEVENT, self.onQuit) 
     19        self.add_event_listener(pyxoo.event.onKeyboardKeyDownEVENT, self.onQuit) 
     20        self.add_event_listener(pyxoo.event.onMouseButtonDownEVENT, self.onClick) 
    2121                 
    2222        self.monitor = pyxoo.utils.monitor.Monitor() 
     
    3232        action = pyxoo.particle.action.StackAction() 
    3333        action.append(pyxoo.particle.action.LifeAction()) 
    34         action.append(pyxoo.particle.action.ForceAction(pyxoo.structure.Point(0,60))) 
     34        action.append(pyxoo.particle.action.ForceAction(pyxoo.structure.Point(0, 60))) 
    3535        action.append(pyxoo.particle.action.MoveAction()) 
    3636        action.append(pyxoo.particle.action.OutOfBoxDeadAction(self.screen.get_rect())) 
     
    3939        self.system = pyxoo.particle.system.SimpleParticleSystem(initializer, action, renderer) 
    4040         
    41     def update(self): 
     41    def onTick(self, event): 
    4242        self.all_sprites.update() 
    4343         
    44     def draw(self): 
    45         self.screen.blit(self.bg,(0,0)) 
     44    def onDraw(self, event): 
     45        pygame.display.flip() 
     46        self.screen.fill(pygame.Color("black")) 
    4647        self.all_sprites.draw(self.screen) 
    4748         
    4849    def onClick(self, event): 
    4950        x, y = event.get_value().pos 
    50         emission = pyxoo.particle.emission.ByRateLimitedEmission(DisplayObjectParticle, pyxoo.structure.Point( x, y ), 500, 200, 100) 
     51        emission = pyxoo.particle.emission.ByRateLimitedEmission(DisplayObjectParticle, pyxoo.structure.Point(x, y), 500, 200, 100) 
    5152        self.system.emit(emission) 
    5253     
     
    5657 
    5758if __name__ == '__main__': 
    58     App().run() 
     59    app = ExplosionSample(MAX_FPS) 
     60    app.run() 
  • project/trunk/example/particle/fountain.py

    r35 r36  
    33import pygame, pyxoo, math, random, os, sys 
    44 
    5 RESOLUTION = 1680, 1050 
    6 COLOR = 0,255,255 
    75 
    8 class App(pyxoo.engine.Application): 
    9     def init(self): 
     6RESOLUTION = 800, 600 
     7MAX_FPS = 120 
     8 
     9class FountainSample(pyxoo.engine.Application): 
     10    def onInitApp(self, event): 
    1011        if sys.platform == "win32": 
    1112            os.environ["SDL_VIDEODRIVER"] = "windib" 
    1213        pygame.init() 
    13         self.screen = pygame.display.set_mode(RESOLUTION,pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.FULLSCREEN, 32) 
    14         self.bg = pygame.Surface(self.screen.get_size()).convert() 
    15         self.input_dispatcher.add_event_listener(pyxoo.event.onQuitEVENT, self.onQuit) 
    16         self.input_dispatcher.add_event_listener(pyxoo.event.onKeyboardKeyDownEVENT, self.onQuit) 
    17          
     14        self.screen = pygame.display.set_mode(RESOLUTION, pygame.HWSURFACE | pygame.DOUBLEBUF, 32) 
     15        pygame.mouse.set_visible(False) 
     16 
     17        self.add_event_listener(pyxoo.event.onQuitEVENT, self.onQuit) 
     18        self.add_event_listener(pyxoo.event.onKeyboardKeyDownEVENT, self.onKeyboardKeyDown) 
     19 
    1820        self.monitor = pyxoo.utils.monitor.Monitor() 
    19         self.monitor.add_field(pyxoo.utils.monitor.FPSField(self.clock, 100, (0, 0, 255))) 
    20         self.monitor.add_field(pyxoo.utils.monitor.ParticleField(3000, (255,0,0))) 
     21        self.monitor.add_field(pyxoo.utils.monitor.FPSField(self.clock, 300, (0, 0, 255))) 
     22        self.monitor.add_field(pyxoo.utils.monitor.ParticleField(3000, (255, 0, 0))) 
    2123        self.monitor.start() 
    2224        self.all_sprites = pygame.sprite.RenderPlain((self.monitor)) 
    2325         
    2426        initializer = pyxoo.particle.initializer.StackInitializer() 
    25         initializer.append(pyxoo.particle.initializer.ImageClassInitializer(pyxoo.displayobject.Star, 5)) 
     27        initializer.append(pyxoo.particle.initializer.ImageClassInitializer(pyxoo.displayobject.Dot, 5, pygame.Color('white'), 1)) 
    2628        initializer.append(pyxoo.particle.initializer.LifeInitializer(3000, 1000)) 
    27         #initializer.append(pyxoo.particle.initializer.ExplosionInitializer(400, pyxoo.structure.Range(math.pi-.1, math.pi+.1), 50)) 
    28         initializer.append(pyxoo.particle.initializer.ExplosionInitializer(400, pyxoo.structure.Range(math.pi*-.25, math.pi*.25), 50)) 
     29        initializer.append(pyxoo.particle.initializer.ExplosionInitializer(400, pyxoo.structure.Range(math.pi - .1, math.pi + .1), 50)) 
    2930         
    3031        action = pyxoo.particle.action.StackAction() 
    3132        action.append(pyxoo.particle.action.LifeAction()) 
    32         action.append(pyxoo.particle.action.ForceAction(pyxoo.structure.Point(0,90))) 
    33         #action.append(pyxoo.particle.action.ForceAction(pyxoo.structure.Point(50,0))) 
     33        action.append(pyxoo.particle.action.ForceAction(pyxoo.structure.Point(50, 90))) 
    3434        action.append(pyxoo.particle.action.FrictionAction(.995)) 
    3535        action.append(pyxoo.particle.action.MoveAction()) 
     
    3737        renderer = pyxoo.particle.renderer.BitmapRenderer(self.screen) 
    3838         
    39         emission = pyxoo.particle.emission.ByRateEmission(pyxoo.particle.DisplayObjectParticle, pyxoo.structure.Point( 300, 5 ), 200) 
     39        self.emission = pyxoo.particle.emission.ByRateEmission(pyxoo.particle.DisplayObjectParticle, pyxoo.structure.Point(300, 5), 200) 
    4040        self.system = pyxoo.particle.system.SimpleParticleSystem(initializer, action, renderer) 
    41         self.system.emit(emission) 
     41        self.system.emit(self.emission) 
    4242         
    43         emission2 = pyxoo.particle.emission.ByRateEmission(pyxoo.particle.DisplayObjectParticle, pyxoo.structure.Point( 700, 5 ), 200) 
    44         self.system2 = pyxoo.particle.system.SimpleParticleSystem(initializer, action, renderer) 
    45         self.system2.emit(emission2) 
    46          
    47         emission3 = pyxoo.particle.emission.ByRateEmission(pyxoo.particle.DisplayObjectParticle, pyxoo.structure.Point( 1100, 5 ), 200) 
    48         self.system3 = pyxoo.particle.system.SimpleParticleSystem(initializer, action, renderer) 
    49         self.system3.emit(emission3) 
    50  
    51     def update(self): 
     43    def onTick(self, event): 
    5244        self.all_sprites.update() 
     45        x, y = pygame.mouse.get_pos() 
     46        self.emission.set_position(pyxoo.structure.Point(x, y)) 
    5347     
    54     def draw(self): 
    55         self.screen.blit(self.bg,(0,0)) 
     48    def onDraw(self, event): 
     49        pygame.display.flip() 
     50        self.screen.fill(pygame.Color('black')) 
    5651        self.all_sprites.draw(self.screen) 
    5752     
     
    5954        self.is_running = False 
    6055         
     56    def onKeyboardKeyDown(self, event): 
     57        key = event.get_value().key 
     58        if key == pygame.K_ESCAPE: 
     59            event.type = pyxoo.event.onQuitEVENT 
     60            self.broadcast(event) 
     61        elif key == pygame.K_UP: 
     62            self.system.set_local_speed(self.system.get_local_speed() + 1) 
     63        elif key == pygame.K_DOWN: 
     64            self.system.set_local_speed(self.system.get_local_speed() - 1) 
     65             
     66         
    6167 
    6268if __name__ == '__main__': 
    63     App().run() 
     69    app = FountainSample(MAX_FPS) 
     70    app.run() 
  • project/trunk/example/particle/mouse_gravity.py

    r35 r36  
    66from pyxoo.structure import Point 
    77 
    8 RESOLUTION = 1680, 105
    9 COLOR = 0,255,255 
     8RESOLUTION = 800, 60
     9MAX_FPS = 120 
    1010 
    11 class App(pyxoo.engine.Application): 
    12     def init(self): 
     11class MouseGravitySample(pyxoo.engine.Application): 
     12    def onInitApp(self, event): 
    1313        if sys.platform == "win32": 
    1414            os.environ["SDL_VIDEODRIVER"] = "windib" 
    1515        pygame.init() 
    16         self.screen = pygame.display.set_mode(RESOLUTION,pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.FULLSCREEN, 32) 
     16        self.screen = pygame.display.set_mode(RESOLUTION,pygame.HWSURFACE|pygame.DOUBLEBUF, 32) 
    1717        self.bg = pygame.Surface(self.screen.get_size()).convert() 
    18         self.input_dispatcher.add_event_listener(pyxoo.event.onQuitEVENT, self.onQuit) 
    19         self.input_dispatcher.add_event_listener(pyxoo.event.onKeyboardKeyDownEVENT, self.onQuit) 
    20          
     18        self.add_event_listener(pyxoo.event.onQuitEVENT, self.onQuit) 
     19        self.add_event_listener(pyxoo.event.onKeyboardKeyDownEVENT, self.onQuit) 
     20                 
    2121        self.monitor = pyxoo.utils.monitor.Monitor() 
    2222        self.monitor.add_field(pyxoo.utils.monitor.FPSField(self.clock, 300, (0, 0, 255))) 
     
    2828        initializer.append(pyxoo.particle.initializer.ImageClassInitializer(pyxoo.displayobject.Star, 5)) 
    2929        initializer.append(pyxoo.particle.initializer.LifeInitializer(3000, 1000)) 
    30         #initializer.append(pyxoo.particle.initializer.ExplosionInitializer(3, pyxoo.structure.Range(math.pi-.1, math.pi+.1), 50)) 
    3130        initializer.append(pyxoo.particle.initializer.BoxInitializer(self.screen.get_rect())) 
    32          
    33          
     31                 
    3432        action = pyxoo.particle.action.StackAction() 
    35         action.append(pyxoo.particle.action.MouseGravity(120, 100)) 
     33        action.append(pyxoo.particle.action.MouseGravity(150, 70)) 
    3634        action.append(pyxoo.particle.action.BoundingBox(Point(0,0), Point(RESOLUTION[0], RESOLUTION[1]))) 
    37         #action.append(pyxoo.particle.action.MutualGravity(500, 10)) 
    38         action.append(pyxoo.particle.action.SpeedLimit(150)) 
     35        action.append(pyxoo.particle.action.SpeedLimit(100)) 
    3936        action.append(pyxoo.particle.action.MoveAction()) 
    4037         
     
    4340         
    4441        self.system = pyxoo.particle.system.SimpleParticleSystem(initializer, action, renderer) 
     42        self.system.set_local_speed(3) 
    4543        self.system.emit(emission) 
    4644 
    47     def update(self): 
     45    def onTick(self, event): 
    4846        self.all_sprites.update() 
    4947     
    50     def draw(self): 
    51         self.screen.blit(self.bg,(0,0)) 
     48    def onDraw(self, event): 
     49        pygame.display.flip()         
     50        self.screen.fill(pygame.Color("black")) 
    5251        self.all_sprites.draw(self.screen) 
    5352         
     
    5756 
    5857if __name__ == '__main__': 
    59     App().run() 
     58    app = MouseGravitySample(MAX_FPS) 
     59    app.run() 
  • project/trunk/src/pyxoo/displayobject.py

    r35 r36  
    2828 
    2929class Dot(SurfaceWithColorKey): 
    30     def __init__(self, radius, color=_WHITE): 
     30    def __init__(self, radius, color=_WHITE, width=0): 
    3131        SurfaceWithColorKey.__init__(self, (radius * 2, radius * 2), _get_color_key(color)) 
    32         pygame.draw.circle(self, color, (radius, radius), radius
     32        pygame.draw.circle(self, color, (radius, radius), radius, width
    3333         
    3434 
    3535class Star(SurfaceWithColorKey): 
    36     def __init__(self, radius, color=_WHITE, width=1): 
     36    def __init__(self, radius, color=_WHITE, width=0): 
    3737        SurfaceWithColorKey.__init__(self, (radius * 2, radius * 2), _get_color_key(color)) 
    3838        rot_step = math.pi / 5.0 
    3939        inner_radius = radius * math.cos(rot_step * 2) 
    40         half_pi = math.pi * 0.5 
    41          
     40        half_pi = math.pi * 0.5         
    4241        points = list() 
    4342        points.append((radius, 0)) 
  • project/trunk/src/pyxoo/engine.py

    r35 r36  
    11import pyxoo, pyxoo.event, pygame 
     2 
     3from pyxoo.event import ApplicationBroadcaster, Event, InputEventConverter, SYSTEM_CHANNEL, onInitAppEVENT, onQuitAppEVENT, onDrawEVENT, onTickEVENT 
    24 
    35__version__ = pyxoo.__version__ 
    46__licence__ = pyxoo.__licence__ 
    5 __url__     = pyxoo.__url__ 
    6 __author__ = "Alexis Couronne" 
     7__url__ = pyxoo.__url__ 
     8__author__ = "Alexis Couronne" 
    79 
    810 
    911class Application: 
    10     def __init__(self, max_fps=0, flip_method=pygame.display.flip): 
    11         self.input_dispatcher = pyxoo.event.InputDispatcher() 
     12    def __init__(self, max_fps=0): 
     13        self._eventbroadcaster = ApplicationBroadcaster().get_channel_dispatcher(SYSTEM_CHANNEL) 
     14        self._event_converter = InputEventConverter() 
    1215        self.is_running = False 
     16         
    1317        self.clock = pygame.time.Clock() 
    1418        self.max_fps = max_fps 
    15         self._flip_method = flip_method 
    16         self.__onInitEVENT   = pyxoo.event.Event(pyxoo.event.onInitAppEVENT) 
    17         self.__onUpdateEVENT = pyxoo.event.Event(pyxoo.event.onUpdateEVENT) 
    18         self.__onDrawEVENT   = pyxoo.event.Event(pyxoo.event.onDrawEVENT) 
    19         self.__onQuitEVENT   = pyxoo.event.Event(pyxoo.event.onQuitAppEVENT) 
    20         self.__onTickEVENT   = pyxoo.engine.RTEvent(pyxoo.event.onTickEVENT, self) 
     19        self._global_speed = 1 
     20        self._max_step_size = 0 
    2121         
    22     def init(self): 
     22        self._onInitAppEVT = Event(onInitAppEVENT) 
     23        self._onTickEVT    = RTEvent(onTickEVENT, self) 
     24        self._onDrawEVT    = Event(onDrawEVENT) 
     25        self._onQuitAppEVT = Event(onQuitAppEVENT) 
     26         
     27        self.add_event_listener(onInitAppEVENT, self) 
     28        self.add_event_listener(onTickEVENT, self) 
     29        self.add_event_listener(onDrawEVENT, self) 
     30        self.add_event_listener(onQuitAppEVENT, self) 
     31         
     32    def onInitApp(self, event): 
    2333        pass 
    2434     
    25     def quit(self): 
     35    def onQuitApp(self, event): 
    2636        pass 
    2737     
    28     def update(self): 
     38    def onTick(self, event): 
    2939        pass 
    3040     
    31     def draw(self): 
     41    def onDraw(self, event): 
    3242        pass 
    3343     
    3444    def run(self): 
    3545        self.is_running = True 
    36         self.init() 
    37         self._fire_onInit() 
     46        self._fire_onInitApp() 
    3847        while self.is_running: 
    3948            self.clock.tick(self.max_fps) 
    40             self.input_dispatcher.dispatch() 
    41             self.update() 
    42             self._fire_onUpdate() 
     49            self._fire_input_events() 
    4350            self._fire_onTick() 
    44             self.draw() 
    4551            self._fire_onDraw() 
    46             self._flip_method() 
    47         self.quit() 
    48         self._fire_onQuit() 
     52        self._fire_onQuitApp() 
     53         
     54    def get_global_speed(self): 
     55        return self._global_speed 
    4956     
    50     def _fire_onInit(self): 
    51         pyxoo.event.ApplicationBroadcaster().broadcast(self.__onInitEVENT) 
     57    def set_global_speed(self, speed): 
     58        if speed <= 0: 
     59            raise ValueError("speed value must positive") 
     60        self._global_speed = speed 
     61         
     62    def get_max_step_size(self): 
     63        return self._max_step_size 
    5264     
    53     def _fire_onUpdate(self): 
    54         pyxoo.event.ApplicationBroadcaster().broadcast(self.__onUpdateEVENT) 
     65    def set_max_step_size(self, size): 
     66        if size >= 0: 
     67            self._max_step_size = size 
     68        else: 
     69            self._max_step_size = 0 
     70 
     71    def add_listener(self, listener): 
     72        return self._eventbroadcaster.add_listener(listener) 
     73     
     74    def remove_listener(self, listener): 
     75        return self._eventbroadcaster.remove_listener(listener) 
     76     
     77    def add_event_listener(self, type, listener, *args): 
     78        return self._eventbroadcaster.add_event_listener(type, listener, *args) 
     79     
     80    def remove_event_listener(self, type, listener): 
     81        return self._eventbroadcaster.remove_event_listener(type, listener) 
     82     
     83    def broadcast(self, event): 
     84        self._eventbroadcaster.broadcast(event) 
    5585         
     86    def _fire_input_events(self): 
     87        for event in pygame.event.get(): 
     88            e = self._event_converter.convert(event) 
     89            self._eventbroadcaster.broadcast(e) 
     90     
     91    def _fire_onInitApp(self): 
     92        self._eventbroadcaster.broadcast(self._onInitAppEVT) 
     93      
    5694    def _fire_onTick(self): 
    57         self.__onTickEVENT.set_step(self.clock.get_time()) 
    58         pyxoo.event.ApplicationBroadcaster().broadcast(self.__onTickEVENT) 
     95        step = self.clock.get_time() * self._global_speed 
     96        if self._max_step_size: 
     97            step = self._restrict(step) 
     98        self._onTickEVT.set_step(step) 
     99        self._eventbroadcaster.broadcast(self._onTickEVT) 
    59100         
    60101    def _fire_onDraw(self): 
    61         pyxoo.event.ApplicationBroadcaster().broadcast(self.__onDrawEVENT) 
     102        self._eventbroadcaster.broadcast(self._onDrawEVT) 
    62103         
    63     def _fire_onQuit(self): 
    64         pyxoo.event.ApplicationBroadcaster().broadcast(self.__onQuitEVENT) 
     104    def _fire_onQuitApp(self): 
     105        self._eventbroadcaster.broadcast(self._onQuitAppEVT) 
     106         
     107    def _restrict(self, step): 
     108        tmp = self._max_step_size * self._global_speed 
     109        if step > tmp: 
     110            return tmp 
     111        else: 
     112            return step 
    65113 
    66114 
    67115class RTObject: 
    68116    def __init__(self): 
    69         self._broadcaster = pyxoo.event.ApplicationBroadcaster().get_channel_dispatcher(pyxoo.event.SYSTEM_CHANNEL) 
     117        self._broadcaster = ApplicationBroadcaster().get_channel_dispatcher(pyxoo.event.SYSTEM_CHANNEL) 
    70118        self._local_speed = 1 
    71119        self._is_playing = False 
     
    87135     
    88136    def set_local_speed(self, rate): 
    89         if rate < 1
    90             raise ArithmeticError 
     137        if rate <= 0
     138            raise ValueError("rate parameter must be positive") 
    91139        self._local_speed = rate 
    92140         
     
    107155     
    108156     
    109 class RTEvent(pyxoo.event.Event): 
     157class RTEvent(Event): 
    110158    def __init__(self, type, target=None): 
    111         pyxoo.event.Event.__init__(self, type, None, target) 
     159        Event.__init__(self, type, None, target) 
    112160        self._step = 0 
    113161         
     
    116164         
    117165    def get_step(self): 
    118         return self._step 
     166        return float(self._step) 
    119167     
    120168    def get_step_in_second(self): 
  • project/trunk/src/pyxoo/event.py

    r34 r36  
    728728        """__str__():String 
    729729        Returns the string representation of this instance.""" 
    730         return pyxoo.utils.PyxooStringifier.stringify(self) 
     730        return pyxoo.utils.PyxooStringifier.stringify(self) + "(type:'%s', value:'%s', target:'%s')"%(self.type, self._value, self.target) 
    731731 
    732732     
     
    834834 
    835835 
    836 class InputDispatcher: 
     836class InputEventConverter: 
    837837    def __init__(self): 
    838         self.__eb = EventBroadcaster(self) 
    839         self.__event_types = dict() 
    840          
     838        self.__event_types = dict()         
    841839        self.__event_types[pygame.MOUSEMOTION]     = onMouseMoveEVENT 
    842840        self.__event_types[pygame.MOUSEBUTTONDOWN] = onMouseButtonDownEVENT 
     
    853851        self.__event_types[pygame.JOYHATMOTION]    = onJoystickHatMotionEVENT 
    854852        self.__event_types[pygame.JOYBUTTONUP]     = onJoystickButtonUpEVENT 
    855         self.__event_types[pygame.JOYBUTTONDOWN]   = onJoystickButtonDownEVENT   
    856          
    857     def dispatch(self): 
    858         for event in pygame.event.get(): 
    859             self.__eb.broadcast(Event(self.__event_types[event.type], event)) 
    860              
    861     def add_listener(self, listener): 
    862         return self.__eb.add_listener(listener) 
    863      
    864     def remove_listener(self, listener): 
    865         return self.__eb.remove_listener(listener) 
    866      
    867     def add_event_listener(self, event_type, listener, *args): 
    868         return self.__eb.add_event_listener(event_type, listener, *args) 
    869      
    870     def remove_event_listener(self, event_type, listener): 
    871         return self.__eb.remove_event_listener(event_type, listener) 
    872      
    873     def __str__(self): 
    874         """__str__():String 
    875         Returns the string representation of this instance.""" 
    876         return pyxoo.utils.PyxooStringifier.stringify(self) 
    877          
     853        self.__event_types[pygame.JOYBUTTONDOWN]   = onJoystickButtonDownEVENT 
     854         
     855    def convert(self, event): 
     856        return Event(self.__event_types[event.type], event) 
     857        
  • project/trunk/src/pyxoo/particle/initializer.py

    r35 r36  
    4444        self._b = b 
    4545        self._rand = rand 
    46         self._segment = b - a #TODO: voir si c bon 
     46        self._segment = b - a 
    4747         
    4848    def initialize(self, particle): 
     
    8989         
    9090class ImageClassInitializer(InitializeStrategy): 
    91     def __init__(self, image, *args): 
     91    def __init__(self, image, *args, **kwargs): 
    9292        self._image = image 
    9393        self._args = args 
     94        self._kwargs = kwargs 
    9495         
    9596    def initialize(self, particle): 
    96         particle.image = self._image(*self._args).convert() 
     97        particle.image = self._image(*self._args, **self._kwargs).convert() 
  • project/trunk/src/pyxoo/particle/system.py

    r35 r36  
    5555     
    5656    def _process_emissions(self, event): 
    57         t = event.get_step(
     57        t = self.get_local_step(event
    5858        for emission in self._emissions: 
    5959            emission.prepare_emission(t) 
     
    7070         
    7171    def _process_particles(self, event): 
    72         time = event.get_step(
     72        time = self.get_local_step(event
    7373        self._prepare_action(time) 
    7474        for particle in self._particles: 
  • project/trunk/src/pyxoo/utils/monitor.py

    r34 r36  
    5656 
    5757class FPSField(Field): 
    58     def __init__(self, clock, max_value, color): 
     58    def __init__(self, clock, max_value=300, color=pygame.Color("green")): 
    5959        Field.__init__(self, "FPS", 0, max_value, color) 
    6060        self.clock = clock