Module game_qu.platformer.game_object
Expand source code
from game_qu.base.id_creator import id_creator
from game_qu.gui_components.component import Component
class GameObject(Component):
"""A class that use is for providing functions and attributes that must be in common for all game objects (or at least almost all)"""
object_type = ""
name = None
def __init__(self, path_to_image=""):
"""Initializes the object"""
super().__init__(path_to_image)
self.name = id_creator.get_unique_id()
def update_for_side_scrolling(self, amount):
"""Updates the inanimate object, so it side scrolls"""
self.left_edge -= amount
def get_collidable_components(self):
"""
Returns:
list[Component]: the components of this object that are collidable"""
return [self]
def run_collisions(self):
"""Runs all the collision logic for a game object"""
pass
def get_all_components(self):
"""
Returns:
list[Component]: all the components of this game_object
"""
return [self]
Classes
class GameObject (path_to_image='')-
A class that use is for providing functions and attributes that must be in common for all game objects (or at least almost all)
Initializes the object
Expand source code
class GameObject(Component): """A class that use is for providing functions and attributes that must be in common for all game objects (or at least almost all)""" object_type = "" name = None def __init__(self, path_to_image=""): """Initializes the object""" super().__init__(path_to_image) self.name = id_creator.get_unique_id() def update_for_side_scrolling(self, amount): """Updates the inanimate object, so it side scrolls""" self.left_edge -= amount def get_collidable_components(self): """ Returns: list[Component]: the components of this object that are collidable""" return [self] def run_collisions(self): """Runs all the collision logic for a game object""" pass def get_all_components(self): """ Returns: list[Component]: all the components of this game_object """ return [self]Ancestors
Subclasses
Class variables
var namevar object_type
Methods
def get_all_components(self)-
Returns
list[Component]- all the components of this game_object
Expand source code
def get_all_components(self): """ Returns: list[Component]: all the components of this game_object """ return [self] def get_collidable_components(self)-
Returns
list[Component]- the components of this object that are collidable
Expand source code
def get_collidable_components(self): """ Returns: list[Component]: the components of this object that are collidable""" return [self] def run_collisions(self)-
Runs all the collision logic for a game object
Expand source code
def run_collisions(self): """Runs all the collision logic for a game object""" pass def update_for_side_scrolling(self, amount)-
Updates the inanimate object, so it side scrolls
Expand source code
def update_for_side_scrolling(self, amount): """Updates the inanimate object, so it side scrolls""" self.left_edge -= amount
Inherited members
Component:bottom_edgeget_scaled_dimensionsgot_clickedhorizontal_midpointmouse_enter_functionmouse_exit_functionnumber_set_dimensionspercentage_set_dimensionsrenderright_edgerunset_colorset_dimensions_within_componentset_mouse_enter_functionset_mouse_exit_functionset_mouse_functionsvertical_midpoint