Static¶
Static movement
This module implements a series of classes and methods that emulate the behavior of objects moving in a 2D space in a static way (not involving acceleration)
Notes
This might need a slightly better explaination
SteeringOutput¶
-
class
steering.static.
SteeringOutput
(velocity=None, rotation=None)[source]¶ Container for Steering data
This class is used as a container for the output of the
StaticSteeringBehavior
algorithms.Parameters: - velocity (pygame.math.Vector2, optional) – Linear velocity, defaults to (0, 0)
- rotation (int, optional) – Angular velocity, defaults to 0
-
velocity
¶ Linear velocity
Type: pygame.math.Vector2
-
update
(gameobject, tick)[source]¶ Update a
GameObject
’s velocity and rotationThis method should be called once per loop, it updates the given
gameobject.GameObject
’s velocity and rotation based on thisSteeringOutput
’s acceleration requestParameters: - gameobject (
GameObject
) – TheGameObject
that will be updated - tick (int) – Time transcurred since last loop
- gameobject (
-
steering.static.
null_steering
¶ Constant with 0 linear velocity and 0 angular velocity
Type: SteeringOutput
StaticSteeringBehavior¶
-
class
steering.static.
StaticSteeringBehavior
[source]¶ Template StaticSteeringBehavior class
This class is a template to supply base methods for StaticSteeringBehaviors. This class is meant to be subclassed since the methods here are just placeholders
-
draw_indicators
(screen, offset=<function StaticSteeringBehavior.<lambda>>)[source]¶ Draws appropiate indicators for each
StaticSteeringBehavior
Parameters: - screen (pygame.Surface) – Surface in which to draw indicators, normally this would be the screen Surface
- offset (function, optional) –
Function that applies an offset to the object’s position
This is meant to be used together with scrolling cameras, leave empty if your game doesn’t implement one,it defaults to a linear function f(pos) -> pos
-
get_steering
()[source]¶ Returns a steering request
Returns: Requested steering Return type: SteeringOutput
-
-
class
steering.static.
Arrive
(character, target, radius=None, time_to_arrive=0.25)[source]¶ StaticSteeringBehavior
that makes the character Arrive at a targetParameters: - character (
GameObject
) – Character with this behavior - target (
GameObject
) – Target to Arrive at - radius (int, optional) – Distance from the center of the target at which the character will stop
- time_to_arrive (float, optional) – Estimated time, in seconds, to Arrive at the target
- character (
-
class
steering.static.
Flee
(character, target)[source]¶ StaticSteeringBehavior
that makes the character Flee from a targetParameters: - character (
GameObject
) – Character with this behavior - target (
GameObject
) – Target to Flee from
- character (
-
class
steering.static.
Seek
(character, target)[source]¶ StaticSteeringBehavior
that makes the character Seek a targetParameters: - character (
GameObject
) – Character with this behavior - target (
GameObject
) – Target to Seek
- character (
-
class
steering.static.
Wander
(character)[source]¶ StaticSteeringBehavior
that makes the character WanderThis behavior makes the character move with it’s maximum speed in a particular direction for a random period of time, after that the character’s orientation is changed randomly using the character’s
max_rotation
.Parameters: character ( GameObject
) – Character with this behavior