Mercurial > parpg-source
annotate bGrease/__init__.py @ 157:79d6b17b80a3
Implemented simple script system.
author | KarstenBock@gmx.net |
---|---|
date | Sat, 12 Nov 2011 16:27:39 +0100 |
parents | ff3e395abf91 |
children | a6bbb732b27b |
rev | line source |
---|---|
5 | 1 ############################################################################# |
2 # | |
3 # Copyright (c) 2010 by Casey Duncan and contributors | |
4 # All Rights Reserved. | |
5 # | |
6 # This software is subject to the provisions of the MIT License | |
7 # A copy of the license should accompany this distribution. | |
8 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
9 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
10 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
11 # | |
12 ############################################################################# | |
13 | |
14 __versioninfo__ = (0, 3, 0) | |
15 __version__ = '.'.join(str(n) for n in __versioninfo__) | |
16 | |
17 __all__ = ('BaseWorld', 'Entity', 'System', 'Renderer') | |
18 | |
7
710f299ed275
Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents:
5
diff
changeset
|
19 import component |
710f299ed275
Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents:
5
diff
changeset
|
20 import geometry |
710f299ed275
Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents:
5
diff
changeset
|
21 import collision |
710f299ed275
Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents:
5
diff
changeset
|
22 from entity import Entity |
710f299ed275
Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents:
5
diff
changeset
|
23 from world import BaseWorld |
5 | 24 |
25 import abc | |
26 | |
27 class System(object): | |
28 """Grease system abstract base class. Systems define behaviorial aspects | |
29 of a |World|. All systems must define a :meth:`step` | |
30 method that is invoked by the world each timestep. User-defined systems | |
31 are not required to subclass this class. | |
32 | |
33 See :ref:`an example system from the tutorial <tut-system-example>`. | |
34 """ | |
35 __metaclass__ = abc.ABCMeta | |
36 | |
37 world = None | |
38 """The |World| this system belongs to""" | |
39 | |
40 def set_world(self, world): | |
41 """Bind the system to a world""" | |
42 self.world = world | |
43 | |
44 @abc.abstractmethod | |
45 def step(self, dt): | |
46 """Execute a time step for the system. Must be defined | |
47 by all system classes. | |
48 | |
49 :param dt: Time since last step invocation | |
50 :type dt: float | |
51 """ | |
52 | |
53 class Renderer(object): | |
54 """Grease renderer abstract base class. Renderers define the presentation | |
55 of a |World|. All renderers must define a :meth:`draw` | |
56 method that is invoked by the world when the display needs to be redrawn. | |
57 User-defined renderers are not required to subclass this class. | |
58 | |
59 See :ref:`an example renderer from the tutorial <tut-renderer-example>`. | |
60 """ | |
61 __metaclass__ = abc.ABCMeta | |
62 | |
63 world = None | |
64 """The |World| this renderer belongs to""" | |
65 | |
66 def set_world(self, world): | |
67 """Bind the system to a world""" | |
68 self.world = world | |
69 | |
70 @abc.abstractmethod | |
71 def draw(self): | |
72 """Issue drawing commands for this renderer. Must be defined | |
73 for all renderer classes. | |
74 """ | |
75 |