Changeset 34
- Timestamp:
- 08/21/08 07:17:52 (5 months ago)
- Files:
-
- project/trunk/example (added)
- project/trunk/example/particle (added)
- project/trunk/example/particle.py (added)
- project/trunk/example/particle/__init__.py (added)
- project/trunk/example/particle/explosion.py (added)
- project/trunk/example/particle/fountain.py (added)
- project/trunk/example/particle/mouse_gravity.py (added)
- project/trunk/src/pyxoo/__init__.py (modified) (1 diff)
- project/trunk/src/pyxoo/displayobject.py (added)
- project/trunk/src/pyxoo/engine.py (added)
- project/trunk/src/pyxoo/event.py (modified) (2 diffs)
- project/trunk/src/pyxoo/particle (added)
- project/trunk/src/pyxoo/particle/__init__.py (added)
- project/trunk/src/pyxoo/particle/action.py (added)
- project/trunk/src/pyxoo/particle/emission.py (added)
- project/trunk/src/pyxoo/particle/initializer.py (added)
- project/trunk/src/pyxoo/particle/renderer.py (added)
- project/trunk/src/pyxoo/particle/system.py (added)
- project/trunk/src/pyxoo/structure.py (added)
- project/trunk/src/pyxoo/utils/__init__.py (modified) (2 diffs)
- project/trunk/src/pyxoo/utils/monitor.py (added)
- project/trunk/test/commands/TestDelegate.py (modified) (2 diffs)
- project/trunk/test/particle (added)
- project/trunk/test/particle/TestParticleManager.py (added)
- project/trunk/test/particle/__init__.py (added)
- project/trunk/test/structure (added)
- project/trunk/test/structure/TestPoint.py (added)
- project/trunk/test/structure/__init__.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
project/trunk/src/pyxoo/__init__.py
r27 r34 32 32 import pyxoo.model 33 33 import pyxoo.view 34 #import pyxoo.load 34 import pyxoo.structure 35 import pyxoo.displayobject 36 import pyxoo.engine 37 import pyxoo.particle 35 38 project/trunk/src/pyxoo/event.py
r33 r34 1 1 2 import pyxoo, threading, logging, time 2 import pyxoo, threading, logging, time, pygame 3 3 4 4 5 __version__ = pyxoo.__version__ … … 804 805 Returns the string representation of this instance.""" 805 806 return pyxoo.utils.PyxooStringifier.stringify(self) 807 808 809 810 onJoystickAxisMotionEVENT = "onJoystickAxisMotion" 811 onJoystickBallMotionEVENT = "onJoystickBallMotion" 812 onJoystickHatMotionEVENT = "onJoystickHatMotion" 813 onJoystickButtonUpEVENT = "onJoystickButtonUp" 814 onJoystickButtonDownEVENT = "onJoystickButtonDown" 815 816 onKeyboardKeyUpEVENT = "onKeyboardKeyUp" 817 onKeyboardKeyDownEVENT = "onKeyboardKeyDown" 818 819 onQuitEVENT = "onQuit" 820 onActiveEVENT = "onActive" 821 onVideoResizeEVENT = "onVideoResize" 822 onVideoExposeEVENT = "onVideoExpose" 823 onUserEVENT = "onUser" 824 825 onMouseMoveEVENT = "onMouseMove" 826 onMouseButtonUpEVENT = "onMouseButtonUp" 827 onMouseButtonDownEVENT = "onMouseButtonDown" 828 829 onInitAppEVENT = "onInitApp" 830 onQuitAppEVENT = "onQuitApp" 831 onUpdateEVENT = "onUpdate" 832 onDrawEVENT = "onDraw" 833 onTickEVENT = "onTick" 834 835 836 class InputDispatcher: 837 def __init__(self): 838 self.__eb = EventBroadcaster(self) 839 self.__event_types = dict() 840 841 self.__event_types[pygame.MOUSEMOTION] = onMouseMoveEVENT 842 self.__event_types[pygame.MOUSEBUTTONDOWN] = onMouseButtonDownEVENT 843 self.__event_types[pygame.MOUSEBUTTONUP] = onMouseButtonUpEVENT 844 self.__event_types[pygame.KEYUP] = onKeyboardKeyUpEVENT 845 self.__event_types[pygame.KEYDOWN] = onKeyboardKeyDownEVENT 846 self.__event_types[pygame.ACTIVEEVENT] = onActiveEVENT 847 self.__event_types[pygame.QUIT] = onQuitEVENT 848 self.__event_types[pygame.VIDEORESIZE] = onVideoResizeEVENT 849 self.__event_types[pygame.VIDEOEXPOSE] = onVideoExposeEVENT 850 self.__event_types[pygame.USEREVENT] = onUserEVENT 851 self.__event_types[pygame.JOYAXISMOTION] = onJoystickAxisMotionEVENT 852 self.__event_types[pygame.JOYBALLMOTION] = onJoystickBallMotionEVENT 853 self.__event_types[pygame.JOYHATMOTION] = onJoystickHatMotionEVENT 854 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 project/trunk/src/pyxoo/utils/__init__.py
r33 r34 1 1 2 import pyxoo 2 import pyxoo, random 3 3 4 4 __version__ = pyxoo.__version__ … … 10 10 from pyxoo.utils.type import is_boolean, is_class, is_dict, is_file, is_float, is_function, is_instance, is_int, is_list, is_long, is_method, is_module, is_none, is_number, is_string, is_tuple, is_type 11 11 from pyxoo.utils.stringifier import PyxooStringifier, BasicStringifier, Stringifier 12 import pyxoo.utils.monitor 12 13 13 14 14 15 16 def random_balance(value): 17 return random.random() * value - value / 2 15 18 19 20 project/trunk/test/commands/TestDelegate.py
r33 r34 29 29 return a + b 30 30 31 def coucou(): 32 return "coucou" 33 31 34 class TestDelegate(unittest.TestCase): 32 35 def setUp(self): … … 43 46 self.assertEquals( "12", self.instance.call_function() ) 44 47 48 def testCallFunctionWithNoArgument(self): 49 delegate = pyxoo.command.Delegate(coucou) 50 self.assertEquals( "coucou", delegate.call_function() ) 51 45 52 def testCreate(self): 46 53 f = pyxoo.command.Delegate.create(myFunction, "a", "b")
