| |
- Method resolution order:
- Engine
- gummworld2.context.Context
- __builtin__.object
Methods defined here:
- __init__(self, screen_surface=None, resolution=None, display_flags=0, caption=None, camera_target=None, camera_view=None, camera_view_rect=None, map=None, tile_size=None, map_size=None, update_speed=30, frame_speed=30, world_type=0, world_args={}, set_state=True)
- Construct an instance of Engine.
This constructor does the following:
The pygame display is initialized with an optional caption, and the
resulting screen.Screen object is placed in State.screen.
An empty map.BasicMap object is created and placed in State.map.
An empty model.World* object is created and placed in State.world.
State.world_type is set to one of the engine.*_WORLD values
corresponding to the world object in State.world.
A camera.Camera object is created and placed in State.camera. The
camera target is either taken from the camera_target argument, or an
appropriate target for world type is created. The target is *NOT*
added to the world, as the target does not need to be an object
subject to game rules. If target happens to be an avatar-type object
then add it manually to world with the rest of the world entities.
A game_clock.GameClock object is created and placed in State.clock.
Joystick objects are created for connected controllers.
The following arguments are used to initialize a Screen object:
The screen_surface argument specifies the pygame top level surface
to use for creating the State.screen object. The presence of this
argument overrides initialization of the pygame display, and
resolution and display_flags arguments are ignored. Use this if
the pygame display has already been initialized in the calling
program.
The resolution argument specifies the width and height of the
display.
The display_flags argument specifies the pygame display flags to
pass to the display initializer.
The caption argument is a string to use as the window caption.
The following arguments are used to initialize a Camera object:
The camera_target argument is the target that the camera will track.
If camera_target is None, Engine will create a default target
appropriate for the world type.
The camera_view argument is a screen.View object to use as the
camera's view.
The camera_view_rect argument specifies the pygame Rect from which
to create a screen.View object for the camera's view.
State.screen.surface is used as the source surface. This argument is
ignored if camera_view is not None.
The following arguments are used to initialize a BasicMap object:
The tile_size and map_size arguments specify the width and height of
a map tile, and width and height of a map in tiles, respectively.
The following arguments are used to initialize a model.World* object:
The world_type argument specifies which of the world classes to
create. It must be one of engine.NO_WORLD, or engine.SIMPLE_WORLD.
The world_args argument is a dict that can be passed verbatim to
the world constructor (see the World* classes in the model module)
like so: World(**world_args).
The following arguments are used to initialize a Clock object:
update_speed specifies the maximum updates that can occur per
second.
frame_speed specifies the maximum frames that can occur per second.
The clock sacrifices frames per second in order to achieve the desired
updates per second. If frame_speed is 0 the frame rate is uncapped.
Engine.update() and Engine.draw() are registered as callbacks in the
clock.
- draw(self, interp)
- Override this method. Called by run() when the clock signals a
frame cycle is ready.
Suggestion:
State.screen.clear()
... custom draw the screen ...
State.screen.flip()
- enter(self)
- Called when the context is entered.
If you override this, make sure you call the super.
- on_active_event(self, gain, state)
- ## Override an event handler to get specific events.
- on_joy_axis_motion(self, joy, axis, value)
- on_joy_ball_motion(self, joy, ball, rel)
- on_joy_button_down(self, joy, button)
- on_joy_button_up(self, joy, button)
- on_joy_hat_motion(self, joy, hat, value)
- on_key_down(self, unicode, key, mod)
- on_key_up(self, key, mod)
- on_mouse_button_down(self, pos, button)
- on_mouse_button_up(self, pos, button)
- on_mouse_motion(self, pos, rel, buttons)
- on_quit(self)
- on_user_event(self, e)
- on_video_expose(self)
- on_video_resize(self, size, w, h)
- resume(self)
- Called when the context is resumed.
If you override this, make sure you call the super.
- set_state(self)
- update(self, dt)
- Override this method. Called by run() when the clock signals an
update cycle is ready.
Suggestion:
move_camera()
State.camera.update()
... custom update the rest of the game ...
Data descriptors defined here:
- joysticks
- List of initialized joysticks.
Data and other attributes defined here:
- NO_WORLD = 0
- SIMPLE_WORLD = 1
Methods inherited from gummworld2.context.Context:
- exit(self)
- Called when this context is popped off the stack.
- suspend(self)
- Called when another context is pushed on top of this one.
Static methods inherited from gummworld2.context.Context:
- pop(n=1)
- push(c, do_enter=True)
- top()
Data descriptors inherited from gummworld2.context.Context:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|