Effect
src.view.effect
¶
Visual effect view model.
Effects are loaded from external sprite sheets when configured for a competence. The class extracts frames, advances effect playback, optionally interpolates projectile movement toward a target, and draws the active effect on the screen.
The documentation follows Google-style docstrings so tools such as pdoc, Sphinx Napoleon, or MkDocs-based pipelines can expose parameters, return values, and side effects in a consistent HTML API reference.
Effect
¶
Runtime state for a visual competence effect.
An effect can be attached to an attack or defense. It stores the selected frame sequence, playback position, screen coordinates, and optional interpolation path for moving effects.
Attributes:
| Name | Type | Description |
|---|---|---|
current_effect |
tuple | None
|
Metadata of the active effect. |
effect_frames |
list[Surface]
|
Frames of the active effect. |
effect_x |
list | ndarray | None
|
Horizontal playback positions. |
effect_y |
list | ndarray | None
|
Vertical playback positions. |
Notes
This class is documented as part of the public project API and is intended to be readable in generated HTML documentation.
Source code in src\view\effect.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
set_effects()
¶
Load external effect sprite sheets declared by the sprite configuration.
Returns:
| Name | Type | Description |
|---|---|---|
None |
This method is executed for its side effects. |
Side Effects
Loads configured effect sprite sheets from disk.
Source code in src\view\effect.py
reset_effect()
¶
Clear the active effect and reset playback indexes.
Returns:
| Name | Type | Description |
|---|---|---|
None |
This method is executed for its side effects. |
Side Effects
Clears active effect state and resets playback counters.
Source code in src\view\effect.py
apply_effect(dt, orientation='right')
¶
Advance the active effect playback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
Elapsed time since the previous frame, used to advance animations. |
required | |
orientation
|
Rendering orientation, typically right or left for mirrored sprites. |
'right'
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
|
Side Effects
Advances effect frame counters and may clear the active effect.
Source code in src\view\effect.py
update(x, y, state, type, target_pos=None)
¶
Select and position the effect matching a competence activation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Horizontal coordinate in pixels, unless explicitly used as a grid coordinate. |
required | |
y
|
Vertical coordinate in pixels, unless explicitly used as a grid coordinate. |
required | |
state
|
Gameplay or animation state to apply. |
required | |
type
|
Action subtype, competence name, or category key used by the caller. |
required | |
target_pos
|
Optional target position used to place or interpolate a visual effect. |
None
|
Returns:
| Type | Description |
|---|---|
|
bool | None: For animations and effects, indicates completion or active playback; for rendering/update controllers, no explicit value is returned. |
Side Effects
Mutates animation, effect, terrain, and rendering state depending on the object.
Notes
The method is part of the frame loop and is expected to be called repeatedly.
Source code in src\view\effect.py
draw(screen)
¶
Draw the current effect frame on the provided surface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Pygame surface or screen wrapper used as the drawing target. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
This method is executed for its side effects. |
Side Effects
Blits animation and effect frames to the target surface.
Source code in src\view\effect.py
extract_frames(sprite_sheet, frame_width, frame_height, num_cols, num_rows, start_col=0, start_row=0)
¶
Extract and scale effect frames from a sprite sheet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sprite_sheet
|
Pygame surface containing animation frames. |
required | |
frame_width
|
Width of one frame in the sprite sheet. |
required | |
frame_height
|
Height of one frame in the sprite sheet. |
required | |
num_cols
|
Number of columns in the sprite-sheet grid. |
required | |
num_rows
|
Number of rows in the sprite-sheet grid. |
required | |
start_col
|
First column index to extract from the sprite sheet. |
0
|
|
start_row
|
First row index to extract from the sprite sheet. |
0
|
Returns:
| Type | Description |
|---|---|
|
list[pygame.Surface]: Extracted frames in traversal order. |