Game Object¶
General-Purpose Game Object
This module implements the GameObject class, core of this AI engine, along with other useful classes, methods and constants
-
class
gameobject.
GameObject
(img_surf=<Surface(0x0x32 SW)>, pos=(0, 0), max_speed=30, max_accel=20, max_rotation=60, max_angular_accel=50)[source]¶ General-Purpose Game Object.
Derives from pygame.sprite.Sprite.
Holds values relevant to any non-static entity in the game.
Parameters: - img_surf (pygame.Surface) – It is asigned to self.image, defaults to
null_surface
- pos (list_like(int, int), optional) – Initial Position, it is assigned to self.rect.center
- max_speed (int, optional) – Maximum linear speed
- max_accel (int, optional) – Maximum linear acceleration
- max_rotation (int, optional) – Maximum angular speed
- max_angular_accel (int, optional) – Maximum angular acceleration
This class exposes the following public properties and methods
-
image
¶ Surface to be blited to screen
Type: pygame.Surface
-
rect
¶ Derived from image, it’s center is the GameObejct’s position
Type: pygame.Rect
-
position
¶ Current position
Type: pygame.math.Vector2
-
velocity
¶ Current velocity
Type: pygame.math.Vector2
-
steer
(steering, tick)[source]¶ Updates GameObject’s velocity and rotation
Parameters: - steering (
kinematic.SteeringOutput
or :py:class:.`static.SteeringOutput`) – The steering request to update velocity and rotation - tick (int) – Time passed since the last loop
- steering (
-
steer_angular
(steering, tick)[source]¶ Updates GameObject’s rotation
Parameters: - steering (
kinematic.SteeringOutput
or :py:class:.`static.SteeringOutput`) – The steering request to update velocity and rotation - tick (int) – Time passed since the last loop
- steering (
-
steer_x
(steering, tick)[source]¶ Updates GameObject’s velocity along the x axis
Parameters: - steering (
kinematic.SteeringOutput
or :py:class:.`static.SteeringOutput`) – The steering request to update velocity and rotation - tick (int) – Time passed since the last loop
- steering (
-
steer_y
(steering, tick)[source]¶ Updates GameObject’s velocity along the y axis
Parameters: - steering (
kinematic.SteeringOutput
or :py:class:.`static.SteeringOutput`) – The steering request to update velocity and rotation - tick (int) – Time passed since the last loop
- steering (
- img_surf (pygame.Surface) – It is asigned to self.image, defaults to
-
class
gameobject.
DummyGameObject
(position=(0, 0))[source]¶ A Dummy with
GameObject
propertiesDerives from
GameObject
.Used for quick instantiation when creating
GameObject
s that will only be used as palceholders and are not meant to appear on screen.Parameters: position (list_like(int, int)) – Current position
-
gameobject.
null_surface
= <Surface(0x0x32 SW)>¶ Empty Surface with size 0
Type: (pygame.Surface)