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
max_speed

Maximum linear speed

Type:int
max_accel

Maximum linear acceleration

Type:int
orientation

Current orientation in degrees

Type:int
rotation

Current angular velocity

Type:int
max_rotation

Maximum angular speed

Type:int
max_angular_accel

Maximum angular acceleration

Type:int
get_lines()[source]

Reruns what it returns, can you guess what it is?

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
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
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
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
class gameobject.DummyGameObject(position=(0, 0))[source]

A Dummy with GameObject properties

Derives 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)