Permalink
Browse files

Changed grease to bGrease.

  • Loading branch information...
1 parent 0f8e73f commit 1408cde4d9de07bfde35d5edd50a026c47ba059b @Beliaar committed Mar 26, 2012
View
@@ -1,14 +1,14 @@
.. Global includes
-.. |World| replace:: :class:`~grease.world.World`
-.. |System| replace:: :class:`~grease.System`
-.. |Component| replace:: :class:`~grease.component.Component`
-.. |Renderer| replace:: :class:`~grease.Renderer`
-.. |Entity| replace:: :class:`~grease.entity.Entity`
-.. |Vec2d| replace:: :class:`~grease.geometry.Vec2d`
-.. |Vec2dArray| replace:: :class:`~grease.geometry.Vec2dArray`
-.. |Rect| replace:: :class:`~grease.geometry.Rect`
-.. |RGBA| replace:: :class:`~grease.color.RGBA`
-.. |Mode| replace:: :class:`~grease.mode.Mode`
-.. |Manager| replace:: :class:`~grease.mode.Manager`
-.. |Multi| replace:: :class:`~grease.mode.Multi`
+.. |World| replace:: :class:`~bGrease.world.World`
+.. |System| replace:: :class:`~bGrease.System`
+.. |Component| replace:: :class:`~bGrease.component.Component`
+.. |Renderer| replace:: :class:`~bGrease.Renderer`
+.. |Entity| replace:: :class:`~bGrease.entity.Entity`
+.. |Vec2d| replace:: :class:`~bGrease.geometry.Vec2d`
+.. |Vec2dArray| replace:: :class:`~bGrease.geometry.Vec2dArray`
+.. |Rect| replace:: :class:`~bGrease.geometry.Rect`
+.. |RGBA| replace:: :class:`~bGrease.color.RGBA`
+.. |Mode| replace:: :class:`~bGrease.mode.Mode`
+.. |Manager| replace:: :class:`~bGrease.mode.Manager`
+.. |Multi| replace:: :class:`~bGrease.mode.Multi`
View
@@ -1,9 +1,9 @@
.. include:: ../include.rst
-:mod:`grease.collision` -- Collision Detection
+:mod:`bGrease.collision` -- Collision Detection
===============================================
-.. automodule:: grease.collision
+.. automodule:: bGrease.collision
:synopsis: Collision detection systems
:members:
View
@@ -1,7 +1,7 @@
-:mod:`grease.color` -- Colors
+:mod:`bGrease.color` -- Colors
=============================
-.. automodule:: grease.color
+.. automodule:: bGrease.color
:synopsis: Come Smell the Colors
:members:
View
@@ -1,9 +1,9 @@
.. include:: ../include.rst
-:mod:`grease.component` -- Entity Data Containers
+:mod:`bGrease.component` -- Entity Data Containers
=================================================
-.. automodule:: grease.component
+.. automodule:: bGrease.component
:synopsis: Entity Data Containers
:members:
View
@@ -1,7 +1,7 @@
-:mod:`grease.controller` -- General Behavioral Aspects
+:mod:`bGrease.controller` -- General Behavioral Aspects
======================================================
-.. automodule:: grease.controller
+.. automodule:: bGrease.controller
:synopsis: General Behavioral Aspects
:members:
View
@@ -1,7 +1,7 @@
-:mod:`grease.controls` -- Game Controls
+:mod:`bGrease.controls` -- Game Controls
=======================================
-.. automodule:: grease.controls
+.. automodule:: bGrease.controls
:synopsis: Game Controls
:members:
View
@@ -1,7 +1,7 @@
-:mod:`grease.entity` -- Entity Classes
+:mod:`bGrease.entity` -- Entity Classes
======================================
-.. automodule:: grease.entity
+.. automodule:: bGrease.entity
:synopsis: Actionable game objects
.. autoclass:: Entity
View
@@ -1,10 +1,10 @@
-:mod:`grease.geometry` -- 2D Geometry
+:mod:`bGrease.geometry` -- 2D Geometry
=====================================
.. note:: This class is in the process of being replaced by
a standalone library now in development.
-.. automodule:: grease.geometry
+.. automodule:: bGrease.geometry
:synopsis: Vectors, Rects, What-not
:members:
View
@@ -12,6 +12,6 @@ Other Base Classes
The following other common base classes can be imported from here for convenience:
-- :class:`~grease.world.World`
-- :class:`~grease.entity.Entity`
+- :class:`~bGrease.world.World`
+- :class:`~bGrease.entity.Entity`
View
@@ -1,7 +1,7 @@
-:mod:`grease.mode` -- Modal Framework
+:mod:`bGrease.mode` -- Modal Framework
=====================================
-.. automodule:: grease.mode
+.. automodule:: bGrease.mode
:synopsis: Application modes
:members:
View
@@ -1,7 +1,7 @@
-:mod:`grease.renderer` -- World Presentation
+:mod:`bGrease.renderer` -- World Presentation
============================================
-.. automodule:: grease.renderer
+.. automodule:: bGrease.renderer
:synopsis: Visualize Whirred Peas
:members:
View
@@ -1,7 +1,7 @@
-:mod:`grease.world` -- Entity Environment
+:mod:`bGrease.world` -- Entity Environment
=========================================
-.. automodule:: grease.world
+.. automodule:: bGrease.world
:synopsis: Container and environment for entities, component, systems and renderers
.. autoclass:: World(step_rate=60, master_clock=pyglet.clock)
@@ -107,7 +107,7 @@ Similar to components, the world attribute :attr:`systems` is used to access the
.. note:: It is possible to insert a system out of order using the :meth:`world.systems.insert` method.
-The :class:`~grease.controller.EulerMovement` system is responsible for updating the position and movement components. It performs a Euler integration each time step to update the :attr:`movement.velocity`, :attr:`position.position` and :attr:`position.angle` fields for all entities with both position and movement data. Systems access components in the world by name. By default, the :class:`~grease.controller.EulerMovement` controller assumes the position component it will use is named "position" and the movement controller is named "movement". This is just a convention, however. In fact you can have multiple position and movement components with different names if desired. For this application the defaults work fine, and require less configuration.
+The :class:`~bGrease.controller.EulerMovement` system is responsible for updating the position and movement components. It performs a Euler integration each time step to update the :attr:`movement.velocity`, :attr:`position.position` and :attr:`position.angle` fields for all entities with both position and movement data. Systems access components in the world by name. By default, the :class:`~bGrease.controller.EulerMovement` controller assumes the position component it will use is named "position" and the movement controller is named "movement". This is just a convention, however. In fact you can have multiple position and movement components with different names if desired. For this application the defaults work fine, and require less configuration.
.. index::
single: Renderer (tutorial overview)
@@ -124,7 +124,7 @@ Like systems, renderer order is important. Renderers are always invoked in the o
Although renderers typically make an immediate visual change to the window, some, like :class:`renderer.Camera` change the drawing state for subsequent renderers to use. A camera renderer is a high-level way to setup the OpenGL state for further rendering. Setting the position of the camera translates all of the subsequent drawing. In our example, we position the origin point (0, 0) in the center of the window instead of the Pyglet default, which is the lower left corner. You can also set a zoom and angle for the camera to scale and rotate respectively. The camera's settings may also be changed at run time to easily implement features like panning and zooming.
-The main workhorse renderer in our example is the :class:`~grease.renderer.Vector` renderer class. This renderer will draw shapes from the shape component in an old-school vector graphics style. As you may have guessed the :attr:`line_width` argument controls how fat the vector lines are drawn. This renderer draws all of the shapes in the component in a single batch using :const:`GL_LINES`. Because of this, all shapes drawn by this renderer must have the same line width. Even with this restriction, it is not difficult to use this renderer in cases where multiple line widths are needed. You will just need one :class:`~grease.component.Renderable` component and one :class:`~grease.renderer.Vector` renderer per desired line width.
+The main workhorse renderer in our example is the :class:`~bGrease.renderer.Vector` renderer class. This renderer will draw shapes from the shape component in an old-school vector graphics style. As you may have guessed the :attr:`line_width` argument controls how fat the vector lines are drawn. This renderer draws all of the shapes in the component in a single batch using :const:`GL_LINES`. Because of this, all shapes drawn by this renderer must have the same line width. Even with this restriction, it is not difficult to use this renderer in cases where multiple line widths are needed. You will just need one :class:`~bGrease.component.Renderable` component and one :class:`~bGrease.renderer.Vector` renderer per desired line width.
We now have all the parts configured for our second goal: to create polygonal shapes, move and draw them. Now we just need to create some entities that store data in our components.
View
@@ -44,7 +44,7 @@ Let's move on to the thrust method:
.. literalinclude:: blasteroids2.py
:pyobject: PlayerShip.thrust_on
-This method accelerates the ship in the direction it is facing. We start by defining an upward-facing vector with a magnitude set to the class's :attr:`THRUST_ACCEL` value. This vector is then rotated in-place to face the direction of the ship using :meth:`Vec2d.rotate()`. The :attr:`accel` field of the entity's movment component is then set to the rotated thrust vector. The :class:`~grease.controller.EulerMovement` system, already in the world takes care of calculating the ship's velocity and position over time based on the acceleration.
+This method accelerates the ship in the direction it is facing. We start by defining an upward-facing vector with a magnitude set to the class's :attr:`THRUST_ACCEL` value. This vector is then rotated in-place to face the direction of the ship using :meth:`Vec2d.rotate()`. The :attr:`accel` field of the entity's movment component is then set to the rotated thrust vector. The :class:`~bGrease.controller.EulerMovement` system, already in the world takes care of calculating the ship's velocity and position over time based on the acceleration.
The last line changes one of the shape vertices, moving it to a random position behind the ship. This will create a simple flickering flame animation that will act as an import cue to the player that the thrust is active. Notice that the vertex is simply moved to a random position vertically relative to the origin, the renderer will automatically take care of translating and rotating the vertex to the proper window coordinates according to the ship's current position and rotation, as well as the current camera settings.
@@ -76,7 +76,7 @@ Remember that systems are behavioral aspects of our application, and are invoked
:pyobject: GameSystem
:end-before: @
-We start by defining our :class:`GameSystem` as a subclass of :class:`~grease.controls.KeyControls`. :class:`KeyControls` is a system subclass that provides a convenient mechanism for binding its methods to keyboard events.
+We start by defining our :class:`GameSystem` as a subclass of :class:`~bGrease.controls.KeyControls`. :class:`KeyControls` is a system subclass that provides a convenient mechanism for binding its methods to keyboard events.
The :meth:`set_world` method is overridden to include a call to create a :class:`PlayerShip` entity and store it in the system as game state. Since there is only one player ship, this is an easy way to keep track of it so that we can call it's methods in response to particular key presses. We make the entity here in this method -- instead of, say :meth:`__init__` -- because this method is called when the system is added to the world. Since we need a reference to the world in order to create an entity, this is the most convenient place to do so.
@@ -107,7 +107,7 @@ The methods for handling turning right are the same as above with the direction
:start-after: turn(0)
:end-before: key.SPACE
-For activating thrust, we use the :meth:`~grease.controls.KeyControls.key_hold` decorator. This works differently than the key press and release decorators we used for turning. The press and release decorators configure a method to fire once for each specific key event. The key hold decorator configures a method to fire continuously, once per time step, as long as the specified key is held down. This is perfect for thrust, which needs to be adjusted continuously as the ship turns, and runs a continuous animation while activated.
+For activating thrust, we use the :meth:`~bGrease.controls.KeyControls.key_hold` decorator. This works differently than the key press and release decorators we used for turning. The press and release decorators configure a method to fire once for each specific key event. The key hold decorator configures a method to fire continuously, once per time step, as long as the specified key is held down. This is perfect for thrust, which needs to be adjusted continuously as the ship turns, and runs a continuous animation while activated.
The :meth:`stop_thrust` method is simply bound to key release, to ensure the thrust is deactivated at the proper time.
@@ -139,13 +139,13 @@ Flying around is way too safe at the moment, since you can't actually run into a
:pyobject: GameWorld
:linenos:
-The :class:`~grease.component.Collision` component (line 9 above) has the fields we need to make the collision system (line 13-14 above) work. The fields in this component are:
+The :class:`~bGrease.component.Collision` component (line 9 above) has the fields we need to make the collision system (line 13-14 above) work. The fields in this component are:
`aabb`
This is the axis-aligned bounding box that contains the entity. This box is used in the collision detection system to quickly reduce the number of collision checks that need to be performed. We can also use it for our own purposes when we need to find the top, left, bottom or right edges of entities.
`radius`
- The meaning of this field is up to the specific collision system used. For :class:`~grease.collision.Circular` systems, entities are approximated as circles for the purposes of collision detection. The radius value is simply the radius of the collision circle for an entity.
+ The meaning of this field is up to the specific collision system used. For :class:`~bGrease.collision.Circular` systems, entities are approximated as circles for the purposes of collision detection. The radius value is simply the radius of the collision circle for an entity.
`from_mask` and `into_mask`
Not all entities in the collision component need to be able to collide with each other. These two mask fields let you specify which entities can collide. Both mask fields are 32 bit integer bitmasks. When two entities are compared for collision, the :attr:`from_mask` value from each entity is bit-anded with the :attr:`into_mask` of the other. If this bit-and operation returns a non-zero result, then a collision is possible, if the result is zero, the entities cannot collide. Note that this check happens in both directions, so a collision can occur between entity A and B if ``A.collision.from_mask & B.collision.into_mask != 0 or B.collision.from_mask & A.collision.into_mask != 0``.
@@ -159,7 +159,7 @@ Let's take a closer look at how the collision system is configured above:
There are two major steps to collision handling in Grease: *collision detection* and *collision response*. The detection step happens within the collision system. A set of pairs of the currently colliding entities can be found in the :attr:`collision_pairs` attribute of the collision system. Applications are free to use :attr:`collision_pairs` directly, but they can also register one or more handlers for more automated collision response. Collision handlers are simply functions that accept the collision system they are configured for as an argument. The handler functions are called each time step to deal with collision response.
-Above we have configured :func:`~grease.collision.dispatch_events` as the collision handler. This function calls :meth:`on_collide` on all entities that are colliding. The entities' :meth:`on_collide` handler methods can contain whatever logic desired to handle the collision. This method accepts three arguments: :attr:`other_entity`, :attr:`collision_point`, and :attr:`collision_normal`. These arguments are the other entity collided with, the point where the collision occurred and the normal vector at the point of collision respectively. It is up to the handler method to decide how these values are used. Note that when two entities collide, both of their :meth:`on_collide` handler methods will be called, if defined.
+Above we have configured :func:`~bGrease.collision.dispatch_events` as the collision handler. This function calls :meth:`on_collide` on all entities that are colliding. The entities' :meth:`on_collide` handler methods can contain whatever logic desired to handle the collision. This method accepts three arguments: :attr:`other_entity`, :attr:`collision_point`, and :attr:`collision_normal`. These arguments are the other entity collided with, the point where the collision occurred and the normal vector at the point of collision respectively. It is up to the handler method to decide how these values are used. Note that when two entities collide, both of their :meth:`on_collide` handler methods will be called, if defined.
In our game we will leverage the collision masks to make it so that the player's ship collides with asteroids, but the asteroids do not collide with each other. To do that we need to modify the :class:`Asteroid` and :class:`PlayerShip` constructors to set the collision component fields.
Oops, something went wrong.

0 comments on commit 1408cde

Please sign in to comment.