kraken-engine 1.0.0__cp311-cp311-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pykraken/_core/key.pyi ADDED
@@ -0,0 +1,73 @@
1
+ """
2
+ Keyboard key state checks
3
+ """
4
+ from __future__ import annotations
5
+ import pykraken._core
6
+ import typing
7
+ __all__: list[str] = ['is_just_pressed', 'is_just_released', 'is_pressed']
8
+ @typing.overload
9
+ def is_just_pressed(scancode: pykraken._core.Scancode) -> bool:
10
+ """
11
+ Check if a key was pressed this frame (by scancode).
12
+
13
+ Args:
14
+ scancode (Scancode): The physical key.
15
+
16
+ Returns:
17
+ bool: True if the key was newly pressed.
18
+ """
19
+ @typing.overload
20
+ def is_just_pressed(keycode: pykraken._core.Keycode) -> bool:
21
+ """
22
+ Check if a key was pressed this frame (by keycode).
23
+
24
+ Args:
25
+ keycode (Keycode): The symbolic key.
26
+
27
+ Returns:
28
+ bool: True if the key was newly pressed.
29
+ """
30
+ @typing.overload
31
+ def is_just_released(scancode: pykraken._core.Scancode) -> bool:
32
+ """
33
+ Check if a key was released this frame (by scancode).
34
+
35
+ Args:
36
+ scancode (Scancode): The physical key.
37
+
38
+ Returns:
39
+ bool: True if the key was newly released.
40
+ """
41
+ @typing.overload
42
+ def is_just_released(keycode: pykraken._core.Keycode) -> bool:
43
+ """
44
+ Check if a key was released this frame (by keycode).
45
+
46
+ Args:
47
+ keycode (Keycode): The symbolic key.
48
+
49
+ Returns:
50
+ bool: True if the key was newly released.
51
+ """
52
+ @typing.overload
53
+ def is_pressed(scancode: pykraken._core.Scancode) -> bool:
54
+ """
55
+ Check if a key is currently held down (by scancode).
56
+
57
+ Args:
58
+ scancode (Scancode): The physical key (e.g., S_w).
59
+
60
+ Returns:
61
+ bool: True if the key is held.
62
+ """
63
+ @typing.overload
64
+ def is_pressed(keycode: pykraken._core.Keycode) -> bool:
65
+ """
66
+ Check if a key is currently held down (by keycode).
67
+
68
+ Args:
69
+ keycode (Keycode): The symbolic key (e.g., K_SPACE).
70
+
71
+ Returns:
72
+ bool: True if the key is held.
73
+ """
@@ -0,0 +1,10 @@
1
+ from __future__ import annotations
2
+ import pykraken._core
3
+ __all__: list[str] = ['move']
4
+ def move(line: pykraken._core.Line, offset: pykraken._core.Vec2) -> pykraken._core.Line:
5
+ """
6
+ Move the given line by a Vec2 or 2-element sequence.
7
+
8
+ Args:
9
+ offset (Vec2 | list[float]): The amount to move.
10
+ """
@@ -0,0 +1,173 @@
1
+ """
2
+ Math related functions
3
+ """
4
+ from __future__ import annotations
5
+ import pykraken._core
6
+ import typing
7
+ __all__: list[str] = ['angle_between', 'clamp', 'cross', 'dot', 'from_polar', 'lerp', 'normalize', 'remap', 'scale_to_length', 'to_deg', 'to_rad']
8
+ def angle_between(a: pykraken._core.Vec2, b: pykraken._core.Vec2) -> float:
9
+ """
10
+ Calculate the angle between two vectors.
11
+
12
+ Args:
13
+ a (Vec2): The first vector.
14
+ b (Vec2): The second vector.
15
+
16
+ Returns:
17
+ float: The angle between the vectors in radians [0, π].
18
+ """
19
+ @typing.overload
20
+ def clamp(vec: pykraken._core.Vec2, min_vec: pykraken._core.Vec2, max_vec: pykraken._core.Vec2) -> pykraken._core.Vec2:
21
+ """
22
+ Clamp a vector between two boundary vectors.
23
+
24
+ Args:
25
+ vector (Vec2): The vector to clamp.
26
+ min_vec (Vec2): The minimum boundary vector.
27
+ max_vec (Vec2): The maximum boundary vector.
28
+
29
+ Returns:
30
+ Vec2: A new vector with components clamped between min and max.
31
+ """
32
+ @typing.overload
33
+ def clamp(value: typing.SupportsFloat, min_val: typing.SupportsFloat, max_val: typing.SupportsFloat) -> float:
34
+ """
35
+ Clamp a value between two boundaries.
36
+
37
+ Args:
38
+ value (float): The value to clamp.
39
+ min_val (float): The minimum boundary.
40
+ max_val (float): The maximum boundary.
41
+
42
+ Returns:
43
+ float: The clamped value.
44
+ """
45
+ def cross(a: pykraken._core.Vec2, b: pykraken._core.Vec2) -> float:
46
+ """
47
+ Calculate the 2D cross product of two vectors.
48
+
49
+ Args:
50
+ a (Vec2): The first vector.
51
+ b (Vec2): The second vector.
52
+
53
+ Returns:
54
+ float: The 2D cross product (a.x * b.y - a.y * b.x).
55
+ """
56
+ def dot(a: pykraken._core.Vec2, b: pykraken._core.Vec2) -> float:
57
+ """
58
+ Calculate the dot product of two vectors.
59
+
60
+ Args:
61
+ a (Vec2): The first vector.
62
+ b (Vec2): The second vector.
63
+
64
+ Returns:
65
+ float: The dot product (a.x * b.x + a.y * b.y).
66
+ """
67
+ @typing.overload
68
+ def from_polar(angle: typing.SupportsFloat, radius: typing.SupportsFloat) -> pykraken._core.Vec2:
69
+ """
70
+ Convert polar coordinates to a Cartesian vector.
71
+
72
+ Args:
73
+ angle (float): The angle in radians.
74
+ radius (float): The radius/distance from origin.
75
+
76
+ Returns:
77
+ Vec2: The equivalent Cartesian vector.
78
+ """
79
+ @typing.overload
80
+ def from_polar(polar: pykraken._core.PolarCoordinate) -> pykraken._core.Vec2:
81
+ """
82
+ Convert a PolarCoordinate object to a Cartesian vector.
83
+
84
+ Args:
85
+ polar (PolarCoordinate): The polar coordinate to convert.
86
+
87
+ Returns:
88
+ Vec2: The equivalent Cartesian vector.
89
+ """
90
+ @typing.overload
91
+ def lerp(a: pykraken._core.Vec2, b: pykraken._core.Vec2, t: typing.SupportsFloat) -> pykraken._core.Vec2:
92
+ """
93
+ Linearly interpolate between two Vec2s.
94
+
95
+ Args:
96
+ a (Vec2): The start vector.
97
+ b (Vec2): The end vector.
98
+ t (float): The interpolation factor [0.0, 1.0].
99
+
100
+ Returns:
101
+ Vec2: The interpolated vector.
102
+ """
103
+ @typing.overload
104
+ def lerp(a: typing.SupportsFloat, b: typing.SupportsFloat, t: typing.SupportsFloat) -> float:
105
+ """
106
+ Linearly interpolate between two values.
107
+
108
+ Args:
109
+ a (float): The start value.
110
+ b (float): The end value.
111
+ t (float): The interpolation factor [0.0, 1.0].
112
+
113
+ Returns:
114
+ float: The interpolated value.
115
+ """
116
+ def normalize(vec: pykraken._core.Vec2) -> pykraken._core.Vec2:
117
+ """
118
+ Normalize a vector to unit length.
119
+
120
+ Args:
121
+ vector (Vec2): The input vector.
122
+
123
+ Returns:
124
+ Vec2: A new normalized vector.
125
+ """
126
+ def remap(in_min: typing.SupportsFloat, in_max: typing.SupportsFloat, out_min: typing.SupportsFloat, out_max: typing.SupportsFloat, value: typing.SupportsFloat) -> float:
127
+ """
128
+ Remap a value from one range to another.
129
+
130
+ Args:
131
+ in_min (float): Input range minimum.
132
+ in_max (float): Input range maximum.
133
+ out_min (float): Output range minimum.
134
+ out_max (float): Output range maximum.
135
+ value (float): The value to remap.
136
+
137
+ Returns:
138
+ float: The remapped value in the output range.
139
+
140
+ Raises:
141
+ ValueError: If in_min equals in_max.
142
+ """
143
+ def scale_to_length(vector: pykraken._core.Vec2, length: typing.SupportsFloat) -> pykraken._core.Vec2:
144
+ """
145
+ Scale a vector to a given length.
146
+
147
+ Args:
148
+ vector (Vec2): The input vector.
149
+ length (float): The target length.
150
+
151
+ Returns:
152
+ Vec2: A new vector scaled to the specified length.
153
+ """
154
+ def to_deg(radians: typing.SupportsFloat) -> float:
155
+ """
156
+ Convert radians to degrees.
157
+
158
+ Args:
159
+ radians (float): The angle in radians.
160
+
161
+ Returns:
162
+ float: The angle in degrees.
163
+ """
164
+ def to_rad(degrees: typing.SupportsFloat) -> float:
165
+ """
166
+ Convert degrees to radians.
167
+
168
+ Args:
169
+ degrees (float): The angle in degrees.
170
+
171
+ Returns:
172
+ float: The angle in radians.
173
+ """
@@ -0,0 +1,85 @@
1
+ """
2
+ Mouse related functions
3
+ """
4
+ from __future__ import annotations
5
+ import pykraken._core
6
+ __all__: list[str] = ['get_pos', 'get_rel', 'hide', 'is_hidden', 'is_just_pressed', 'is_just_released', 'is_locked', 'is_pressed', 'lock', 'show', 'unlock']
7
+ def get_pos() -> pykraken._core.Vec2:
8
+ """
9
+ Get the current position of the mouse cursor.
10
+
11
+ Returns:
12
+ tuple[float, float]: The current mouse position as (x, y) coordinates.
13
+ """
14
+ def get_rel() -> pykraken._core.Vec2:
15
+ """
16
+ Get the relative mouse movement since the last frame.
17
+
18
+ Returns:
19
+ tuple[float, float]: The relative movement of the mouse as (dx, dy).
20
+ """
21
+ def hide() -> None:
22
+ """
23
+ Hide the mouse cursor from view.
24
+
25
+ The cursor will be invisible but mouse input will still be tracked.
26
+ """
27
+ def is_hidden() -> bool:
28
+ """
29
+ Check if the mouse cursor is currently hidden.
30
+
31
+ Returns:
32
+ bool: True if the cursor is hidden.
33
+ """
34
+ def is_just_pressed(button: pykraken._core.MouseButton) -> bool:
35
+ """
36
+ Check if a mouse button was pressed this frame.
37
+
38
+ Args:
39
+ button (MouseButton): The mouse button to check.
40
+
41
+ Returns:
42
+ bool: True if the button was just pressed.
43
+ """
44
+ def is_just_released(button: pykraken._core.MouseButton) -> bool:
45
+ """
46
+ Check if a mouse button was released this frame.
47
+
48
+ Args:
49
+ button (MouseButton): The mouse button to check.
50
+
51
+ Returns:
52
+ bool: True if the button was just released.
53
+ """
54
+ def is_locked() -> bool:
55
+ """
56
+ Check if the mouse is currently locked to the window.
57
+
58
+ Returns:
59
+ bool: True if the mouse is locked.
60
+ """
61
+ def is_pressed(button: pykraken._core.MouseButton) -> bool:
62
+ """
63
+ Check if a mouse button is currently pressed.
64
+
65
+ Args:
66
+ button (MouseButton): The mouse button to check (e.g., kn.MOUSE_LEFT).
67
+
68
+ Returns:
69
+ bool: True if the button is currently pressed.
70
+ """
71
+ def lock() -> None:
72
+ """
73
+ Lock the mouse to the center of the window.
74
+
75
+ Useful for first-person controls where you want to capture mouse movement
76
+ without letting the cursor leave the window area.
77
+ """
78
+ def show() -> None:
79
+ """
80
+ Show the mouse cursor if it was hidden.
81
+ """
82
+ def unlock() -> None:
83
+ """
84
+ Unlock the mouse from the window, allowing it to move freely.
85
+ """
@@ -0,0 +1,93 @@
1
+ """
2
+ Rectangle related functions
3
+ """
4
+ from __future__ import annotations
5
+ import pykraken._core
6
+ import typing
7
+ __all__: list[str] = ['clamp', 'move', 'scale_by', 'scale_to']
8
+ @typing.overload
9
+ def clamp(rect: pykraken._core.Rect, min: pykraken._core.Vec2, max: pykraken._core.Vec2) -> pykraken._core.Rect:
10
+ """
11
+ Clamp a rectangle to be within the specified bounds.
12
+
13
+ Args:
14
+ rect (Rect): The rectangle to clamp.
15
+ min (Vec2): The minimum bounds as (min_x, min_y).
16
+ max (Vec2): The maximum bounds as (max_x, max_y).
17
+
18
+ Returns:
19
+ Rect: A new rectangle clamped within the bounds.
20
+
21
+ Raises:
22
+ ValueError: If min >= max or rectangle is larger than the clamp area.
23
+ """
24
+ @typing.overload
25
+ def clamp(rect: pykraken._core.Rect, other: pykraken._core.Rect) -> pykraken._core.Rect:
26
+ """
27
+ Clamp a rectangle to be within another rectangle.
28
+
29
+ Args:
30
+ rect (Rect): The rectangle to clamp.
31
+ other (Rect): The rectangle to clamp within.
32
+
33
+ Returns:
34
+ Rect: A new rectangle clamped within the other rectangle.
35
+
36
+ Raises:
37
+ ValueError: If rect is larger than the clamp area.
38
+ """
39
+ def move(rect: pykraken._core.Rect, offset: pykraken._core.Vec2) -> pykraken._core.Rect:
40
+ """
41
+ Move a rectangle by the given offset.
42
+
43
+ Args:
44
+ rect (Rect): The rectangle to move.
45
+ offset (Vec2): The offset to move by as (dx, dy).
46
+
47
+ Returns:
48
+ Rect: A new rectangle moved by the offset.
49
+ """
50
+ @typing.overload
51
+ def scale_by(rect: pykraken._core.Rect, factor: typing.SupportsFloat) -> pykraken._core.Rect:
52
+ """
53
+ Scale a rectangle by a uniform factor.
54
+
55
+ Args:
56
+ rect (Rect): The rectangle to scale.
57
+ factor (float): The scaling factor (must be > 0).
58
+
59
+ Returns:
60
+ Rect: A new rectangle scaled by the factor.
61
+
62
+ Raises:
63
+ ValueError: If factor is <= 0.
64
+ """
65
+ @typing.overload
66
+ def scale_by(rect: pykraken._core.Rect, factor: pykraken._core.Vec2) -> pykraken._core.Rect:
67
+ """
68
+ Scale a rectangle by different factors for width and height.
69
+
70
+ Args:
71
+ rect (Rect): The rectangle to scale.
72
+ factor (Vec2): The scaling factors as (scale_x, scale_y).
73
+
74
+ Returns:
75
+ Rect: A new rectangle scaled by the factors.
76
+
77
+ Raises:
78
+ ValueError: If any factor is <= 0.
79
+ """
80
+ def scale_to(rect: pykraken._core.Rect, size: pykraken._core.Vec2) -> pykraken._core.Rect:
81
+ """
82
+ Scale a rectangle to the specified size.
83
+
84
+ Args:
85
+ rect (Rect): The rectangle to scale.
86
+ size (Vec2): The new size as (width, height).
87
+
88
+ Returns:
89
+ Rect: A new rectangle scaled to the specified size.
90
+
91
+ Raises:
92
+ ValueError: If width or height is <= 0.
93
+ """
@@ -0,0 +1,63 @@
1
+ """
2
+ Functions for rendering graphics
3
+ """
4
+ from __future__ import annotations
5
+ import pykraken._core
6
+ import typing
7
+ __all__: list[str] = ['clear', 'draw', 'get_res', 'present']
8
+ @typing.overload
9
+ def clear(color: typing.Any = None) -> None:
10
+ """
11
+ Clear the renderer with the specified color.
12
+
13
+ Args:
14
+ color (Color, optional): The color to clear with. Defaults to black (0, 0, 0, 255).
15
+
16
+ Raises:
17
+ ValueError: If color values are not between 0 and 255.
18
+ """
19
+ @typing.overload
20
+ def clear(r: typing.SupportsInt, g: typing.SupportsInt, b: typing.SupportsInt, a: typing.SupportsInt = 255) -> None:
21
+ """
22
+ Clear the renderer with the specified color.
23
+
24
+ Args:
25
+ r (int): Red component (0-255).
26
+ g (int): Green component (0-255).
27
+ b (int): Blue component (0-255).
28
+ a (int, optional): Alpha component (0-255). Defaults to 255.
29
+ """
30
+ @typing.overload
31
+ def draw(texture: pykraken._core.Texture, dst: pykraken._core.Rect, src: typing.Any = None) -> None:
32
+ """
33
+ Render a texture with specified destination and source rectangles.
34
+
35
+ Args:
36
+ texture (Texture): The texture to render.
37
+ dst (Rect): The destination rectangle on the renderer.
38
+ src (Rect, optional): The source rectangle from the texture. Defaults to entire texture if not specified.
39
+ """
40
+ @typing.overload
41
+ def draw(texture: pykraken._core.Texture, pos: typing.Any = None, anchor: pykraken._core.Anchor = pykraken._core.Anchor.CENTER) -> None:
42
+ """
43
+ Render a texture at the specified position with anchor alignment.
44
+
45
+ Args:
46
+ texture (Texture): The texture to render.
47
+ pos (Vec2, optional): The position to draw at. Defaults to (0, 0).
48
+ anchor (Anchor, optional): The anchor point for positioning. Defaults to CENTER.
49
+ """
50
+ def get_res() -> pykraken._core.Vec2:
51
+ """
52
+ Get the resolution of the renderer.
53
+
54
+ Returns:
55
+ Vec2: The current rendering resolution as (width, height).
56
+ """
57
+ def present() -> None:
58
+ """
59
+ Present the rendered content to the screen.
60
+
61
+ This finalizes the current frame and displays it. Should be called after
62
+ all drawing operations for the frame are complete.
63
+ """
@@ -0,0 +1,75 @@
1
+ """
2
+ Time related functions
3
+ """
4
+ from __future__ import annotations
5
+ import typing
6
+ __all__: list[str] = ['delay', 'get_delta', 'get_elapsed', 'get_fps', 'get_scale', 'set_max_delta', 'set_scale', 'set_target']
7
+ def delay(milliseconds: typing.SupportsInt) -> None:
8
+ """
9
+ Delay the program execution for the specified duration.
10
+
11
+ This function pauses execution for the given number of milliseconds.
12
+ Useful for simple timing control, though using time.set_cap() is generally
13
+ preferred for precise frame rate control with nanosecond accuracy.
14
+
15
+ Args:
16
+ milliseconds (int): The number of milliseconds to delay.
17
+ """
18
+ def get_delta() -> float:
19
+ """
20
+ Get the time elapsed since the last frame in seconds.
21
+
22
+ For stability, the returned delta is clamped so it will not be
23
+ smaller than 1/12 seconds (equivalent to capping at 12 FPS). This prevents
24
+ unstable calculations that rely on delta when very small frame times are
25
+ measured.
26
+
27
+ Returns:
28
+ float: The time elapsed since the last frame, in seconds.
29
+ """
30
+ def get_elapsed() -> float:
31
+ """
32
+ Get the elapsed time since the program started.
33
+
34
+ Returns:
35
+ float: The total elapsed time since program start, in seconds.
36
+ """
37
+ def get_fps() -> float:
38
+ """
39
+ Get the current frames per second of the program.
40
+
41
+ Returns:
42
+ float: The current FPS based on the last frame time.
43
+ """
44
+ def get_scale() -> float:
45
+ """
46
+ Get the current global time scale factor.
47
+
48
+ Returns:
49
+ float: The current time scale factor.
50
+ """
51
+ def set_max_delta(max_delta: typing.SupportsFloat) -> None:
52
+ """
53
+ Set the maximum allowed delta time between frames.
54
+
55
+ Parameters:
56
+ max_delta (float): The maximum delta time in seconds, greater than 0.0.
57
+ This is useful to prevent large delta values during
58
+ frame drops or pauses that could destabilize physics or animations.
59
+ """
60
+ def set_scale(scale: typing.SupportsFloat) -> None:
61
+ """
62
+ Set the global time scale factor.
63
+
64
+ Args:
65
+ scale (float): The time scale factor. Values < 0.0 are clamped to 0.0.
66
+ A scale of 1.0 represents normal time, 0.5 is half speed,
67
+ and 2.0 is double speed.
68
+ """
69
+ def set_target(frame_rate: typing.SupportsInt) -> None:
70
+ """
71
+ Set the target framerate for the application.
72
+
73
+ Args:
74
+ frame_rate (int): Target framerate to enforce. Values <= 0 disable frame rate limiting.
75
+ """