core.managers package

Submodules

core.managers.event module

Creation, retrieval, posting and deletion of events using Forge’s custom event management system.

class core.managers.event.Event(name: str, _subscribers: dict[typing.Callable[[typing.Any, ...], NoneType], tuple[typing.Any, ...]] = <factory>)

Bases: object

Forge’s basic but sufficient event system for both internal and developer use.

name: str
post() None

Post the event that calls all of its subscriber functions with their respective arguments. If an exception occurs when calling a subscriber function, it is raised as a warning instead.

Raises

RuntimeWarning – A subscribed function had an error during its execution. The severity is bumped down to a warning instead.

core.managers.event.delete_event(event_name: str) None

Delete a registered event from the event dictionary. Acts as an abstraction over the package-protected dictionary. Also does not allow deletion of an internal event.

Parameters

event_name (str) – Name of the event to delete.

Raises
  • ValueError – Internal events cannot be deleted.

  • KeyError – Event must be present in the event dictionary to delete.

core.managers.event.get_event(event_name: str) Event

Get a registered event from the event dictionary. Acts as an abstraction over the package-protected dictionary. Also does not allow getting an internal event.

Parameters

event_name (str) – Name of the event to retrieve.

Returns

Event from the dictionary with the same name.

Return type

Event

Raises
  • ValueError – Internal events cannot be retrieved.

  • KeyError – Event must be present in the event dictionary to retrieve.

core.managers.keyboard module

Keyboard management in Forge.

class core.managers.keyboard.Key(value)

Bases: Enum

Keys with direct-wrapping to Pygame’s key-codes; which themselves are wrapped for SDL key codes.

A = 97
AMPERSAND = 38
ASTERISK = 42
AT = 64
B = 98
BACKSLASH = 92
BACKSPACE = 8
BACK_QUOTE = 96
BREAK = 1073741896
C = 99
CAPS_LOCK = 1073741881
CARET = 94
CLEAR = 1073741980
COLON = 58
COMMA = 44
CURRENCY_SUBUNIT = 1073742005
CURRENCY_UNIT = 1073742004
D = 100
DELETE = 127
DOLLAR = 36
DOWN = 1073741905
E = 101
END = 1073741901
EQUALS = 61
ESCAPE = 27
EURO = 1073742004
EXCLAMATION_MARK = 33
F = 102
F1 = 1073741882
F10 = 1073741891
F11 = 1073741892
F12 = 1073741893
F13 = 1073741928
F14 = 1073741929
F15 = 1073741930
F2 = 1073741883
F3 = 1073741884
F4 = 1073741885
F5 = 1073741886
F6 = 1073741887
F7 = 1073741888
F8 = 1073741889
F9 = 1073741890
G = 103
GREATER = 62
H = 104
HASH = 35
HELP = 1073741941
HOME = 1073741898
I = 105
INSERT = 1073741897
J = 106
K = 107
KEYPAD_DIVIDE = 1073741908
KEYPAD_ENTER = 1073741912
KEYPAD_EQUALS = 1073741927
KEYPAD_MINUS = 1073741910
KEYPAD_MULTIPLY = 1073741909
KEYPAD_NUM_0 = 1073741922
KEYPAD_NUM_1 = 1073741913
KEYPAD_NUM_2 = 1073741914
KEYPAD_NUM_3 = 1073741915
KEYPAD_NUM_4 = 1073741916
KEYPAD_NUM_5 = 1073741917
KEYPAD_NUM_6 = 1073741918
KEYPAD_NUM_7 = 1073741919
KEYPAD_NUM_8 = 1073741920
KEYPAD_NUM_9 = 1073741921
KEYPAD_PERIOD = 1073741923
KEYPAD_PLUS = 1073741911
L = 108
LEFT = 1073741904
LEFT_ALT = 1073742050
LEFT_BRACKET = 91
LEFT_CTRL = 1073742048
LEFT_PAREN = 40
LEFT_SHIFT = 1073742049
LESS = 60
M = 109
MENU = 1073741942
MINUS = 45
MODE = 1073742081
N = 110
NUM_0 = 48
NUM_1 = 49
NUM_2 = 50
NUM_3 = 51
NUM_4 = 52
NUM_5 = 53
NUM_6 = 54
NUM_7 = 55
NUM_8 = 56
NUM_9 = 57
NUM_LOCK = 1073741907
O = 111
P = 112
PAGE_DOWN = 1073741902
PAGE_UP = 1073741899
PAUSE = 1073741896
PERCENT = 37
PERIOD = 46
PLUS = 43
POWER = 1073741926
PRINT = 1073741894
PRINT_SCREEN = 1073741894
Q = 113
QUESTION_MARK = 63
QUOTE = 39
R = 114
RETURN = 13
RIGHT = 1073741903
RIGHT_ALT = 1073742054
RIGHT_BRACKET = 93
RIGHT_CTRL = 1073742052
RIGHT_PAREN = 41
RIGHT_SHIFT = 1073742053
S = 115
SCROLL_LOCK = 1073741895
SEMICOLON = 59
SLASH = 47
SPACE = 32
T = 116
TAB = 9
U = 117
UNDERSCORE = 95
UNKNOWN = 0
UP = 1073741906
V = 118
W = 119
X = 120
Y = 121
Z = 122

core.managers.mouse module

Forge’s direct wrapping for Pygame’s mouse.

class core.managers.mouse.MouseButton(value)

Bases: Enum

Enum containing all possible mouse buttons for a simple three-buttoned mouse.

LEFT = 0
MIDDLE = 1
RIGHT = 2
core.managers.mouse.is_any_pressed() bool

Check if any mouse button of a three-buttoned mouse is pressed.

Returns

True if any mouse button is pressed; else False.

Return type

bool

core.managers.mouse.is_pressed(mouse_button: MouseButton) bool

Check if a certain mouse button of a three-buttoned mouse is pressed.

Parameters

mouse_button (MouseButton) – Enum value of the mouse button to check.

Returns

True if the mouse button passed is pressed; else False.

Return type

bool

core.managers.mouse.modify_visibility(visible: bool) None

Change the visibility of the mouse on the display.

Parameters

visible (bool) – Whether the mouse should be made visible or not.

core.managers.mouse.movement() Vector2D

Get the relative position, or movement, of the mouse as a vector.

Returns

Relative mouse position.

Return type

core.physics.vector.Vector2D

core.managers.mouse.position() Vector2D

Get the current mouse position as a vector.

Returns

Current mouse position.

Return type

core.physics.vector.Vector2D

Module contents