nqp.base_classes package¶
Submodules¶
nqp.base_classes.animation module¶
- class Animation(frames: Dict[str, List[Image]], frame_duration: float = 0.6, loop: bool = True, starting_frame_set_name: str = None, uses_simulation_time: bool = True)[source]¶
Bases:
object
Class to hold visual information for a series of images
- __init__(frames: Dict[str, List[Image]], frame_duration: float = 0.6, loop: bool = True, starting_frame_set_name: str = None, uses_simulation_time: bool = True)[source]¶
- flash(colour: Tuple[int, int, int], duration: float = 0.05)[source]¶
Change the colour of the sprite for a given period.
- get_frame(frame_num: int) nqp.base_classes.image.Image [source]¶
Return the Image of the nth frame
- property image: nqp.base_classes.image.Image¶
Return the current frame.
- set_current_frame_set_name(frame_set_name: str)[source]¶
Set the frame set to be used.
If the name given isnt a valid key no action is taken.
- property surface: pygame.Surface¶
Return the current frame’s surface.
nqp.base_classes.controller module¶
nqp.base_classes.effect_processor module¶
nqp.base_classes.entity_behaviour module¶
nqp.base_classes.image module¶
- class Image(*args: pygame.sprite.Group, image: pygame.Surface)[source]¶
Bases:
pygame.sprite.Sprite
Class to hold visual information for static images
- __init__(*args: pygame.sprite.Group, image: pygame.Surface)[source]¶
- property surface: pygame.Surface¶
nqp.base_classes.resource_controller module¶
- class ResourceController(loader: Callable, is_weakref: bool)[source]¶
Bases:
abc.ABC
Base class with a general specification for lazily loading game resources.
Resources in a ResourceController can be accessed just like in a dictionary.
Initialize a ResourceController.
- Parameters
loader – function used to create a new object. When it does not exist,
the loader function gets called with the key passed to the controller as an argument. :param is_weakref: weakref is used to allow garbage collecting values that are no longer used even if they are referenced by the dictionary, meaning the cache dictionary does not increase the reference count for its values, so they get can be released from memory when not referenced elsewhere.
- __init__(loader: Callable, is_weakref: bool)[source]¶
Initialize a ResourceController.
- Parameters
loader – function used to create a new object. When it does not exist,
the loader function gets called with the key passed to the controller as an argument. :param is_weakref: weakref is used to allow garbage collecting values that are no longer used even if they are referenced by the dictionary, meaning the cache dictionary does not increase the reference count for its values, so they get can be released from memory when not referenced elsewhere.
nqp.base_classes.scene module¶
nqp.base_classes.stat module¶
- class Stat(base_value)[source]¶
Bases:
abc.ABC
A container for an Entities Stat and related functionality.
base_value is used as the reference for modifiers. value is the result after modifiers are applied. override forces a specific value to be used, ignoring modifiers.
- apply_modifier(func: Callable, key: Any)[source]¶
Add a modifier
When value is calculated,
func
will be called with the base value- Parameters
func – Any callable function
key – Unique identifier for adding and removing
- property base_value¶
- has_modifier(key: Any)[source]¶
Check if modifier is applied
- Parameters
key – Unique identifier for adding and removing
- remove_modifier(key: Any)[source]¶
Remove a modifier
- Parameters
key – Unique identifier for adding and removing
- property value¶