NotQuiteParadise2

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]
property current_frame_set: List[Image]
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 height: int
property image: nqp.base_classes.image.Image

Return the current frame.

property is_finished: bool

” Return True if this animation has finished playing.

pause()[source]

Pause the animation

play()[source]

Resume the animation

reset()[source]

Reset and pause the animation

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.

stop()[source]

Finish the animation

property surface: pygame.Surface

Return the current frame’s surface.

update(delta_time: float, game_speed: float)[source]
property width: int

nqp.base_classes.controller module

class Controller(game: Game, parent_scene: WorldScene)[source]

Bases: abc.ABC

Manage game functionality for a specific context

  • Modify game state in accordance with game rules

  • Do not draw anything

__init__(game: Game, parent_scene: WorldScene)[source]
abstract reset()[source]
abstract update(delta_time: float)[source]

nqp.base_classes.effect_processor module

class EffectProcessor[source]

Bases: abc.ABC

update(time_delta: float, game: Game)[source]

Handle changes for this Processor

For example:
for eid, (burn,) in list(OnFireStatusSystem.burning):

burn.ttl -= time_delta

nqp.base_classes.entity_behaviour module

class EntityBehaviour(game: Game, unit: Unit, entity: EntityID)[source]

Bases: abc.ABC

__init__(game: Game, unit: Unit, entity: EntityID)[source]
abstract update(delta_time: float)[source]
update_target_entity()[source]

Pick a new target from valid options, as per Unit Behaviour.

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 height: int
property surface: pygame.Surface
property width: int

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.

__init__(base_value)[source]
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

override(value)[source]

Force the value and ignore modifiers

remove_modifier(key: Any)[source]

Remove a modifier

Parameters

key – Unique identifier for adding and removing

reset()[source]

Remove any modifiers and override.

property value

nqp.base_classes.ui module

nqp.base_classes.ui_element module

class UIElement(game: Game, pos: pygame.Vector2, is_selectable: bool = False, tooltip_key: str | None = None)[source]

Bases: abc.ABC

__init__(game: Game, pos: pygame.Vector2, is_selectable: bool = False, tooltip_key: str | None = None)[source]
draw(surface: pygame.Surface)[source]
property height: int
property is_selected: bool
set_active(is_active: bool)[source]
update(delta_time: float)[source]
property width: int
property x: int
property y: int

Module contents