Gloopy’s top level package.
Bases: gloopy.color.__BaseColor
4-component named tuple: (r, g, b, a), with some methods.
Each component is an unsigned byte in the range 0 to 255. (Note this is likely to change in the future to using floats throughout. It seems that once geometry is pushed to a VBO, the performance gains of using ubytes diminish substantially).
r, g, b: red, green and blue
a: alpha (defaults to fully opaque)
All of r, g, b, a are ints from 0 to 255 (Color.MAX_CHANNEL.)
For example, to specify red color:
from gloopy.color import Color
red = Color(255, 0, 0)
Or semi-transparent blue:
red = Color(0, 0, 255, 127)
Some predefined instances of Color provide named colors. These named colors are defined as attributes of the Color class:
from gloopy.color import Color
print Color.RoyalPurple
The names and values are taken from the top 69 results of the xkcd color survey:
Returns this color as a tuple of normalised floats, suitable for use with glSetClearColor. Note this method is likely to be deleted in a subsequent release, when colors change to being stored internally as floats.
Return a new color which is the complement of this one, i.e. if this color contains a lot of red, the return value will contain little red, and so on.
Bases: object
A dumb collection of attributes, representing a single item to be rendered.
kwargs: contains attributes which are attached to the returned instance, for example:
shape: specifies the appearance of the item, as an instance of Shape.
position: specified as a Vector.
orientation: specified as an Orientation.
update: a callable, of the signature:
- update(self, time, dt)¶
This is called in between every render (unless it is None.)
You should feel free to pass in other attributes, which you might use in this item’s update method, for example .velocity, which you could use to move this item.
glyph: is used to store the shape converted into a VBO which OpenGL can render. If you update a GameItem shape, you must also update its glyph attribute using shape_to_glyph().
In addition, the attribute .id is assigned a unique integer.
Bases: object
Initialise Gloopy. Must be called before calling run() to start the event loop. You may pass in a pyglet.window.Window instance, or if it is None, we will create a (non-visible) one, using self.options to determine its parameters.
Handle key presses:
escape | quit |
f12 | toggle fps display |
f9 | take screenshot |
alt-enter | toggle fullscreen |
Bases: object
A collection of all the GameItems to be updated and rendered. Supports iteration through all added items, and indexing by item.id to get a particular item.
Attributes:
self.item_added: event which is fired after an item is added.
self.item_removed: event which is fired after an item is removed.
self.background_color: color used to clear the screen before render