q5play 4.1.2 → 4.2.2

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.
Files changed (5) hide show
  1. package/package.json +1 -1
  2. package/py.typed +0 -0
  3. package/q5play.d.ts +1382 -160
  4. package/q5play.js +847 -204
  5. package/q5play.pyi +5007 -0
package/q5play.pyi ADDED
@@ -0,0 +1,5007 @@
1
+ # Auto-generated from q5play.d.ts — do not edit by hand.
2
+ # Run: bun lang/types.js
3
+
4
+ from __future__ import annotations
5
+ from typing import Any, Callable, Type, TypeVar, Generic, overload
6
+ from collections.abc import Awaitable
7
+ from q5 import *
8
+
9
+ class Q5Play:
10
+
11
+ sprites: dict
12
+ """
13
+ Contains all the sprites in the sketch.
14
+
15
+ Users should use the `allSprites` group instead
16
+ because this object includes deleted sprites.
17
+
18
+ The keys are the sprite's unique ids.
19
+ """
20
+
21
+ groups: dict
22
+ """
23
+ Contains all the groups in the sketch.
24
+
25
+ The keys are the group's unique ids.
26
+ """
27
+
28
+ groupsCreated: float
29
+
30
+ spritesCreated: float
31
+
32
+ spritesDrawn: float
33
+
34
+ palettes: list[Any]
35
+ """
36
+ The default color palette, at index 0 of this array,
37
+ has all the letters of the English alphabet mapped to colors.
38
+ """
39
+
40
+ friendlyRounding: bool
41
+ """
42
+ Friendly rounding makes some Sprite getters return nice rounded numbers
43
+ if a decimal value is within linear slop range (+/-0.005) or
44
+ angular slop range (+/-0.000582 radians) of a whole number.
45
+
46
+ This is because Box2D physics calculations can result in
47
+ floating point drift, which beginners wouldn't expect.
48
+
49
+ Setting to false can slightly improve performance.
50
+
51
+ Default: `true`
52
+ """
53
+
54
+ os: dict
55
+ """Information about the operating system being used."""
56
+
57
+ context: str
58
+
59
+ hasMouse: bool
60
+
61
+ standardizeKeyboard: bool
62
+
63
+ renderStats: bool
64
+ """
65
+ Displays the version of q5play being used,
66
+ the number of sprites being drawn
67
+ and a realtime graphing of the current FPS.
68
+
69
+ FPS in this context refers to how many frames per second your
70
+ computer can generate, only based on the physics calculations and
71
+ other processes necessary to generate a frame, but not
72
+ including the delay between when frames are actually shown on
73
+ the screen. The higher the FPS, the better your game is
74
+ performing.
75
+
76
+ You can use this function for approximate performance testing.
77
+ But for the most accurate results, use your web browser's
78
+ performance testing tools.
79
+
80
+ Generally having less sprites and using a smaller canvas will
81
+ make your game perform better. Also drawing images is faster
82
+ than drawing shapes.
83
+
84
+ Default: `false`
85
+ """
86
+
87
+ def splashScreen(self) -> Awaitable[None]:
88
+ """
89
+ "Made with q5play" [splash screen](https://en.wikipedia.org/wiki/Splash_screen)
90
+ displayed during initial page load by default.
91
+ """
92
+ ...
93
+
94
+ def update(self) -> None:
95
+ """Runs automatically before each q5.draw function call."""
96
+ ...
97
+
98
+ def draw(self) -> None:
99
+ """Runs automatically after each q5.draw function call."""
100
+ ...
101
+
102
+ q5play: Q5Play
103
+
104
+ Box2D: Any
105
+ """
106
+ Box2D v3 ported to WASM is used by
107
+ q5play to simulate physics.
108
+
109
+ This variable enables direct access to the Box2D API for
110
+ advanced users who want to do things that aren't wrapped
111
+ by q5play.
112
+ """
113
+
114
+ class Shape:
115
+ """
116
+ Don't create Shapes directly; use `sprite.addCollider()`
117
+ or `sprite.addSensor()` instead.
118
+ """
119
+
120
+ sprite: Sprite
121
+
122
+ type: str
123
+
124
+ geom: Any
125
+
126
+ density: float
127
+
128
+ def applyWind(self, speed: float, angle: float, drag: float = ..., lift: float = ...) -> None:
129
+ ...
130
+
131
+ def scaleBy(self, scaleX: float, scaleY: float = ...) -> None:
132
+ ...
133
+
134
+ def delete(self) -> None:
135
+ ...
136
+
137
+ class Collider(Shape):
138
+ """
139
+ Colliders are added to a sprite's physics body to cause
140
+ physical collisions with other sprites.
141
+
142
+ Don't create Colliders directly; use Sprite.addCollider() instead.
143
+ """
144
+
145
+ friction: float
146
+
147
+ bounciness: float
148
+
149
+ density: float
150
+
151
+ @property
152
+ def rollingResistance(self) -> float:
153
+ ...
154
+
155
+ @rollingResistance.setter
156
+ def rollingResistance(self, val: float) -> None: ...
157
+
158
+ @property
159
+ def surfaceSpeed(self) -> float:
160
+ ...
161
+
162
+ @surfaceSpeed.setter
163
+ def surfaceSpeed(self, val: float) -> None: ...
164
+
165
+ class Sensor(Shape):
166
+ """
167
+ Sensor are added to a sprite's physics body to detect overlaps
168
+ without causing physical collisions.
169
+
170
+ Don't create Sensors directly; use Sprite.addSensor() instead.
171
+ """
172
+
173
+ _isSensor: bool
174
+
175
+ density: float
176
+
177
+ class Visual:
178
+ """
179
+ A Visual object stores an image or animation(s)
180
+ which can be displayed with respect to the camera.
181
+ """
182
+
183
+ @property
184
+ def x(self) -> float:
185
+ """Horizontal position of the visual."""
186
+ ...
187
+
188
+ @x.setter
189
+ def x(self, val: float) -> None: ...
190
+
191
+ @property
192
+ def y(self) -> float:
193
+ """Vertical position of the visual."""
194
+ ...
195
+
196
+ @y.setter
197
+ def y(self, val: float) -> None: ...
198
+
199
+ vx: float
200
+ """Horizontal velocity of the visual."""
201
+
202
+ vy: float
203
+ """Vertical velocity of the visual."""
204
+
205
+ @property
206
+ def draw(self) -> Any:
207
+ """Draws the visual on the canvas."""
208
+ ...
209
+
210
+ @draw.setter
211
+ def draw(self, val: Any) -> None: ...
212
+
213
+ @property
214
+ def img(self) -> Image:
215
+ """Current image or frame of animation being displayed."""
216
+ ...
217
+
218
+ @img.setter
219
+ def img(self, val: str | Image) -> None: ...
220
+
221
+ @property
222
+ def ani(self) -> Ani:
223
+ """Current animation."""
224
+ ...
225
+
226
+ @ani.setter
227
+ def ani(self, val: Ani) -> None: ...
228
+
229
+ @property
230
+ def anis(self) -> Anis:
231
+ """
232
+ Stores animations.
233
+ Keys are the animation label, values are Ani objects
234
+ """
235
+ ...
236
+
237
+ def addAni(self, spriteSheetURL: str, frameCount: float) -> Awaitable[None]:
238
+ """
239
+ Adds an animation to the Sprite or Visual.
240
+
241
+ Args:
242
+ spriteSheetURL: the URL of the sprite sheet image
243
+ frameCount: the number of frames in the sprite sheet
244
+
245
+ Returns:
246
+ A promise that fulfills when the animation is loaded
247
+ """
248
+ ...
249
+
250
+ @overload
251
+ def addAnis(self, atlases: dict) -> Awaitable[None]:
252
+ """
253
+ Add multiple animations to the Sprite or Visual.
254
+
255
+ Args:
256
+ atlases: an object with animation names as keys and an animation or animation atlas as values
257
+
258
+ Returns:
259
+ A promise that fulfills when the animations are loaded
260
+ """
261
+ ...
262
+
263
+ @overload
264
+ def addAnis(self, spriteSheetURL: str, atlases: dict) -> Awaitable[None]:
265
+ """
266
+ Add multiple animations to the Sprite or Visual.
267
+
268
+ Args:
269
+ spriteSheetURL: the URL of the sprite sheet image
270
+ atlases: an object with animation names as keys and an animation or animation atlas as values
271
+
272
+ Returns:
273
+ A promise that fulfills when the animations are loaded
274
+ """
275
+ ...
276
+
277
+ @overload
278
+ def addAnis(self, spriteSheetURL: str, frameSize: str, atlases: dict) -> Awaitable[None]:
279
+ """
280
+ Add multiple animations to the Sprite or Visual.
281
+
282
+ Args:
283
+ spriteSheetURL: the URL of the sprite sheet image
284
+ frameSize: the size of each frame in the sprite sheet in the format "WIDTHxHEIGHT" (example: "32x32")
285
+ atlases: an object with animation names as keys and an animation or animation atlas as values
286
+
287
+ Returns:
288
+ A promise that fulfills when the animations are loaded
289
+ """
290
+ ...
291
+
292
+ def addAnis(self, spriteSheetURL: str, frameSize: str, atlases: dict) -> Awaitable[None]:
293
+ ...
294
+
295
+ def changeAni(self, name: str) -> None:
296
+ """
297
+ Changes the sprite's animation. Use `addAni` to define the
298
+ animation(s) first.
299
+
300
+ Args:
301
+ name: the name of the animation to switch to
302
+ """
303
+ ...
304
+
305
+ def playAni(self, name: str) -> Awaitable[None]:
306
+ """
307
+ Plays an animation.
308
+
309
+ You can put special modifier characters before the name:
310
+ - "!" plays it backwards
311
+ - ">" or "<" horizontally flips it
312
+ - "^" vertically flips it
313
+
314
+ Args:
315
+ name: the name of the animation to play
316
+
317
+ Returns:
318
+ A promise that fulfills when the animation completes
319
+ """
320
+ ...
321
+
322
+ def playAnis(self, *sequence: str) -> Awaitable[None]:
323
+ """
324
+ Plays a sequence of animations.
325
+
326
+ You can put special modifier characters before each ani name:
327
+ - "!" plays it backwards
328
+ - ">" or "<" horizontally flips it
329
+ - "^" vertically flips it
330
+
331
+ You can put sequence modifiers at the end of the sequence:
332
+ - "**" loops it indefinitely
333
+ - ";;" stops it on the last ani's last frame
334
+
335
+ Args:
336
+ sequence: the names of animations
337
+
338
+ Returns:
339
+ A promise that fulfills when the sequence completes
340
+ """
341
+ ...
342
+
343
+ DYNAMIC: str
344
+
345
+ DYN: str
346
+
347
+ STATIC: str
348
+
349
+ STA: str
350
+
351
+ KINEMATIC: str
352
+
353
+ KIN: str
354
+
355
+ class Sprite(Visual):
356
+ """A Sprite has a Box2D physics body with a collider (by default), which can interact with other sprites in the physics simulation."""
357
+
358
+ @overload
359
+ @classmethod
360
+ def new(cls, x: float = ..., y: float = ..., w: float = ..., h: float = ..., physicsType: str = ...) -> 'Sprite': ...
361
+
362
+ @overload
363
+ @classmethod
364
+ def new(cls, x: float = ..., y: float = ..., w: float = ..., h: float = ..., roundedRadius: float = ..., physicsType: str = ...) -> 'Sprite': ...
365
+
366
+ @overload
367
+ @classmethod
368
+ def new(cls, x: float, y: float, d: float, physicsType: str = ...) -> 'Sprite': ...
369
+
370
+ @overload
371
+ @classmethod
372
+ def new(cls, points: list[tuple[float, float]], roundedRadius: float, physicsType: str = ...) -> 'Sprite': ...
373
+
374
+ @overload
375
+ @classmethod
376
+ def new(cls, vertices: list[tuple[float, float]], physicsType: str = ...) -> 'Sprite': ...
377
+
378
+ @overload
379
+ @classmethod
380
+ def new(cls, x: float, y: float, vertices: list[tuple[float, float]], physicsType: str = ...) -> 'Sprite': ...
381
+
382
+ @overload
383
+ @classmethod
384
+ def new(cls, x: float, y: float, distAngles: list[float], physicsType: str = ...) -> 'Sprite': ...
385
+
386
+ @overload
387
+ @classmethod
388
+ def new(cls, x: float, y: float, distAngles: list[float], roundedRadius: float, physicsType: str = ...) -> 'Sprite': ...
389
+
390
+ @overload
391
+ @classmethod
392
+ def new(cls, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> 'Sprite': ...
393
+
394
+ @overload
395
+ @classmethod
396
+ def new(cls, ani: str | Ani | Image, x: float = ..., y: float = ..., w: float = ..., h: float = ..., physicsType: str = ...) -> 'Sprite': ...
397
+
398
+ @overload
399
+ @classmethod
400
+ def new(cls, ani: str | Ani | Image, x: float = ..., y: float = ..., w: float = ..., h: float = ..., roundedRadius: float = ..., physicsType: str = ...) -> 'Sprite': ...
401
+
402
+ @overload
403
+ @classmethod
404
+ def new(cls, ani: str | Ani | Image, x: float, y: float, d: float, physicsType: str = ...) -> 'Sprite': ...
405
+
406
+ @overload
407
+ @classmethod
408
+ def new(cls, ani: str | Ani | Image, points: list[tuple[float, float]], roundedRadius: float, physicsType: str = ...) -> 'Sprite': ...
409
+
410
+ @overload
411
+ @classmethod
412
+ def new(cls, ani: str | Ani | Image, vertices: list[tuple[float, float]], physicsType: str = ...) -> 'Sprite': ...
413
+
414
+ @overload
415
+ @classmethod
416
+ def new(cls, ani: str | Ani | Image, x: float, y: float, vertices: list[tuple[float, float]], physicsType: str = ...) -> 'Sprite': ...
417
+
418
+ @overload
419
+ @classmethod
420
+ def new(cls, ani: str | Ani | Image, x: float, y: float, distAngles: list[float], physicsType: str = ...) -> 'Sprite': ...
421
+
422
+ @overload
423
+ @classmethod
424
+ def new(cls, ani: str | Ani | Image, x: float, y: float, distAngles: list[float], roundedRadius: float, physicsType: str = ...) -> 'Sprite': ...
425
+
426
+ @overload
427
+ @classmethod
428
+ def new(cls, ani: str | Ani | Image, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> 'Sprite': ...
429
+
430
+ @classmethod
431
+ def new(cls, ani: str | Ani | Image, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> 'Sprite':
432
+ ...
433
+
434
+ @overload
435
+ def __init__(self, x: float = ..., y: float = ..., w: float = ..., h: float = ..., physicsType: str = ...) -> None: ...
436
+
437
+ @overload
438
+ def __init__(self, x: float = ..., y: float = ..., w: float = ..., h: float = ..., roundedRadius: float = ..., physicsType: str = ...) -> None: ...
439
+
440
+ @overload
441
+ def __init__(self, x: float, y: float, d: float, physicsType: str = ...) -> None: ...
442
+
443
+ @overload
444
+ def __init__(self, points: list[tuple[float, float]], roundedRadius: float, physicsType: str = ...) -> None: ...
445
+
446
+ @overload
447
+ def __init__(self, vertices: list[tuple[float, float]], physicsType: str = ...) -> None: ...
448
+
449
+ @overload
450
+ def __init__(self, x: float, y: float, vertices: list[tuple[float, float]], physicsType: str = ...) -> None: ...
451
+
452
+ @overload
453
+ def __init__(self, x: float, y: float, distAngles: list[float], physicsType: str = ...) -> None: ...
454
+
455
+ @overload
456
+ def __init__(self, x: float, y: float, distAngles: list[float], roundedRadius: float, physicsType: str = ...) -> None: ...
457
+
458
+ @overload
459
+ def __init__(self, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> None: ...
460
+
461
+ @overload
462
+ def __init__(self, ani: str | Ani | Image, x: float = ..., y: float = ..., w: float = ..., h: float = ..., physicsType: str = ...) -> None: ...
463
+
464
+ @overload
465
+ def __init__(self, ani: str | Ani | Image, x: float = ..., y: float = ..., w: float = ..., h: float = ..., roundedRadius: float = ..., physicsType: str = ...) -> None: ...
466
+
467
+ @overload
468
+ def __init__(self, ani: str | Ani | Image, x: float, y: float, d: float, physicsType: str = ...) -> None: ...
469
+
470
+ @overload
471
+ def __init__(self, ani: str | Ani | Image, points: list[tuple[float, float]], roundedRadius: float, physicsType: str = ...) -> None: ...
472
+
473
+ @overload
474
+ def __init__(self, ani: str | Ani | Image, vertices: list[tuple[float, float]], physicsType: str = ...) -> None: ...
475
+
476
+ @overload
477
+ def __init__(self, ani: str | Ani | Image, x: float, y: float, vertices: list[tuple[float, float]], physicsType: str = ...) -> None: ...
478
+
479
+ @overload
480
+ def __init__(self, ani: str | Ani | Image, x: float, y: float, distAngles: list[float], physicsType: str = ...) -> None: ...
481
+
482
+ @overload
483
+ def __init__(self, ani: str | Ani | Image, x: float, y: float, distAngles: list[float], roundedRadius: float, physicsType: str = ...) -> None: ...
484
+
485
+ @overload
486
+ def __init__(self, ani: str | Ani | Image, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> None: ...
487
+
488
+ def __init__(self, ani: str | Ani | Image, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> None: ...
489
+
490
+ @overload
491
+ @classmethod
492
+ def withSensor(cls, x: float = ..., y: float = ..., w: float = ..., h: float = ..., physicsType: str = ...) -> Sprite: ...
493
+
494
+ @overload
495
+ @classmethod
496
+ def withSensor(cls, x: float = ..., y: float = ..., w: float = ..., h: float = ..., roundedRadius: float = ..., physicsType: str = ...) -> Sprite: ...
497
+
498
+ @overload
499
+ @classmethod
500
+ def withSensor(cls, x: float, y: float, d: float, physicsType: str = ...) -> Sprite: ...
501
+
502
+ @overload
503
+ @classmethod
504
+ def withSensor(cls, points: list[tuple[float, float]], roundedRadius: float, physicsType: str = ...) -> Sprite: ...
505
+
506
+ @overload
507
+ @classmethod
508
+ def withSensor(cls, vertices: list[tuple[float, float]], physicsType: str = ...) -> Sprite: ...
509
+
510
+ @overload
511
+ @classmethod
512
+ def withSensor(cls, x: float, y: float, vertices: list[tuple[float, float]], physicsType: str = ...) -> Sprite: ...
513
+
514
+ @overload
515
+ @classmethod
516
+ def withSensor(cls, x: float, y: float, distAngles: list[float], physicsType: str = ...) -> Sprite: ...
517
+
518
+ @overload
519
+ @classmethod
520
+ def withSensor(cls, x: float, y: float, distAngles: list[float], roundedRadius: float, physicsType: str = ...) -> Sprite: ...
521
+
522
+ @overload
523
+ @classmethod
524
+ def withSensor(cls, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> Sprite: ...
525
+
526
+ @overload
527
+ @classmethod
528
+ def withSensor(cls, ani: str | Ani | Image, x: float = ..., y: float = ..., w: float = ..., h: float = ..., physicsType: str = ...) -> Sprite: ...
529
+
530
+ @overload
531
+ @classmethod
532
+ def withSensor(cls, ani: str | Ani | Image, x: float = ..., y: float = ..., w: float = ..., h: float = ..., roundedRadius: float = ..., physicsType: str = ...) -> Sprite: ...
533
+
534
+ @overload
535
+ @classmethod
536
+ def withSensor(cls, ani: str | Ani | Image, x: float, y: float, d: float, physicsType: str = ...) -> Sprite: ...
537
+
538
+ @overload
539
+ @classmethod
540
+ def withSensor(cls, ani: str | Ani | Image, points: list[tuple[float, float]], roundedRadius: float, physicsType: str = ...) -> Sprite: ...
541
+
542
+ @overload
543
+ @classmethod
544
+ def withSensor(cls, ani: str | Ani | Image, vertices: list[tuple[float, float]], physicsType: str = ...) -> Sprite: ...
545
+
546
+ @overload
547
+ @classmethod
548
+ def withSensor(cls, ani: str | Ani | Image, x: float, y: float, vertices: list[tuple[float, float]], physicsType: str = ...) -> Sprite: ...
549
+
550
+ @overload
551
+ @classmethod
552
+ def withSensor(cls, ani: str | Ani | Image, x: float, y: float, distAngles: list[float], physicsType: str = ...) -> Sprite: ...
553
+
554
+ @overload
555
+ @classmethod
556
+ def withSensor(cls, ani: str | Ani | Image, x: float, y: float, distAngles: list[float], roundedRadius: float, physicsType: str = ...) -> Sprite: ...
557
+
558
+ @overload
559
+ @classmethod
560
+ def withSensor(cls, ani: str | Ani | Image, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> Sprite: ...
561
+
562
+ @classmethod
563
+ def withSensor(cls, ani: str | Ani | Image, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> Sprite:
564
+ ...
565
+
566
+ @property
567
+ def physics(self) -> str:
568
+ """
569
+ The physics type of the sprite, which determines how it interacts with
570
+ other sprites in the physics simulation.
571
+
572
+ It can be set to DYNAMIC/DYN, STATIC/STA, or KINEMATIC/KIN.
573
+
574
+ Default: `"dynamic"`
575
+ """
576
+ ...
577
+
578
+ @physics.setter
579
+ def physics(self, val: str) -> None: ...
580
+
581
+ @property
582
+ def physicsType(self) -> str:
583
+ """
584
+ The physics type of the sprite, which determines how it interacts with
585
+ other sprites in the physics simulation.
586
+
587
+ It can be set to DYNAMIC/DYN, STATIC/STA, or KINEMATIC/KIN.
588
+
589
+ Default: `"dynamic"`
590
+ """
591
+ ...
592
+
593
+ @physicsType.setter
594
+ def physicsType(self, val: str) -> None: ...
595
+
596
+ @property
597
+ def physicsEnabled(self) -> bool:
598
+ """
599
+ If true, the sprite's physics body is included in the physics simulation.
600
+
601
+ Default: `true`
602
+ """
603
+ ...
604
+
605
+ @physicsEnabled.setter
606
+ def physicsEnabled(self, val: bool) -> None: ...
607
+
608
+ idNum: float
609
+ """
610
+ Each sprite has a unique id number. Don't change it!
611
+ They are useful for debugging.
612
+ """
613
+
614
+ bdID: Any
615
+ """The Box2D body id for the sprite's physics body. Don't change it!"""
616
+
617
+ groups: list[Group]
618
+ """
619
+ Groups the sprite belongs to.
620
+
621
+ Default: `[allSprites]`
622
+ """
623
+
624
+ animations: Anis
625
+ """Keys are the animation label, values are Ani objects."""
626
+
627
+ colliders: list[Collider]
628
+ """Array of colliders that are part of the sprite's physics body."""
629
+
630
+ sensors: list[Sensor]
631
+ """
632
+ Array of sensors that are part of the sprite's physics body.
633
+ Sensors are used to detect overlaps without causing physical collisions.
634
+ """
635
+
636
+ joints: list[Joint]
637
+ """
638
+ Joints that the sprite is attached to.
639
+
640
+ Default: `[]`
641
+ """
642
+
643
+ watch: bool
644
+ """
645
+ If set to true, q5play will record all changes to the sprite's
646
+ properties in its `mod` array. Intended to be used to enable
647
+ online multiplayer.
648
+
649
+ Default: `undefined`
650
+ """
651
+
652
+ mod: dict
653
+ """
654
+ Modification tracking object.
655
+
656
+ It has sprite property number codes as keys,
657
+ these correspond to the index of the property in the
658
+ Sprite.props array, and boolean values, that
659
+ indicate which properties were changed since the last frame.
660
+
661
+ Useful for limiting the amount of sprite data sent in netcode
662
+ to only the sprite properties that have been modified.
663
+ """
664
+
665
+ @property
666
+ def x(self) -> float:
667
+ """The horizontal position of the sprite."""
668
+ ...
669
+
670
+ @x.setter
671
+ def x(self, val: float) -> None: ...
672
+
673
+ @property
674
+ def y(self) -> float:
675
+ """The vertical position of the sprite."""
676
+ ...
677
+
678
+ @y.setter
679
+ def y(self, val: float) -> None: ...
680
+
681
+ @property
682
+ def w(self) -> float:
683
+ """The width of the sprite."""
684
+ ...
685
+
686
+ @w.setter
687
+ def w(self, val: float) -> None: ...
688
+
689
+ @property
690
+ def h(self) -> float:
691
+ """The height of the sprite."""
692
+ ...
693
+
694
+ @h.setter
695
+ def h(self, val: float) -> None: ...
696
+
697
+ prevX: float
698
+ """The sprite's x position on the previous frame."""
699
+
700
+ prevY: float
701
+ """The sprite's y position on the previous frame."""
702
+
703
+ prevRotation: float
704
+ """The sprite's rotation on the previous frame."""
705
+
706
+ text: str
707
+ """
708
+ Text displayed at the center of the sprite.
709
+
710
+ Default: `undefined`
711
+ """
712
+
713
+ def addCollider(self, offsetX: float, offsetY: float, w: float = ..., h: float = ..., roundedRadius: float = ...) -> None:
714
+ """
715
+ Adds a collider to the sprite's physics body.
716
+
717
+ It accepts parameters in a similar format to the Sprite
718
+ constructor except the first two parameters are x and y offsets,
719
+ the distance new collider should be from the center of the sprite.
720
+
721
+ This function also recalculates the sprite's mass based on the
722
+ size of the new collider added to it. However, it does not move
723
+ the sprite's center of mass, which makes adding multiple colliders
724
+ to a sprite easier.
725
+
726
+ Args:
727
+ offsetX: distance from the center of the sprite
728
+ offsetY: distance from the center of the sprite
729
+ w: width of the collider
730
+ h: height of the collider
731
+ roundedRadius: corner radius for a rounded box collider
732
+ """
733
+ ...
734
+
735
+ def addSensor(self, offsetX: float, offsetY: float, w: float = ..., h: float = ..., roundedRadius: float = ...) -> None:
736
+ """
737
+ Adds an overlap sensor to the sprite's physics body.
738
+
739
+ Sensors can't displace or be displaced by colliders.
740
+ Sensors don't have any mass or other physical properties.
741
+ Sensors simply detect overlaps.
742
+
743
+ This function accepts parameters in a similar format to the Sprite
744
+ constructor except the first two parameters are x and y offsets,
745
+ the relative distance the new sensor should be from the center of
746
+ the sprite.
747
+
748
+ Args:
749
+ offsetX: distance from the center of the sprite
750
+ offsetY: distance from the center of the sprite
751
+ w: width of the collider
752
+ h: height of the collider
753
+ roundedRadius: corner radius for a rounded box sensor
754
+ """
755
+ ...
756
+
757
+ @property
758
+ def mass(self) -> float:
759
+ """The mass of the sprite's physics body."""
760
+ ...
761
+
762
+ @mass.setter
763
+ def mass(self, val: float) -> None: ...
764
+
765
+ @property
766
+ def centerOfMass(self) -> dict:
767
+ """
768
+ The center of mass of the sprite's physics body, the point at which
769
+ the physics body is balanced and rotates around. By default it's the
770
+ same as the sprite's position, but it can be changed with this setter.
771
+ """
772
+ ...
773
+
774
+ @centerOfMass.setter
775
+ def centerOfMass(self, val: dict) -> None: ...
776
+
777
+ @property
778
+ def fixedCenterOfMass(self) -> bool:
779
+ """
780
+ If true, the center of mass of the sprite's physics body is fixed to
781
+ the sprite's [x, y] position.
782
+
783
+ It prevents the center of mass from being recalculated (moved) when adding or
784
+ removing colliders or sensors. Set it to false to allow dynamic center of mass
785
+ recalculation.
786
+
787
+ Default: `true`
788
+ """
789
+ ...
790
+
791
+ @fixedCenterOfMass.setter
792
+ def fixedCenterOfMass(self, val: bool) -> None: ...
793
+
794
+ def resetMass(self) -> None:
795
+ """
796
+ Recalculates the sprite's mass based on its current
797
+ density and size.
798
+ """
799
+ ...
800
+
801
+ @property
802
+ def rotation(self) -> float:
803
+ """
804
+ The angle of the sprite's rotation, not the direction it's moving.
805
+
806
+ If angleMode is set to "degrees", the value will be returned in
807
+ a range of -180 to 180.
808
+
809
+ Default: `0`
810
+ """
811
+ ...
812
+
813
+ @rotation.setter
814
+ def rotation(self, val: float) -> None: ...
815
+
816
+ def deleteColliders(self) -> None:
817
+ """Removes colliders from the sprite's physics body."""
818
+ ...
819
+
820
+ def deleteSensors(self) -> None:
821
+ """Removes overlap sensors from the sprite's physics body."""
822
+ ...
823
+
824
+ @property
825
+ def autoUpdate(self) -> bool:
826
+ """
827
+ If true, a sprite is updated by q5play before each physics update.
828
+
829
+ Default: `true`
830
+ """
831
+ ...
832
+
833
+ @autoUpdate.setter
834
+ def autoUpdate(self, val: bool) -> None: ...
835
+
836
+ @property
837
+ def autoDraw(self) -> bool:
838
+ """
839
+ If true, a sprite is drawn by q5play after each physics update.
840
+
841
+ Default: `true`
842
+ """
843
+ ...
844
+
845
+ @autoDraw.setter
846
+ def autoDraw(self, val: bool) -> None: ...
847
+
848
+ @property
849
+ def allowSleeping(self) -> bool:
850
+ """
851
+ Controls the ability for a sprite to "sleep".
852
+
853
+ "Sleeping" sprites are not included in the physics simulation, a
854
+ sprite starts "sleeping" when it stops moving and doesn't collide
855
+ with anything that it wasn't already colliding with.
856
+
857
+ Default: `true`
858
+ """
859
+ ...
860
+
861
+ @allowSleeping.setter
862
+ def allowSleeping(self, val: bool) -> None: ...
863
+
864
+ @property
865
+ def bounciness(self) -> float:
866
+ """
867
+ The bounciness of the sprite's physics body.
868
+
869
+ Default: `0.2`
870
+ """
871
+ ...
872
+
873
+ @bounciness.setter
874
+ def bounciness(self, val: float) -> None: ...
875
+
876
+ @property
877
+ def rotationSpeed(self) -> float:
878
+ """
879
+ The speed of the sprite's rotation in angles per frame.
880
+
881
+ Default: `0`
882
+ """
883
+ ...
884
+
885
+ @rotationSpeed.setter
886
+ def rotationSpeed(self, val: float) -> None: ...
887
+
888
+ @property
889
+ def color(self) -> Color:
890
+ """
891
+ The sprite's current fill color.
892
+
893
+ By default sprites get a random color.
894
+ """
895
+ ...
896
+
897
+ @color.setter
898
+ def color(self, val: Color) -> None: ...
899
+
900
+ @property
901
+ def colour(self) -> Color:
902
+ """
903
+ The sprite's current fill colour.
904
+
905
+ By default sprites get a random color.
906
+ """
907
+ ...
908
+
909
+ @colour.setter
910
+ def colour(self, val: Color) -> None: ...
911
+
912
+ @property
913
+ def fill(self) -> Color:
914
+ """
915
+ The sprite's current fill color.
916
+
917
+ By default sprites get a random color.
918
+ """
919
+ ...
920
+
921
+ @fill.setter
922
+ def fill(self, val: Color) -> None: ...
923
+
924
+ @property
925
+ def stroke(self) -> Color:
926
+ """The sprite's stroke color."""
927
+ ...
928
+
929
+ @stroke.setter
930
+ def stroke(self, val: Color) -> None: ...
931
+
932
+ @property
933
+ def strokeWeight(self) -> float:
934
+ """The sprite's stroke weight, the thickness of its outline."""
935
+ ...
936
+
937
+ @strokeWeight.setter
938
+ def strokeWeight(self, val: float) -> None: ...
939
+
940
+ @property
941
+ def textFill(self) -> Color:
942
+ """
943
+ The sprite's text fill color. Black by default.
944
+
945
+ Default: `black (#000000)`
946
+ """
947
+ ...
948
+
949
+ @textFill.setter
950
+ def textFill(self, val: Color) -> None: ...
951
+
952
+ @property
953
+ def textSize(self) -> float:
954
+ """The sprite's text size, the sketch's current textSize by default."""
955
+ ...
956
+
957
+ @textSize.setter
958
+ def textSize(self, val: float) -> None: ...
959
+
960
+ @property
961
+ def textStroke(self) -> Color:
962
+ """
963
+ The sprite's text stroke color.
964
+ No stroke by default, does not inherit from the sketch's stroke color.
965
+
966
+ Default: `undefined`
967
+ """
968
+ ...
969
+
970
+ @textStroke.setter
971
+ def textStroke(self, val: Color) -> None: ...
972
+
973
+ @property
974
+ def textStrokeWeight(self) -> float:
975
+ """
976
+ The sprite's text stroke weight, the thickness of its outline.
977
+ No stroke by default, does not inherit from the sketch's stroke weight.
978
+
979
+ Default: `undefined`
980
+ """
981
+ ...
982
+
983
+ @textStrokeWeight.setter
984
+ def textStrokeWeight(self, val: float) -> None: ...
985
+
986
+ @property
987
+ def tile(self) -> str:
988
+ """The tile character that represents the sprite in a tile map."""
989
+ ...
990
+
991
+ @tile.setter
992
+ def tile(self, val: str) -> None: ...
993
+
994
+ @property
995
+ def bearing(self) -> float:
996
+ """
997
+ A bearing indicates the direction that needs to be followed to
998
+ reach a destination.
999
+
1000
+ Setting a sprite's bearing doesn't do anything by itself.
1001
+ You can apply a force to the sprite at its bearing angle
1002
+ using the `applyForce` function.
1003
+ """
1004
+ ...
1005
+
1006
+ @bearing.setter
1007
+ def bearing(self, val: float) -> None: ...
1008
+
1009
+ @property
1010
+ def debug(self) -> bool:
1011
+ """
1012
+ If true, outlines of the sprite's colliders and sensors will be drawn.
1013
+
1014
+ Default: `false`
1015
+ """
1016
+ ...
1017
+
1018
+ @debug.setter
1019
+ def debug(self, val: bool) -> None: ...
1020
+
1021
+ @property
1022
+ def density(self) -> float:
1023
+ """
1024
+ The density of the sprite's physics body.
1025
+
1026
+ Default: `1`
1027
+ """
1028
+ ...
1029
+
1030
+ @density.setter
1031
+ def density(self, val: float) -> None: ...
1032
+
1033
+ @property
1034
+ def direction(self) -> float:
1035
+ """
1036
+ The angle of the sprite's movement.
1037
+
1038
+ Can be set with directional strings like "up", "down", "left", "right",
1039
+ "upRight", "upLeft", "downRight", and "downLeft". The setter's input parser ignores
1040
+ capitalization, spaces, underscores, dashes, and cardinal direction word order.
1041
+
1042
+ Default: `0 ("right")`
1043
+ """
1044
+ ...
1045
+
1046
+ @direction.setter
1047
+ def direction(self, val: float | str) -> None: ...
1048
+
1049
+ @property
1050
+ def drag(self) -> float:
1051
+ """
1052
+ The amount of resistance a sprite has to being moved.
1053
+
1054
+ Default: `0`
1055
+ """
1056
+ ...
1057
+
1058
+ @drag.setter
1059
+ def drag(self, val: float) -> None: ...
1060
+
1061
+ @property
1062
+ def draw(self) -> Callable[..., Any]:
1063
+ """
1064
+ Displays the sprite.
1065
+
1066
+ This function is called automatically at the end of each
1067
+ sketch `draw` function call but it can also be run
1068
+ by users to customize the order sprites are drawn in relation
1069
+ to other stuff drawn on the canvas. Also see the sprite.layer
1070
+ property.
1071
+
1072
+ A sprite's draw function can be overridden with a
1073
+ custom draw function, inside this function (0, 0) is the center of
1074
+ the sprite.
1075
+ """
1076
+ ...
1077
+
1078
+ @draw.setter
1079
+ def draw(self, val: Callable[..., Any]) -> None: ...
1080
+
1081
+ @property
1082
+ def friction(self) -> float:
1083
+ """
1084
+ The amount the sprite's colliders resist moving
1085
+ when rubbing against other colliders.
1086
+
1087
+ Default: `0.5`
1088
+ """
1089
+ ...
1090
+
1091
+ @friction.setter
1092
+ def friction(self, val: float) -> None: ...
1093
+
1094
+ @property
1095
+ def heading(self) -> str:
1096
+ """
1097
+ The sprite's heading. This is a string that can be set to
1098
+ "up", "down", "left", "right", "upRight", "upLeft", "downRight"
1099
+
1100
+ The setter's input parser ignores capitalization, spaces,
1101
+ underscores, dashes, and cardinal direction word order.
1102
+
1103
+ Default: `undefined`
1104
+ """
1105
+ ...
1106
+
1107
+ @heading.setter
1108
+ def heading(self, val: str) -> None: ...
1109
+
1110
+ @property
1111
+ def isSuperFast(self) -> bool:
1112
+ """
1113
+ Set this to true if the sprite goes really fast to prevent
1114
+ inaccurate physics simulation.
1115
+
1116
+ Default: `false`
1117
+ """
1118
+ ...
1119
+
1120
+ @isSuperFast.setter
1121
+ def isSuperFast(self, val: bool) -> None: ...
1122
+
1123
+ @property
1124
+ def layer(self) -> float:
1125
+ """
1126
+ Sprites with the highest layer value get drawn first.
1127
+
1128
+ By default sprites are drawn in the order they were created in.
1129
+ """
1130
+ ...
1131
+
1132
+ @layer.setter
1133
+ def layer(self, val: float) -> None: ...
1134
+
1135
+ @property
1136
+ def life(self) -> float:
1137
+ """
1138
+ When the physics simulation is progressed in `world.physicsUpdate`,
1139
+ each sprite's life is decreased by `world.timeScale`.
1140
+
1141
+ If life becomes less than or equal to 0, the sprite will
1142
+ be removed.
1143
+
1144
+ Default: `Infinity`
1145
+ """
1146
+ ...
1147
+
1148
+ @life.setter
1149
+ def life(self, val: float) -> None: ...
1150
+
1151
+ @property
1152
+ def opacity(self) -> float:
1153
+ """
1154
+ The sprite's opacity. 0 is transparent, 1 is opaque.
1155
+
1156
+ Default: `1`
1157
+ """
1158
+ ...
1159
+
1160
+ @opacity.setter
1161
+ def opacity(self, val: float) -> None: ...
1162
+
1163
+ @property
1164
+ def previousX(self) -> float:
1165
+ """
1166
+ The sprite's x position on the previous frame.
1167
+ Alias for sprite.prevX.
1168
+ """
1169
+ ...
1170
+
1171
+ @property
1172
+ def previousY(self) -> float:
1173
+ """
1174
+ The sprite's y position on the previous frame.
1175
+ Alias for sprite.prevY.
1176
+ """
1177
+ ...
1178
+
1179
+ @property
1180
+ def previousRotation(self) -> float:
1181
+ """
1182
+ The sprite's rotation on the previous frame.
1183
+ Alias for sprite.prevRotation.
1184
+ """
1185
+ ...
1186
+
1187
+ @property
1188
+ def pixelPerfect(self) -> bool:
1189
+ """
1190
+ If true, q5play will draw sprites at integer pixel precision.
1191
+
1192
+ This is useful for making retro games.
1193
+
1194
+ By default q5play draws sprites with subpixel rendering.
1195
+
1196
+ Default: `false`
1197
+ """
1198
+ ...
1199
+
1200
+ @pixelPerfect.setter
1201
+ def pixelPerfect(self, val: bool) -> None: ...
1202
+
1203
+ @property
1204
+ def deleted(self) -> bool:
1205
+ """
1206
+ If the sprite has been deleted from the world.
1207
+
1208
+ Default: `false`
1209
+ """
1210
+ ...
1211
+
1212
+ @deleted.setter
1213
+ def deleted(self, val: bool) -> None: ...
1214
+
1215
+ @property
1216
+ def rollingResistance(self) -> float:
1217
+ """
1218
+ Simulates friction that slows down a sprite rolling on another sprite,
1219
+ like a soccer ball rolling to a stop on high grass.
1220
+
1221
+ Default: `0`
1222
+ """
1223
+ ...
1224
+
1225
+ @rollingResistance.setter
1226
+ def rollingResistance(self, val: float) -> None: ...
1227
+
1228
+ @property
1229
+ def rotationDrag(self) -> float:
1230
+ """
1231
+ The amount the sprite resists rotating.
1232
+
1233
+ Default: `0`
1234
+ """
1235
+ ...
1236
+
1237
+ @rotationDrag.setter
1238
+ def rotationDrag(self, val: float) -> None: ...
1239
+
1240
+ @property
1241
+ def rotationLock(self) -> bool:
1242
+ """
1243
+ If true, the sprite can not rotate.
1244
+
1245
+ Default: `false`
1246
+ """
1247
+ ...
1248
+
1249
+ @rotationLock.setter
1250
+ def rotationLock(self, val: bool) -> None: ...
1251
+
1252
+ @property
1253
+ def scale(self) -> float | dict:
1254
+ """
1255
+ Horizontal and vertical scale of the sprite.
1256
+
1257
+ Components can be negative to flip/mirror the sprite on an axis.
1258
+
1259
+ The `valueOf` function for `sprite.scale` returns the scale as a
1260
+ number. This enables users to do things like `sprite.scale *= 2`
1261
+ to double the sprite's scale.
1262
+
1263
+ Default: `{x: 1, y: 1}`
1264
+ """
1265
+ ...
1266
+
1267
+ @scale.setter
1268
+ def scale(self, val: float | list | dict) -> None: ...
1269
+
1270
+ def scaleBy(self, x: float, y: float = ...) -> None:
1271
+ """
1272
+ Scales the the sprite.
1273
+
1274
+ Components can be negative to flip/mirror the sprite on an axis.
1275
+
1276
+ Args:
1277
+ x: horizontal scale factor or uniform scale factor for both axes
1278
+ y: vertical scale factor
1279
+ """
1280
+ ...
1281
+
1282
+ @property
1283
+ def sleeping(self) -> bool:
1284
+ """
1285
+ Wake a sprite up or put it to sleep.
1286
+
1287
+ "Sleeping" sprites are not included in the physics simulation, a
1288
+ sprite starts "sleeping" when it stops moving and doesn't collide
1289
+ with anything that it wasn't already colliding with.
1290
+
1291
+ Default: `true`
1292
+ """
1293
+ ...
1294
+
1295
+ @sleeping.setter
1296
+ def sleeping(self, val: bool) -> None: ...
1297
+
1298
+ @property
1299
+ def sleepThreshold(self) -> float:
1300
+ """
1301
+ The minimum speed (in m/s) at which the sprite must be moving
1302
+ before it is considered awake.
1303
+ """
1304
+ ...
1305
+
1306
+ @sleepThreshold.setter
1307
+ def sleepThreshold(self, val: float) -> None: ...
1308
+
1309
+ @property
1310
+ def speed(self) -> float:
1311
+ """
1312
+ The sprite's speed.
1313
+
1314
+ Setting speed to a negative value will make the sprite move
1315
+ 180 degrees opposite of its current direction angle.
1316
+
1317
+ Default: `0`
1318
+ """
1319
+ ...
1320
+
1321
+ @speed.setter
1322
+ def speed(self, val: float) -> None: ...
1323
+
1324
+ def setSpeedAndDirection(self, speed: float, direction: float) -> None:
1325
+ """Efficiently sets the sprite's speed and direction at the same time."""
1326
+ ...
1327
+
1328
+ @property
1329
+ def surfaceSpeed(self) -> float:
1330
+ """
1331
+ The sprite's speed along the surface of its collider(s),
1332
+ like a conveyor belt.
1333
+ Requires friction to be greater than 1 to have an effect.
1334
+
1335
+ Default: `0`
1336
+ """
1337
+ ...
1338
+
1339
+ @surfaceSpeed.setter
1340
+ def surfaceSpeed(self, val: float) -> None: ...
1341
+
1342
+ @property
1343
+ def tint(self) -> Color:
1344
+ """
1345
+ Tint color applied to the sprite when drawn.
1346
+
1347
+ Note that this is not good for performance, you should probably
1348
+ pre-render the effect if you want to use it a lot.
1349
+
1350
+ Default: `undefined`
1351
+ """
1352
+ ...
1353
+
1354
+ @tint.setter
1355
+ def tint(self, val: Color) -> None: ...
1356
+
1357
+ @property
1358
+ def visible(self) -> bool:
1359
+ """
1360
+ If true the sprite is shown, if set to false the sprite is hidden.
1361
+
1362
+ Becomes null when the sprite is off screen but will be drawn and
1363
+ set to true again if it goes back on screen.
1364
+
1365
+ Default: `true`
1366
+ """
1367
+ ...
1368
+
1369
+ @visible.setter
1370
+ def visible(self, val: bool) -> None: ...
1371
+
1372
+ @property
1373
+ def pos(self) -> dict:
1374
+ """
1375
+ Gets the sprite's position as a readonly object {x, y} which
1376
+ won't be updated if the sprite moves. Useful for saving
1377
+ the sprite's position at a specific moment in time.
1378
+ """
1379
+ ...
1380
+
1381
+ @pos.setter
1382
+ def pos(self, val: list[float] | dict) -> None: ...
1383
+
1384
+ @property
1385
+ def position(self) -> Vector:
1386
+ """The sprite's position vector."""
1387
+ ...
1388
+
1389
+ @position.setter
1390
+ def position(self, val: list[float] | dict) -> None: ...
1391
+
1392
+ @property
1393
+ def canvasPos(self) -> Any:
1394
+ """The sprite's absolute position on the canvas."""
1395
+ ...
1396
+
1397
+ @property
1398
+ def hw(self) -> float:
1399
+ """Half the width of the sprite."""
1400
+ ...
1401
+
1402
+ @hw.setter
1403
+ def hw(self, val: float) -> None: ...
1404
+
1405
+ @property
1406
+ def width(self) -> float:
1407
+ """The width of the sprite."""
1408
+ ...
1409
+
1410
+ @width.setter
1411
+ def width(self, val: float) -> None: ...
1412
+
1413
+ @property
1414
+ def halfWidth(self) -> float:
1415
+ """Half the width of the sprite."""
1416
+ ...
1417
+
1418
+ @halfWidth.setter
1419
+ def halfWidth(self, val: float) -> None: ...
1420
+
1421
+ @property
1422
+ def hh(self) -> float:
1423
+ """Half the height of the sprite."""
1424
+ ...
1425
+
1426
+ @hh.setter
1427
+ def hh(self, val: float) -> None: ...
1428
+
1429
+ @property
1430
+ def height(self) -> float:
1431
+ """The height of the sprite."""
1432
+ ...
1433
+
1434
+ @height.setter
1435
+ def height(self, val: float) -> None: ...
1436
+
1437
+ @property
1438
+ def halfHeight(self) -> float:
1439
+ """Half the height of the sprite."""
1440
+ ...
1441
+
1442
+ @halfHeight.setter
1443
+ def halfHeight(self, val: float) -> None: ...
1444
+
1445
+ @property
1446
+ def d(self) -> float:
1447
+ """The diameter of a circular sprite."""
1448
+ ...
1449
+
1450
+ @d.setter
1451
+ def d(self, val: float) -> None: ...
1452
+
1453
+ @property
1454
+ def diameter(self) -> float:
1455
+ """The diameter of a circular sprite."""
1456
+ ...
1457
+
1458
+ @diameter.setter
1459
+ def diameter(self, val: float) -> None: ...
1460
+
1461
+ @property
1462
+ def r(self) -> float:
1463
+ """The radius of a circular sprite."""
1464
+ ...
1465
+
1466
+ @r.setter
1467
+ def r(self, val: float) -> None: ...
1468
+
1469
+ @property
1470
+ def radius(self) -> float:
1471
+ """The radius of a circular sprite."""
1472
+ ...
1473
+
1474
+ @radius.setter
1475
+ def radius(self, val: float) -> None: ...
1476
+
1477
+ @property
1478
+ def update(self) -> Callable[..., Any]:
1479
+ """
1480
+ Runs before each physics update by default.
1481
+
1482
+ Set this to a custom function that handles input, directs sprite movement,
1483
+ and performs other tasks that should run before the physics update.
1484
+
1485
+ Optionally, users can run this function manually in q5play's `update`
1486
+ function.
1487
+ """
1488
+ ...
1489
+
1490
+ @update.setter
1491
+ def update(self, val: Callable[..., Any]) -> None: ...
1492
+
1493
+ @property
1494
+ def vel(self) -> Vector:
1495
+ """
1496
+ The sprite's velocity vector {x, y}
1497
+
1498
+ Default: `{x: 0, y: 0}`
1499
+ """
1500
+ ...
1501
+
1502
+ @vel.setter
1503
+ def vel(self, val: list | dict | Vector) -> None: ...
1504
+
1505
+ @property
1506
+ def velocity(self) -> Vector:
1507
+ """
1508
+ The sprite's velocity vector {x, y}
1509
+
1510
+ Default: `{x: 0, y: 0}`
1511
+ """
1512
+ ...
1513
+
1514
+ @velocity.setter
1515
+ def velocity(self, val: list | dict | Vector) -> None: ...
1516
+
1517
+ @property
1518
+ def grabbable(self) -> bool:
1519
+ """Whether the sprite can be grabbed by a pointer."""
1520
+ ...
1521
+
1522
+ @grabbable.setter
1523
+ def grabbable(self, val: bool) -> None: ...
1524
+
1525
+ @property
1526
+ def gravityScale(self) -> float:
1527
+ """
1528
+ A ratio that defines how much the sprite is affected by gravity.
1529
+
1530
+ Default: `1`
1531
+ """
1532
+ ...
1533
+
1534
+ @gravityScale.setter
1535
+ def gravityScale(self, val: float) -> None: ...
1536
+
1537
+ @overload
1538
+ def applyForce(self, amount: float, origin: dict = ...) -> None:
1539
+ """
1540
+ Applies a force magnitude at the sprite's current bearing.
1541
+
1542
+ Args:
1543
+ amount: force magnitude
1544
+ origin: point (relative to the sprite) where the force is applied. Accepts an object with `x` and `y` properties.
1545
+ """
1546
+ ...
1547
+
1548
+ @overload
1549
+ def applyForce(self, force: list[dict | float], origin: dict = ...) -> None:
1550
+ """
1551
+ Applies a force vector to the sprite.
1552
+
1553
+ Args:
1554
+ force: force vector as an object with `x` and `y` properties or array of [x, y]
1555
+ origin: point (relative to the sprite) where the force is applied. Accepts an object with `x` and `y` properties.
1556
+ """
1557
+ ...
1558
+
1559
+ def applyForce(self, force: list[dict | float], origin: dict = ...) -> None:
1560
+ ...
1561
+
1562
+ @overload
1563
+ def applyForceScaled(self, amount: float, origin: dict = ...) -> None:
1564
+ """
1565
+ Applies a force scaled to the sprite's mass using a magnitude.
1566
+
1567
+ Args:
1568
+ amount: force magnitude
1569
+ origin: point (relative to the sprite) where the force is applied. Accepts an object with `x` and `y` properties.
1570
+ """
1571
+ ...
1572
+
1573
+ @overload
1574
+ def applyForceScaled(self, force: dict, origin: dict = ...) -> None:
1575
+ """
1576
+ Applies a force scaled to the sprite's mass using a vector.
1577
+
1578
+ Args:
1579
+ force: force vector as an object with `x` and `y` properties
1580
+ origin: point (relative to the sprite) where the force is applied. Accepts an object with `x` and `y` properties.
1581
+ """
1582
+ ...
1583
+
1584
+ def applyForceScaled(self, force: dict, origin: dict = ...) -> None:
1585
+ ...
1586
+
1587
+ def applyWind(self, strength: float, angle: float, drag: float = ..., lift: float = ...) -> None:
1588
+ """
1589
+ Applies wind force to the sprite.
1590
+
1591
+ Args:
1592
+ strength: the strength of the wind
1593
+ angle: the angle the wind is blowing at
1594
+ drag: the force that opposes the relative velocity
1595
+ lift: the force that is perpendicular to the relative velocity
1596
+ """
1597
+ ...
1598
+
1599
+ @overload
1600
+ def attractTo(self, x: float, y: float, force: float = ...) -> None:
1601
+ """
1602
+ Applies a force to the sprite's center of mass attracting it to
1603
+ the given position.
1604
+
1605
+ Args:
1606
+ x: x coordinate
1607
+ y: y coordinate
1608
+ """
1609
+ ...
1610
+
1611
+ @overload
1612
+ def attractTo(self, pos: dict, force: float = ...) -> None:
1613
+ """
1614
+ Applies a force to the sprite's center of mass attracting it to
1615
+ the given position.
1616
+
1617
+ Args:
1618
+ pos: object with x and y properties
1619
+ """
1620
+ ...
1621
+
1622
+ def attractTo(self, pos: dict, force: float = ...) -> None:
1623
+ ...
1624
+
1625
+ @overload
1626
+ def repelFrom(self, x: float, y: float, force: float = ...) -> None:
1627
+ """
1628
+ Applies a force to the sprite's center of mass repelling it from
1629
+ the given position.
1630
+
1631
+ Args:
1632
+ x: x coordinate
1633
+ y: y coordinate
1634
+ """
1635
+ ...
1636
+
1637
+ @overload
1638
+ def repelFrom(self, pos: dict, force: float = ...) -> None:
1639
+ """
1640
+ Applies a force to the sprite's center of mass repelling it from
1641
+ the given position.
1642
+
1643
+ Args:
1644
+ pos: object with x and y properties
1645
+ """
1646
+ ...
1647
+
1648
+ def repelFrom(self, pos: dict, force: float = ...) -> None:
1649
+ ...
1650
+
1651
+ def applyTorque(self, torque: Any) -> None:
1652
+ """
1653
+ Apply a torque on the sprite's physics body.
1654
+ Torque is the force that causes rotation.
1655
+ A positive torque will rotate the sprite clockwise.
1656
+ A negative torque will rotate the sprite counter-clockwise.
1657
+
1658
+ This function is the rotational equivalent of applyForce().
1659
+ It will not imperatively set the sprite's rotation.
1660
+ """
1661
+ ...
1662
+
1663
+ @overload
1664
+ def moveTo(self, x: float | None, y: float | None, speed: float = ...) -> Awaitable[bool]:
1665
+ """
1666
+ Attempts to move the sprite to a destination at a constant speed
1667
+ and stops the sprite if it reaches the destination.
1668
+
1669
+ The destination check is deferred until the sprite is estimated to be
1670
+ at the target position, based on `world.physicsTime`.
1671
+
1672
+ Args:
1673
+ x: destination x, or `null` to only move on the y-axis
1674
+ y: destination y, or `null` to only move on the x-axis
1675
+ speed: movement speed in pixels per frame, defaults to the sprite's current speed or 1
1676
+
1677
+ Returns:
1678
+ a lazy thenable that resolves `true` if the sprite reached the destination, or `false` if it didn't.
1679
+ """
1680
+ ...
1681
+
1682
+ @overload
1683
+ def moveTo(self, pos: dict, speed: float = ...) -> Awaitable[bool]:
1684
+ """
1685
+ Attempts to move the sprite to a destination at a constant speed
1686
+ and stops the sprite if it reaches the destination.
1687
+
1688
+ Args:
1689
+ pos: destination object with x and y properties
1690
+ speed: movement speed in pixels per frame, defaults to the sprite's current speed or 1
1691
+
1692
+ Returns:
1693
+ a lazy thenable that resolves `true` if the sprite reached the destination, or `false` if it didn't.
1694
+ """
1695
+ ...
1696
+
1697
+ def moveTo(self, pos: dict, speed: float = ...) -> Awaitable[bool]:
1698
+ ...
1699
+
1700
+ @overload
1701
+ def moveTowards(self, x: float | None, y: float | None, tracking: float = ...) -> None:
1702
+ """
1703
+ Moves the sprite towards a position at a percentage of the distance
1704
+ between itself and the destination.
1705
+
1706
+ Args:
1707
+ x: destination x, or `null` to only move on the y-axis
1708
+ y: destination y, or `null` to only move on the x-axis
1709
+ tracking: percent of the distance to move towards the destination as a 0-1 value, default is 0.1 (10% tracking)
1710
+ """
1711
+ ...
1712
+
1713
+ @overload
1714
+ def moveTowards(self, pos: dict, tracking: float = ...) -> None:
1715
+ """
1716
+ Moves the sprite towards a position at a percentage of the distance
1717
+ between itself and the destination.
1718
+
1719
+ Args:
1720
+ pos: destination object with x and y properties
1721
+ tracking: percent of the distance to move towards the destination as a 0-1 value, default is 0.1 (10% tracking)
1722
+ """
1723
+ ...
1724
+
1725
+ def moveTowards(self, pos: dict, tracking: float = ...) -> None:
1726
+ ...
1727
+
1728
+ @overload
1729
+ def rotateTo(self, angle: float, speed: float = ...) -> Awaitable[bool]:
1730
+ """
1731
+ Rotates the sprite to a target angle at a constant speed,
1732
+ stopping if it arrives.
1733
+
1734
+ The destination check is deferred until the sprite is estimated to be
1735
+ at the target angle, based on `world.physicsTime`.
1736
+
1737
+ Args:
1738
+ angle: target rotation angle
1739
+ speed: rotation speed in degrees (or radians) per frame, defaults to the sprite's current rotationSpeed or 1
1740
+
1741
+ Returns:
1742
+ a lazy thenable that resolves `true` if the sprite reached the target angle, or `false` if it didn't.
1743
+ """
1744
+ ...
1745
+
1746
+ @overload
1747
+ def rotateTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
1748
+ """
1749
+ Rotates the sprite to face a position at a constant speed,
1750
+ stopping if it arrives.
1751
+
1752
+ Args:
1753
+ pos: object with x and y properties
1754
+ speed: rotation speed in degrees (or radians) per frame, defaults to the sprite's current rotationSpeed or 1
1755
+ facing: rotation angle the sprite should be at when "facing" the position, default is 0
1756
+
1757
+ Returns:
1758
+ a lazy thenable that resolves `true` if the sprite reached the target angle, or `false` if it didn't.
1759
+ """
1760
+ ...
1761
+
1762
+ def rotateTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
1763
+ ...
1764
+
1765
+ @overload
1766
+ def rotateMinTo(self, angle: float, speed: float = ...) -> Awaitable[bool]:
1767
+ """
1768
+ Rotates the sprite by the smallest angular distance to a target angle
1769
+ at a constant speed, stopping when it arrives.
1770
+
1771
+ Args:
1772
+ angle: target rotation angle
1773
+ speed: absolute rotation per frame, defaults to the sprite's current rotationSpeed or 1
1774
+
1775
+ Returns:
1776
+ a lazy thenable that resolves `true` if the sprite reached the target angle, or `false` if it didn't.
1777
+ """
1778
+ ...
1779
+
1780
+ @overload
1781
+ def rotateMinTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
1782
+ """
1783
+ Rotates the sprite by the smallest angular distance to face a position
1784
+ at a constant speed, stopping when it arrives.
1785
+
1786
+ Args:
1787
+ pos: object with x and y properties
1788
+ speed: absolute rotation per frame, defaults to the sprite's current rotationSpeed or 1
1789
+ facing: rotation angle the sprite should be at when "facing" the position, default is 0
1790
+
1791
+ Returns:
1792
+ a lazy thenable that resolves `true` if the sprite reached the target angle, or `false` if it didn't.
1793
+ """
1794
+ ...
1795
+
1796
+ def rotateMinTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
1797
+ ...
1798
+
1799
+ @overload
1800
+ def rotateTowards(self, angle: float, tracking: float = ...) -> None:
1801
+ """
1802
+ Rotates the sprite towards an angle.
1803
+
1804
+ Args:
1805
+ angle: angle in degrees
1806
+ tracking: percent of the distance to rotate on each frame towards the target angle, default is 0.1 (10%)
1807
+ """
1808
+ ...
1809
+
1810
+ @overload
1811
+ def rotateTowards(self, pos: dict, tracking: float = ..., facing: float = ...) -> None:
1812
+ """
1813
+ Rotates the sprite towards a position.
1814
+
1815
+ Args:
1816
+ pos: object with x and y properties
1817
+ tracking: percent of the distance to rotate on each frame towards the target position, default is 0.1 (10%)
1818
+ facing: rotation angle the sprite should be at when "facing" the position, default is 0
1819
+ """
1820
+ ...
1821
+
1822
+ def rotateTowards(self, pos: dict, tracking: float = ..., facing: float = ...) -> None:
1823
+ ...
1824
+
1825
+ @overload
1826
+ def angleTo(self, x: float, y: float, facing: float = ...) -> float:
1827
+ """
1828
+ Finds the angle from this sprite to the given position.
1829
+
1830
+ Equivalent to `atan2(y - sprite.y, x - sprite.x) + facing`.
1831
+ Returns the sprite's current rotation if the position is within 0.01 pixels.
1832
+
1833
+ Can be used to set the direction of a sprite so it moves toward a position.
1834
+
1835
+ Args:
1836
+ x: x coordinate
1837
+ y: y coordinate
1838
+ facing: offset angle added to the result, default is 0
1839
+
1840
+ Returns:
1841
+ angle to the position
1842
+ """
1843
+ ...
1844
+
1845
+ @overload
1846
+ def angleTo(self, pos: dict, facing: float = ...) -> float:
1847
+ """
1848
+ Finds the angle from this sprite to the given position.
1849
+
1850
+ Args:
1851
+ pos: object with x and y properties
1852
+ facing: offset angle added to the result, default is 0
1853
+
1854
+ Returns:
1855
+ angle to the position
1856
+ """
1857
+ ...
1858
+
1859
+ def angleTo(self, pos: dict, facing: float = ...) -> float:
1860
+ ...
1861
+
1862
+ @overload
1863
+ def angleDistTo(self, x: float, y: float, facing: float = ...) -> float:
1864
+ """
1865
+ Finds the minimum angular distance the sprite would need to rotate
1866
+ to face a position, taking into account the sprite's current rotation.
1867
+
1868
+ Useful for `rotateTowards`-style logic where you need the signed delta
1869
+ rather than an absolute target angle.
1870
+
1871
+ Args:
1872
+ x: x coordinate
1873
+ y: y coordinate
1874
+ facing: offset angle, default is 0
1875
+
1876
+ Returns:
1877
+ the minimum angular distance to face the position
1878
+ """
1879
+ ...
1880
+
1881
+ @overload
1882
+ def angleDistTo(self, pos: dict, facing: float = ...) -> float:
1883
+ """
1884
+ Finds the minimum angular distance the sprite would need to rotate
1885
+ to face a position, taking into account the sprite's current rotation.
1886
+
1887
+ Args:
1888
+ pos: object with x and y properties
1889
+ facing: offset angle, default is 0
1890
+
1891
+ Returns:
1892
+ the minimum angular distance to face the position
1893
+ """
1894
+ ...
1895
+
1896
+ def angleDistTo(self, pos: dict, facing: float = ...) -> float:
1897
+ ...
1898
+
1899
+ @overload
1900
+ def transformTowards(self, x: float, y: float, rotation: float = ..., tracking: float = ...) -> None:
1901
+ """
1902
+ Moves and rotates a sprite's physics body towards a target transform
1903
+ at a percentage of the distance on each frame.
1904
+
1905
+ Uses Box2D's `b2Body_SetTargetTransform` for maximum efficiency
1906
+ compared to using `moveTowards` and `rotateTowards` separately.
1907
+
1908
+ Args:
1909
+ x: destination x
1910
+ y: destination y
1911
+ rotation: target rotation angle
1912
+ tracking: percent of the distance to move towards the target as a 0-1 value, default is 0.1 (10% tracking)
1913
+ """
1914
+ ...
1915
+
1916
+ @overload
1917
+ def transformTowards(self, pos: dict, rotation: float = ..., tracking: float = ...) -> None:
1918
+ """
1919
+ Moves and rotates a sprite's physics body towards a target transform
1920
+ at a percentage of the distance on each frame.
1921
+
1922
+ Args:
1923
+ pos: destination object with x and y properties
1924
+ rotation: target rotation angle
1925
+ tracking: percent of the distance to move towards the target as a 0-1 value, default is 0.1 (10% tracking)
1926
+ """
1927
+ ...
1928
+
1929
+ def transformTowards(self, pos: dict, rotation: float = ..., tracking: float = ...) -> None:
1930
+ ...
1931
+
1932
+ def delete(self) -> None:
1933
+ """
1934
+ Deletes the Sprite from the sketch and all the groups it
1935
+ belongs to.
1936
+
1937
+ When a sprite is deleted it will not be drawn or updated anymore.
1938
+ If it has a physics body, it will be deleted from the physics simulation.
1939
+
1940
+ There's no way to undo this operation. If you want to hide a
1941
+ sprite use `sprite.visible = false` instead.
1942
+ """
1943
+ ...
1944
+
1945
+ def toString(self) -> str:
1946
+ """
1947
+ Returns the sprite's unique identifier `sprite.idNum`.
1948
+
1949
+ Returns:
1950
+ the sprite's id
1951
+ """
1952
+ ...
1953
+
1954
+ def collides(self, target: Sprite | Group, callback: Callable[..., Any] = ...) -> bool:
1955
+ """
1956
+ Returns true on the first frame that the sprite collides with the
1957
+ target sprite or group.
1958
+
1959
+ Custom collision event handling can be done by using this function
1960
+ in an if statement or adding a callback as the second parameter.
1961
+ """
1962
+ ...
1963
+
1964
+ def colliding(self, target: Sprite | Group, callback: Callable[..., Any] = ...) -> float:
1965
+ """
1966
+ Returns a truthy value while the sprite is colliding with the
1967
+ target sprite or group. The value is the number of frames that
1968
+ the sprite has been colliding with the target.
1969
+
1970
+ Returns:
1971
+ frames
1972
+ """
1973
+ ...
1974
+
1975
+ def collided(self, target: Sprite | Group, callback: Callable[..., Any] = ...) -> bool:
1976
+ """
1977
+ Returns true on the first frame that the sprite no longer overlaps
1978
+ with the target sprite or group.
1979
+ """
1980
+ ...
1981
+
1982
+ def overlaps(self, target: Sprite | Group, callback: Callable[..., Any] = ...) -> bool:
1983
+ """
1984
+ Returns true on the first frame that the sprite overlaps with the
1985
+ target sprite or group.
1986
+
1987
+ Custom overlap event handling can be done by using this function
1988
+ in an if statement or adding a callback as the second parameter.
1989
+ """
1990
+ ...
1991
+
1992
+ def overlapping(self, target: Sprite | Group, callback: Callable[..., Any] = ...) -> float:
1993
+ """
1994
+ Returns a truthy value while the sprite is overlapping with the
1995
+ target sprite or group. The value returned is the number of
1996
+ frames the sprite has been overlapping with the target.
1997
+
1998
+ Returns:
1999
+ frames
2000
+ """
2001
+ ...
2002
+
2003
+ def overlapped(self, target: Sprite | Group, callback: Callable[..., Any] = ...) -> bool:
2004
+ """
2005
+ Returns true on the first frame that the sprite no longer overlaps
2006
+ with the target sprite or group.
2007
+ """
2008
+ ...
2009
+
2010
+ def pass_(self, target: Sprite | Group) -> None:
2011
+ """
2012
+ Sets a pass through contact relationship between the sprite
2013
+ and a target sprite or group.
2014
+ """
2015
+ ...
2016
+
2017
+ def passes(self, target: Sprite | Group) -> None:
2018
+ """
2019
+ Sets a pass through contact relationship between the sprite
2020
+ and a target sprite or group.
2021
+ """
2022
+ ...
2023
+
2024
+ def addDefaultSensors(self) -> None:
2025
+ """
2026
+ Creates overlap sensors that are the same size as the sprite's
2027
+ colliders. If you'd like to add more sensors to a sprite, use the
2028
+ `addSensor` function.
2029
+
2030
+ Used internally if a sprite overlap detection
2031
+ function is called but the sprite has no overlap sensors.
2032
+ """
2033
+ ...
2034
+
2035
+ @overload
2036
+ def distanceTo(self, x: float, y: float) -> float:
2037
+ """
2038
+ Returns the distance to another sprite, the mouse, a touch pointer,
2039
+ or any other object with x and y properties. Uses q5's `dist` function.
2040
+
2041
+ Returns:
2042
+ distance
2043
+ """
2044
+ ...
2045
+
2046
+ @overload
2047
+ def distanceTo(self, pos: dict) -> float:
2048
+ """
2049
+ Returns the distance to another sprite, the mouse, a touch pointer,
2050
+ or any other object with x and y properties. Uses q5's `dist` function.
2051
+
2052
+ Args:
2053
+ pos: object with x and y properties
2054
+
2055
+ Returns:
2056
+ distance
2057
+ """
2058
+ ...
2059
+
2060
+ def distanceTo(self, pos: dict) -> float:
2061
+ ...
2062
+
2063
+ class Ani(list[Image]):
2064
+
2065
+ @classmethod
2066
+ def new(cls, *args: Image) -> 'Ani':
2067
+ """
2068
+ Ani objects are an array of images
2069
+ that can be displayed by a Visual or Sprite.
2070
+
2071
+ Args:
2072
+ args: the frames of the animation
2073
+ """
2074
+ ...
2075
+
2076
+ def __init__(self, *args: Image) -> None: ...
2077
+
2078
+ name: str
2079
+ """The name of the animation"""
2080
+
2081
+ targetFrame: float
2082
+
2083
+ offset: dict
2084
+ """
2085
+ The distance from the sprite or visual's position
2086
+ that the animation is drawn at.
2087
+ """
2088
+
2089
+ playing: bool
2090
+ """
2091
+ True if the animation is currently playing.
2092
+
2093
+ Default: `true`
2094
+ """
2095
+
2096
+ visible: bool
2097
+ """
2098
+ Animation visibility.
2099
+
2100
+ Default: `true`
2101
+ """
2102
+
2103
+ looping: bool
2104
+ """
2105
+ If set to false the animation will stop after reaching the last frame
2106
+
2107
+ Default: `true`
2108
+ """
2109
+
2110
+ endOnFirstFrame: bool
2111
+ """
2112
+ Ends the loop on frame 0 instead of the last frame.
2113
+ This is useful for animations that are symmetric.
2114
+ For example a walking cycle where the first frame is the
2115
+ same as the last frame.
2116
+
2117
+ Default: `false`
2118
+ """
2119
+
2120
+ frameChanged: bool
2121
+ """True if frame changed during the last draw cycle"""
2122
+
2123
+ onComplete: Any
2124
+
2125
+ onChange: Any
2126
+
2127
+ rotation: Any
2128
+
2129
+ spriteSheet: Any
2130
+
2131
+ @property
2132
+ def frame(self) -> float:
2133
+ """The index of the current frame that the animation is on."""
2134
+ ...
2135
+
2136
+ @frame.setter
2137
+ def frame(self, val: float) -> None: ...
2138
+
2139
+ @property
2140
+ def frameDelay(self) -> float:
2141
+ """
2142
+ Delay between frames in number of draw cycles.
2143
+ If set to 4 the framerate of the animation would be the
2144
+ sketch framerate divided by 4 (60fps = 15fps)
2145
+
2146
+ Default: `4`
2147
+ """
2148
+ ...
2149
+
2150
+ @frameDelay.setter
2151
+ def frameDelay(self, val: float) -> None: ...
2152
+
2153
+ @property
2154
+ def scale(self) -> float | dict:
2155
+ """
2156
+ The animation's scale.
2157
+
2158
+ Can be set to a number to scale both x and y
2159
+ or an object with x and/or y properties.
2160
+
2161
+ Default: `1`
2162
+ """
2163
+ ...
2164
+
2165
+ @scale.setter
2166
+ def scale(self, val: float | dict) -> None: ...
2167
+
2168
+ def clone(self) -> Ani:
2169
+ """
2170
+ Make a copy of the animation, with its own playback state,
2171
+ independent of the original animation.
2172
+ """
2173
+ ...
2174
+
2175
+ def update(self) -> None:
2176
+ """Updates the animation's playback state. This is called automatically"""
2177
+ ...
2178
+
2179
+ def play(self, frame: Any) -> Awaitable[Any]:
2180
+ """
2181
+ Plays the animation, starting from the specified frame.
2182
+
2183
+ Returns:
2184
+ [Promise] a promise that resolves when the animation completes
2185
+ """
2186
+ ...
2187
+
2188
+ def pause(self, frame: Any) -> None:
2189
+ """Pauses the animation."""
2190
+ ...
2191
+
2192
+ def stop(self, frame: Any) -> None:
2193
+ """Stops the animation. Alt for pause."""
2194
+ ...
2195
+
2196
+ def rewind(self) -> Awaitable[Any]:
2197
+ """
2198
+ Plays the animation backwards.
2199
+ Equivalent to ani.goToFrame(0)
2200
+
2201
+ Returns:
2202
+ [Promise] a promise that resolves when the animation completes rewinding
2203
+ """
2204
+ ...
2205
+
2206
+ def loop(self) -> None:
2207
+ """Plays the animation forwards and loops it."""
2208
+ ...
2209
+
2210
+ def noLoop(self) -> None:
2211
+ """Prevents the animation from looping"""
2212
+ ...
2213
+
2214
+ def nextFrame(self) -> None:
2215
+ """Goes to the next frame and stops."""
2216
+ ...
2217
+
2218
+ def previousFrame(self) -> None:
2219
+ """Goes to the previous frame and stops."""
2220
+ ...
2221
+
2222
+ def goToFrame(self, toFrame: float) -> Awaitable[Any]:
2223
+ """
2224
+ Plays the animation forward or backward toward a target frame.
2225
+
2226
+ Args:
2227
+ toFrame: Frame number destination (starts from 0)
2228
+
2229
+ Returns:
2230
+ [Promise] a promise that resolves when the animation completes
2231
+ """
2232
+ ...
2233
+
2234
+ @property
2235
+ def lastFrame(self) -> float:
2236
+ """The index of the last frame. Read only."""
2237
+ ...
2238
+
2239
+ @property
2240
+ def frameImage(self) -> Image:
2241
+ """The current frame as Q5.Image. Read only."""
2242
+ ...
2243
+
2244
+ @property
2245
+ def w(self) -> float:
2246
+ """Width of the animation's current frame."""
2247
+ ...
2248
+
2249
+ @property
2250
+ def width(self) -> float:
2251
+ """Width of the animation's current frame."""
2252
+ ...
2253
+
2254
+ @property
2255
+ def defaultWidth(self) -> Any:
2256
+ ...
2257
+
2258
+ @property
2259
+ def h(self) -> float:
2260
+ """Height of the animation's current frame."""
2261
+ ...
2262
+
2263
+ @property
2264
+ def height(self) -> float:
2265
+ """Height of the animation's current frame."""
2266
+ ...
2267
+
2268
+ @property
2269
+ def defaultHeight(self) -> Any:
2270
+ ...
2271
+
2272
+ class Anis:
2273
+ """
2274
+ Stores animations.
2275
+
2276
+ Used internally to create `sprite.anis` and `group.anis`.
2277
+
2278
+ In instances of this class, the keys are animation names,
2279
+ values are Ani objects.
2280
+ """
2281
+
2282
+ frameDelay: float
2283
+
2284
+ offset: dict
2285
+
2286
+ scale: float | dict
2287
+
2288
+ looping: bool
2289
+
2290
+ playing: bool
2291
+
2292
+ cutFrames: bool
2293
+ """
2294
+ Cuts sprite sheet frames into separate images, instead of rendering
2295
+ sections of the sprite sheet.
2296
+
2297
+ Avoids edge bleeding artifacts caused by rotation and scaling,
2298
+ but uses more memory and may cause longer load times.
2299
+ """
2300
+
2301
+ endOnFirstFrame: bool
2302
+
2303
+ w: float
2304
+
2305
+ width: float
2306
+
2307
+ h: float
2308
+
2309
+ height: float
2310
+
2311
+ frameSize: str
2312
+ """Frame size of the animations in the collection, in the format "WIDTHxHEIGHT", for example "32x32"."""
2313
+
2314
+ spriteSheet: Image
2315
+ """The sprite sheet image used by the animations in the collection."""
2316
+
2317
+ _T_Visuals = TypeVar('_T_Visuals', bound=Visual)
2318
+
2319
+ class Visuals(list[_T_Visuals], Generic[_T_Visuals]):
2320
+ """
2321
+ A collection of and blueprint for Visual objects
2322
+ that store an image or animation(s)
2323
+ which can be displayed with respect to the camera.
2324
+ """
2325
+
2326
+ def draw(self) -> None:
2327
+ """Draws the visuals on the canvas."""
2328
+ ...
2329
+
2330
+ img: Image
2331
+ """Current image."""
2332
+
2333
+ ani: Ani
2334
+ """Current animation."""
2335
+
2336
+ @property
2337
+ def anis(self) -> Anis:
2338
+ """
2339
+ Stores animations.
2340
+ Keys are the animation label, values are Ani objects
2341
+ """
2342
+ ...
2343
+
2344
+ def addAni(self, spriteSheetURL: str, frameCount: float) -> Awaitable[None]:
2345
+ """
2346
+ Adds an animation to the Group or Visuals array.
2347
+
2348
+ Args:
2349
+ spriteSheetURL: the URL of the sprite sheet image
2350
+ frameCount: the number of frames in the sprite sheet
2351
+
2352
+ Returns:
2353
+ A promise that fulfills when the animation is loaded
2354
+ """
2355
+ ...
2356
+
2357
+ @overload
2358
+ def addAnis(self, atlases: dict) -> Awaitable[None]:
2359
+ """
2360
+ Add multiple animations to the Group or Visuals array.
2361
+
2362
+ Args:
2363
+ atlases: an object with animation names as keys and an animation or animation atlas as values
2364
+
2365
+ Returns:
2366
+ A promise that fulfills when the animations are loaded
2367
+ """
2368
+ ...
2369
+
2370
+ @overload
2371
+ def addAnis(self, spriteSheetURL: str, atlases: dict) -> Awaitable[None]:
2372
+ """
2373
+ Add multiple animations to the Group or Visuals array.
2374
+
2375
+ Args:
2376
+ spriteSheetURL: the URL of the sprite sheet image
2377
+ atlases: an object with animation names as keys and an animation or animation atlas as values
2378
+
2379
+ Returns:
2380
+ A promise that fulfills when the animations are loaded
2381
+ """
2382
+ ...
2383
+
2384
+ @overload
2385
+ def addAnis(self, spriteSheetURL: str, frameSize: str, atlases: dict) -> Awaitable[None]:
2386
+ """
2387
+ Add multiple animations to the Group or Visuals array.
2388
+
2389
+ Args:
2390
+ spriteSheetURL: the URL of the sprite sheet image
2391
+ frameSize: the size of each frame in the sprite sheet in the format "WIDTHxHEIGHT" (example: "32x32")
2392
+ atlases: an object with animation names as keys and an animation or animation atlas as values
2393
+
2394
+ Returns:
2395
+ A promise that fulfills when the animations are loaded
2396
+ """
2397
+ ...
2398
+
2399
+ def addAnis(self, spriteSheetURL: str, frameSize: str, atlases: dict) -> Awaitable[None]:
2400
+ ...
2401
+
2402
+ def cull(self, top: float = ..., bottom: float = ..., left: float = ..., right: float = ..., cb: Callable[..., Any] = ...) -> float:
2403
+ """
2404
+ Detects when visuals go outside the given culling boundary,
2405
+ relative to the camera.
2406
+
2407
+ Args:
2408
+ top: top bound or boundary range
2409
+ bottom: bottom bound
2410
+ left: left bound
2411
+ right: right bound
2412
+ cb: the function to be run when a visual is culled, it's given the visual being culled, if no callback is given then the visual's life is set to 0
2413
+
2414
+ Returns:
2415
+ the number of visuals culled
2416
+ """
2417
+ ...
2418
+
2419
+ tile: str
2420
+ """The tile character that represents the Visuals or Group in a tile map."""
2421
+
2422
+ def addTiles(self, tiles: list[str], x: float = ..., y: float = ..., colWidth: float = ..., rowHeight: float = ...) -> None:
2423
+ """
2424
+ Adds sprites to the group based on a tile map.
2425
+
2426
+ Args:
2427
+ x: x coordinate of the top left corner of the tile map, default is -colWidth * longest row / 2
2428
+ y: y coordinate of the top left corner of the tile map, default is -rowHeight * number of rows / 2
2429
+ colWidth: column width including spacing, default is the width of the first tile
2430
+ rowHeight: row height including spacing, default is the height of the first tile
2431
+ """
2432
+ ...
2433
+
2434
+ class Group(Visuals[Sprite]):
2435
+ """
2436
+ A Group is a collection of and blueprint for
2437
+ sprites with similar traits and behaviors.
2438
+ """
2439
+
2440
+ @classmethod
2441
+ def new(cls, *sprites: Sprite) -> 'Group':
2442
+ """
2443
+ A Group is a collection of and blueprint for
2444
+ sprites with similar traits and behaviors.
2445
+
2446
+ Group extends Visuals which extends Array,
2447
+ so you can use them in for loops. They've got
2448
+ all the functions and properties of standard arrays
2449
+ such as `group.length` and functions like `group.includes()`.
2450
+
2451
+ Changing a group setting changes it for all the sprites in the
2452
+ group ("dynamic inheritance").
2453
+
2454
+ All groups inherit from the base group `allSprites`.
2455
+
2456
+ Groups can have subgroups, creating a hierarchy of inheritance.
2457
+ """
2458
+ ...
2459
+
2460
+ def __init__(self, *sprites: Sprite) -> None: ...
2461
+
2462
+ x: float
2463
+ """Horizontal position of group sprites."""
2464
+
2465
+ y: float
2466
+ """Vertical position of group sprites."""
2467
+
2468
+ vel: float
2469
+ """Velocity of group sprites."""
2470
+
2471
+ velocity: float
2472
+ """Velocity of group sprites."""
2473
+
2474
+ rotation: float
2475
+ """
2476
+ The angle of the group sprites' rotation, not the direction it's moving.
2477
+
2478
+ If angleMode is set to "degrees", the value will be returned in
2479
+ a range of -180 to 180.
2480
+ """
2481
+
2482
+ rotationSpeed: float
2483
+ """The speed of the group sprites' rotation in angles per frame."""
2484
+
2485
+ autoDraw: bool
2486
+ """If true, group sprites are drawn by q5play after each physics update."""
2487
+
2488
+ allowSleeping: bool
2489
+ """
2490
+ Controls the ability for group sprites to "sleep".
2491
+
2492
+ "Sleeping" sprites are not included in the physics simulation, a
2493
+ sprite starts "sleeping" when it stops moving and doesn't collide
2494
+ with anything that it wasn't already colliding with.
2495
+ """
2496
+
2497
+ autoUpdate: float
2498
+ """If true, group sprites are updated by q5play before each physics update."""
2499
+
2500
+ bearing: float
2501
+ """
2502
+ A bearing indicates the direction that needs to be followed to
2503
+ reach a destination.
2504
+
2505
+ Setting a group sprites' bearing doesn't do anything by itself.
2506
+ You can apply a force to the group sprites at its bearing angle
2507
+ using the `applyForce` function.
2508
+ """
2509
+
2510
+ bounciness: float
2511
+ """The bounciness of the group sprites' physics body."""
2512
+
2513
+ color: Color
2514
+ """
2515
+ The group sprites' current fill color.
2516
+
2517
+ By default sprites get a random color.
2518
+ """
2519
+
2520
+ d: float
2521
+ """The diameter of a circular sprite."""
2522
+
2523
+ diameter: float
2524
+ """The diameter of a circular sprite."""
2525
+
2526
+ debug: bool
2527
+ """
2528
+ If true, outlines of the group sprites' colliders and sensors will be drawn.
2529
+
2530
+ Use the keyboard shortcut Command+B to toggle `allSprites.debug`.
2531
+ """
2532
+
2533
+ density: float
2534
+ """The density of the group sprites' physics body."""
2535
+
2536
+ direction: float
2537
+ """The angle of the group sprites' movement."""
2538
+
2539
+ drag: float
2540
+ """The amount of resistance group sprites has to being moved."""
2541
+
2542
+ friction: float
2543
+ """
2544
+ The amount the group sprites' colliders resist moving
2545
+ when rubbing against other colliders.
2546
+ """
2547
+
2548
+ grabbable: bool
2549
+ """Whether the group sprites can be grabbed by a pointer."""
2550
+
2551
+ gravityScale: float
2552
+ """A ratio that defines how much the group sprites are affected by gravity."""
2553
+
2554
+ heading: str
2555
+ """
2556
+ The group sprites' heading. This is a string that can be set to
2557
+ "up", "down", "left", "right", "upRight", "upLeft", "downRight"
2558
+
2559
+ The setter's input parser ignores capitalization, spaces,
2560
+ underscores, dashes, and cardinal direction word order.
2561
+ """
2562
+
2563
+ h: float
2564
+ """The height of the group sprites."""
2565
+
2566
+ height: float
2567
+ """The height of the group sprites."""
2568
+
2569
+ isSuperFast: bool
2570
+ """
2571
+ Set this to true if the group sprites goes really fast to prevent
2572
+ inaccurate physics simulation.
2573
+ """
2574
+
2575
+ layer: float
2576
+ """
2577
+ Sprites with the highest layer value get drawn first.
2578
+
2579
+ By default sprites are drawn in the order they were created in.
2580
+ """
2581
+
2582
+ life: float
2583
+ """
2584
+ When the physics simulation is progressed in `world.physicsUpdate`,
2585
+ each sprite's life is decreased by `world.timeScale`.
2586
+
2587
+ If life becomes less than or equal to 0, the group sprites will
2588
+ be removed.
2589
+ """
2590
+
2591
+ mass: float
2592
+ """The mass of the group sprites' physics body."""
2593
+
2594
+ physics: str
2595
+ """
2596
+ The physics type of the group sprites, which determines how it interacts with
2597
+ other sprites in the physics simulation.
2598
+
2599
+ It can be set to DYNAMIC/DYN, STATIC/STA, or KINEMATIC/KIN.
2600
+ """
2601
+
2602
+ physicsType: str
2603
+ """
2604
+ The physics type of the group sprites, which determines how it interacts with
2605
+ other sprites in the physics simulation.
2606
+
2607
+ It can be set to DYNAMIC/DYN, STATIC/STA, or KINEMATIC/KIN.
2608
+ """
2609
+
2610
+ physicsEnabled: bool
2611
+ """If true, the group sprites' physics body is included in the physics simulation."""
2612
+
2613
+ pixelPerfect: bool
2614
+ """
2615
+ If true, q5play will draw sprites at integer pixel precision.
2616
+
2617
+ This is useful for making retro games.
2618
+
2619
+ By default q5play draws sprites with subpixel rendering.
2620
+ """
2621
+
2622
+ rollingResistance: float
2623
+ """
2624
+ Simulates friction that slows down group sprites rolling on another sprite,
2625
+ like a soccer ball rolling to a stop on high grass.
2626
+ """
2627
+
2628
+ rotationDrag: float
2629
+ """The amount the group sprites resists rotating."""
2630
+
2631
+ rotationLock: bool
2632
+ """If true, the group sprites can not rotate."""
2633
+
2634
+ scale: float | list | dict
2635
+ """
2636
+ Horizontal and vertical scale of the group sprites.
2637
+
2638
+ Components can be negative to flip/mirror the group sprites on an axis.
2639
+
2640
+ The `valueOf` function for `sprite.scale` returns the scale as a
2641
+ number. This enables users to do things like `sprite.scale *= 2`
2642
+ to double the group sprites' scale.
2643
+ """
2644
+
2645
+ sleeping: bool
2646
+ """
2647
+ Wake group sprites up or put it to sleep.
2648
+
2649
+ "Sleeping" sprites are not included in the physics simulation, a
2650
+ sprite starts "sleeping" when it stops moving and doesn't collide
2651
+ with anything that it wasn't already colliding with.
2652
+ """
2653
+
2654
+ stroke: Color
2655
+ """The group sprites' stroke color."""
2656
+
2657
+ strokeWeight: float
2658
+ """The group sprites' stroke weight, the thickness of its outline."""
2659
+
2660
+ speed: float
2661
+ """
2662
+ The group sprites' speed.
2663
+
2664
+ Setting speed to a negative value will make the group sprites move
2665
+ 180 degrees opposite of its current direction angle.
2666
+ """
2667
+
2668
+ surfaceSpeed: float
2669
+ """
2670
+ The group sprites' speed along the surface of its collider(s),
2671
+ like a conveyor belt.
2672
+ """
2673
+
2674
+ text: float
2675
+ """Text displayed at the center of the group sprites."""
2676
+
2677
+ textFill: Color
2678
+ """The group sprites' text fill color. Black by default."""
2679
+
2680
+ textStroke: Color
2681
+ """
2682
+ The group sprites' text stroke color.
2683
+ No stroke by default, does not inherit from the sketch's stroke color.
2684
+ """
2685
+
2686
+ textStrokeWeight: float
2687
+ """
2688
+ The group sprites' text stroke weight, the thickness of its outline.
2689
+ No stroke by default, does not inherit from the sketch's stroke weight.
2690
+ """
2691
+
2692
+ textSize: float
2693
+ """The group sprites' text size, the sketch's current textSize by default."""
2694
+
2695
+ visible: bool
2696
+ """
2697
+ If true the group sprites are shown, if set to false the group sprites are hidden.
2698
+
2699
+ Becomes null when the group sprites are off screen but will be drawn and
2700
+ set to true again if it goes back on screen.
2701
+ """
2702
+
2703
+ w: float
2704
+ """The width of the group sprites."""
2705
+
2706
+ width: float
2707
+ """The width of the group sprites."""
2708
+
2709
+ idNum: float
2710
+ """
2711
+ Each group has a unique id number. Don't change it!
2712
+ It's useful for debugging.
2713
+ """
2714
+
2715
+ subgroups: list[dict]
2716
+ """
2717
+ Groups can have subgroups, which inherit the properties
2718
+ of their parent groups.
2719
+
2720
+ Default: `[]`
2721
+ """
2722
+
2723
+ parent: Any
2724
+ """The direct parent group that this group inherits properties from."""
2725
+
2726
+ Sprite: Type[Sprite]
2727
+ """Creates a new sprite with the traits of the group and adds it to the group."""
2728
+
2729
+ Group: Type[Group]
2730
+ """Creates a new subgroup that inherits the traits of the group."""
2731
+
2732
+ autoCull: bool
2733
+ """
2734
+ A property of the `allSprites` group only,
2735
+ that controls whether sprites are automatically deleted
2736
+ when they are 10,000 pixels away from the camera.
2737
+
2738
+ It only needs to be set to false once and then it will
2739
+ remain false for the rest of the sketch, unless changed.
2740
+ """
2741
+
2742
+ visualOnly: bool
2743
+ """New group sprites will not have physics bodies (can't have colliders)."""
2744
+
2745
+ add: Callable[..., float]
2746
+ """
2747
+ Alias for `group.push`.
2748
+
2749
+ Adds a sprite to the end of the group.
2750
+ """
2751
+
2752
+ contains: Callable[..., bool]
2753
+ """
2754
+ Alias for `group.includes`.
2755
+
2756
+ Check if a sprite is in the group.
2757
+ """
2758
+
2759
+ @property
2760
+ def amount(self) -> float:
2761
+ """
2762
+ Depending on the value that the amount property is set to, the group will
2763
+ either add or delete sprites.
2764
+ """
2765
+ ...
2766
+
2767
+ @amount.setter
2768
+ def amount(self, val: float) -> None: ...
2769
+
2770
+ def collides(self, target: Group, callback: Callable[..., Any] = ...) -> bool:
2771
+ """
2772
+ Returns true on the first frame that the group collides with the
2773
+ target group.
2774
+
2775
+ Custom collision event handling can be done by using this function
2776
+ in an if statement or adding a callback as the second parameter.
2777
+ """
2778
+ ...
2779
+
2780
+ def colliding(self, target: Group, callback: Callable[..., Any] = ...) -> float:
2781
+ """
2782
+ Returns the amount of frames that the group has been colliding
2783
+ with the target group for, which is a truthy value. Returns 0 if
2784
+ the group is not colliding with the target group.
2785
+
2786
+ Returns:
2787
+ frames
2788
+ """
2789
+ ...
2790
+
2791
+ def collided(self, target: Group, callback: Callable[..., Any] = ...) -> bool:
2792
+ """
2793
+ Returns true on the first frame that the group no longer overlaps
2794
+ with the target group.
2795
+ """
2796
+ ...
2797
+
2798
+ def overlaps(self, target: Group, callback: Callable[..., Any] = ...) -> bool:
2799
+ """
2800
+ Returns true on the first frame that the group overlaps with the
2801
+ target group.
2802
+
2803
+ Custom overlap event handling can be done by using this function
2804
+ in an if statement or adding a callback as the second parameter.
2805
+ """
2806
+ ...
2807
+
2808
+ def overlapping(self, target: Group, callback: Callable[..., Any] = ...) -> float:
2809
+ """
2810
+ Returns the amount of frames that the group has been overlapping
2811
+ with the target group for, which is a truthy value. Returns 0 if
2812
+ the group is not overlapping with the target group.
2813
+
2814
+ Returns:
2815
+ frames
2816
+ """
2817
+ ...
2818
+
2819
+ def overlapped(self, target: Group, callback: Callable[..., Any] = ...) -> bool:
2820
+ """
2821
+ Returns true on the first frame that the group no longer overlaps
2822
+ with the target group.
2823
+ """
2824
+ ...
2825
+
2826
+ def pass_(self, target: Group) -> None:
2827
+ """Sets a pass through contact relationship between the group and the target group."""
2828
+ ...
2829
+
2830
+ def passes(self, target: Group) -> None:
2831
+ """Sets a pass through contact relationship between the group and the target group."""
2832
+ ...
2833
+
2834
+ @overload
2835
+ def applyForce(self, amount: float, origin: dict = ...) -> None:
2836
+ """Applies a force magnitude to the group at its bearing."""
2837
+ ...
2838
+
2839
+ @overload
2840
+ def applyForce(self, force: dict, origin: dict = ...) -> None:
2841
+ """Applies a force vector to the group."""
2842
+ ...
2843
+
2844
+ def applyForce(self, force: dict, origin: dict = ...) -> None:
2845
+ ...
2846
+
2847
+ @overload
2848
+ def applyForceScaled(self, amount: float, origin: dict = ...) -> None:
2849
+ """Applies a force scaled to member masses using a magnitude."""
2850
+ ...
2851
+
2852
+ @overload
2853
+ def applyForceScaled(self, force: dict, origin: dict = ...) -> None:
2854
+ """Applies a force scaled to member masses using a vector."""
2855
+ ...
2856
+
2857
+ def applyForceScaled(self, force: dict, origin: dict = ...) -> None:
2858
+ ...
2859
+
2860
+ def applyWind(self, speed: float, angle: float, drag: float = ..., lift: float = ...) -> None:
2861
+ ...
2862
+
2863
+ @overload
2864
+ def attractTo(self, x: float, y: float, force: float = ...) -> None:
2865
+ """
2866
+ Applies a force to the group's center of mass attracting it to
2867
+ the given position.
2868
+ """
2869
+ ...
2870
+
2871
+ @overload
2872
+ def attractTo(self, pos: dict, force: float = ...) -> None:
2873
+ """
2874
+ Applies a force to the group's center of mass attracting it to
2875
+ the given position.
2876
+ """
2877
+ ...
2878
+
2879
+ def attractTo(self, pos: dict, force: float = ...) -> None:
2880
+ ...
2881
+
2882
+ def applyTorque(self, torque: Any) -> None:
2883
+ ...
2884
+
2885
+ @overload
2886
+ def moveTo(self, x: float | None, y: float | None, speed: float = ...) -> Awaitable[bool]:
2887
+ """
2888
+ Moves each sprite in the group to a destination at a constant speed,
2889
+ maintaining their relative offsets from the group's centroid.
2890
+ """
2891
+ ...
2892
+
2893
+ @overload
2894
+ def moveTo(self, pos: dict, speed: float = ...) -> Awaitable[bool]:
2895
+ """
2896
+ Moves each sprite in the group to a destination at a constant speed,
2897
+ maintaining their relative offsets from the group's centroid.
2898
+ """
2899
+ ...
2900
+
2901
+ def moveTo(self, pos: dict, speed: float = ...) -> Awaitable[bool]:
2902
+ ...
2903
+
2904
+ @overload
2905
+ def moveTowards(self, x: float | None, y: float | None, tracking: float = ...) -> None:
2906
+ """Moves the group towards a position."""
2907
+ ...
2908
+
2909
+ @overload
2910
+ def moveTowards(self, pos: dict, tracking: float = ...) -> None:
2911
+ """Moves the group towards a position."""
2912
+ ...
2913
+
2914
+ def moveTowards(self, pos: dict, tracking: float = ...) -> None:
2915
+ ...
2916
+
2917
+ @overload
2918
+ def rotateTo(self, angle: float, speed: float = ...) -> Awaitable[bool]:
2919
+ """
2920
+ Rotates each sprite in the group to a target angle. The sign of `speed`
2921
+ determines direction: positive = CW, negative = CCW.
2922
+ """
2923
+ ...
2924
+
2925
+ @overload
2926
+ def rotateTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
2927
+ """
2928
+ Rotates each sprite in the group to face a position. The sign of `speed`
2929
+ determines direction: positive = CW, negative = CCW.
2930
+ """
2931
+ ...
2932
+
2933
+ def rotateTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
2934
+ ...
2935
+
2936
+ def rotate(self, angle: float, speed: float = ...) -> Awaitable[bool]:
2937
+ """Rotates each sprite in the group by the given angle amount at the given speed."""
2938
+ ...
2939
+
2940
+ @overload
2941
+ def rotateMinTo(self, angle: float, speed: float = ...) -> Awaitable[bool]:
2942
+ """
2943
+ Rotates each sprite in the group by the smallest angular distance to
2944
+ a target angle, stopping when they arrive.
2945
+ """
2946
+ ...
2947
+
2948
+ @overload
2949
+ def rotateMinTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
2950
+ """
2951
+ Rotates each sprite in the group by the smallest angular distance to
2952
+ face a position, stopping when they arrive.
2953
+ """
2954
+ ...
2955
+
2956
+ def rotateMinTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
2957
+ ...
2958
+
2959
+ @overload
2960
+ def rotateTowards(self, angle: float, tracking: float = ...) -> None:
2961
+ """Rotates each sprite in the group towards an angle."""
2962
+ ...
2963
+
2964
+ @overload
2965
+ def rotateTowards(self, pos: dict, tracking: float = ..., facing: float = ...) -> None:
2966
+ """Rotates each sprite in the group towards a position."""
2967
+ ...
2968
+
2969
+ def rotateTowards(self, pos: dict, tracking: float = ..., facing: float = ...) -> None:
2970
+ ...
2971
+
2972
+ @overload
2973
+ def transformTowards(self, x: float, y: float, rotation: float = ..., tracking: float = ...) -> None:
2974
+ """
2975
+ Moves and rotates each sprite in the group towards a target transform,
2976
+ maintaining their relative offsets from the group's centroid.
2977
+ """
2978
+ ...
2979
+
2980
+ @overload
2981
+ def transformTowards(self, pos: dict, rotation: float = ..., tracking: float = ...) -> None:
2982
+ """
2983
+ Moves and rotates each sprite in the group towards a target transform,
2984
+ maintaining their relative offsets from the group's centroid.
2985
+ """
2986
+ ...
2987
+
2988
+ def transformTowards(self, pos: dict, rotation: float = ..., tracking: float = ...) -> None:
2989
+ ...
2990
+
2991
+ @overload
2992
+ def repelFrom(self, x: float, y: float, force: float = ...) -> None:
2993
+ """Applies a repelling force from a position."""
2994
+ ...
2995
+
2996
+ @overload
2997
+ def repelFrom(self, pos: dict, force: float = ...) -> None:
2998
+ """Applies a repelling force from a position."""
2999
+ ...
3000
+
3001
+ def repelFrom(self, pos: dict, force: float = ...) -> None:
3002
+ ...
3003
+
3004
+ def cull(self, top: float = ..., bottom: float = ..., left: float = ..., right: float = ..., cb: Callable[..., Any] = ...) -> float:
3005
+ """
3006
+ Detects when sprites go outside the given culling boundary
3007
+ relative to the camera.
3008
+
3009
+ By default, culled sprites are deleted, but a callback function
3010
+ can be provided to perform other operations on the culled sprites.
3011
+
3012
+ Args:
3013
+ top: the distance that sprites can move below the canvas before they are removed
3014
+ bottom: the distance that sprites can move below the canvas before they are removed
3015
+ left: the distance that sprites can move beyond the left side of the canvas before they are removed
3016
+ right: the distance that sprites can move beyond the right side of the canvas before they are removed
3017
+ cb: the function to be run when a sprite is culled, it's given the sprite being culled, if no callback is given then the sprite is removed
3018
+
3019
+ Returns:
3020
+ the number of sprites culled
3021
+ """
3022
+ ...
3023
+
3024
+ def splice(self, start: float, removalCount: float, *sprites: Sprite) -> list[Sprite]:
3025
+ """
3026
+ If removalCount is greater than 0, that amount of
3027
+ sprites starting from the start index will be removed
3028
+ from this group and its sub groups recursively (if any),
3029
+
3030
+ Then any provided sprites will be added at the start index
3031
+ to this group and at the end of each of its parent groups recursively,
3032
+ if not already present in parent groups.
3033
+
3034
+ Args:
3035
+ start: start index
3036
+ removalCount: number of sprites to remove, starting from the start index
3037
+ sprites: sprites to add at start index
3038
+
3039
+ Returns:
3040
+ the removed sprites
3041
+ """
3042
+ ...
3043
+
3044
+ def remove(self, item: Sprite | float) -> Sprite: # type: ignore[override]
3045
+ """
3046
+ Removes a sprite from this group and its sub groups (if any),
3047
+ but does not delete it from the world.
3048
+
3049
+ Args:
3050
+ item: the sprite to be deleted or its index
3051
+
3052
+ Returns:
3053
+ the deleted sprite or undefined if the specified sprite was not found
3054
+ """
3055
+ ...
3056
+
3057
+ def removeAll(self) -> list[Sprite]:
3058
+ """
3059
+ Removes all sprites from this group without deleting them.
3060
+
3061
+ Returns:
3062
+ the removed sprites
3063
+ """
3064
+ ...
3065
+
3066
+ def delete(self) -> None:
3067
+ """
3068
+ Deletes the group and all its sprites
3069
+ from the world and every other group they belong to.
3070
+
3071
+ Don't attempt to use a group after deleting it.
3072
+ """
3073
+ ...
3074
+
3075
+ def deleteAll(self) -> None:
3076
+ """
3077
+ Deletes all the sprites in the group.
3078
+
3079
+ Does not delete the group itself.
3080
+ """
3081
+ ...
3082
+
3083
+ def update(self) -> None:
3084
+ """Updates all the sprites in the group."""
3085
+ ...
3086
+
3087
+ def draw(self) -> None:
3088
+ """Draws all the sprites in the group."""
3089
+ ...
3090
+
3091
+ class World:
3092
+ """The World is the Box2D physics simulation."""
3093
+
3094
+ @property
3095
+ def gravity(self) -> Any:
3096
+ """
3097
+ Gravity force vector that affects all dynamic physics colliders.
3098
+
3099
+ Default: `{ x: 0, y: 0 }`
3100
+ """
3101
+ ...
3102
+
3103
+ @gravity.setter
3104
+ def gravity(self, val: Any) -> None: ...
3105
+
3106
+ @property
3107
+ def bounceThreshold(self) -> float:
3108
+ """
3109
+ The lowest velocity an object can have before it is considered
3110
+ to be at rest.
3111
+
3112
+ Adjust the bounce threshold to allow for slow moving objects
3113
+ but don't have it be too low, or else objects will never sleep,
3114
+ which will hurt performance.
3115
+
3116
+ Default: `0.19`
3117
+ """
3118
+ ...
3119
+
3120
+ @bounceThreshold.setter
3121
+ def bounceThreshold(self, val: float) -> None: ...
3122
+
3123
+ physicsTime: float
3124
+ """The time elapsed in the physics simulation in seconds."""
3125
+
3126
+ meterSize: float
3127
+ """
3128
+ Represents the size of a meter in pixels.
3129
+
3130
+ Adjusting this property changes the simulated scale of the physics world.
3131
+ For optimal results, it should be set such that sprites are between
3132
+ 0.1 and 10 meters in size in the physics simulation.
3133
+
3134
+ The default value is 60, which means that your sprites should optimally
3135
+ be between 6 and 600 pixels in size.
3136
+
3137
+ Default: `60`
3138
+ """
3139
+
3140
+ autoStep: bool
3141
+ """
3142
+
3143
+ Default: `true`
3144
+ """
3145
+
3146
+ def physicsUpdate(self, timeStep: float = ...) -> None:
3147
+ """
3148
+ Performs a physics simulation step that advances all sprites
3149
+ forward in time by 1 / updateRate * timeScale if no timeStep is given.
3150
+ """
3151
+ ...
3152
+
3153
+ @property
3154
+ def timeScale(self) -> float:
3155
+ """
3156
+ A time scale of 1.0 represents real time.
3157
+ Accepts decimal values between 0 and 2.
3158
+
3159
+ Default: `1.0`
3160
+ """
3161
+ ...
3162
+
3163
+ @timeScale.setter
3164
+ def timeScale(self, val: float) -> None: ...
3165
+
3166
+ @property
3167
+ def updateRate(self) -> float:
3168
+ """
3169
+ The fixed update rate of the physics simulation in hertz.
3170
+
3171
+ The time step, the amount of time that passes during a
3172
+ physics update, is calculated to be: 1 / updateRate * timeScale
3173
+
3174
+ Setting the update rate to a value lower than 50hz is not
3175
+ recommended, as simulation quality will degrade.
3176
+
3177
+ Default: `60`
3178
+ """
3179
+ ...
3180
+
3181
+ @updateRate.setter
3182
+ def updateRate(self, val: float) -> None: ...
3183
+
3184
+ @property
3185
+ def realTime(self) -> float:
3186
+ """
3187
+ The real time in seconds since the world was created, including
3188
+ time spent paused.
3189
+ """
3190
+ ...
3191
+
3192
+ @overload
3193
+ def getSpritesAt(self, x: float, y: float, radius: float = ..., group: Group = ..., cameraActiveWhenDrawn: bool = ...) -> list[Sprite]:
3194
+ """
3195
+ Returns the sprites at a position, ordered by layer.
3196
+
3197
+ Sprites must have a physics body to be detected.
3198
+
3199
+ Args:
3200
+ x: x coordinate or object with x and y properties
3201
+ radius: the distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
3202
+ group: limit results to a specific group, allSprites by default
3203
+ cameraActiveWhenDrawn: limit results to sprites drawn when the camera was active, true by default
3204
+
3205
+ Returns:
3206
+ an array of sprites
3207
+ """
3208
+ ...
3209
+
3210
+ @overload
3211
+ def getSpritesAt(self, pos: dict, radius: float = ..., group: Group = ..., cameraActiveWhenDrawn: bool = ...) -> list[Sprite]:
3212
+ """
3213
+ Returns the sprites at a position, ordered by layer.
3214
+
3215
+ Sprites must have a physics body to be detected.
3216
+
3217
+ Args:
3218
+ pos: object with x and y properties
3219
+ radius: the distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
3220
+ group: limit results to a specific group, allSprites by default
3221
+ cameraActiveWhenDrawn: limit results to sprites drawn when the camera was active, true by default
3222
+
3223
+ Returns:
3224
+ an array of sprites
3225
+ """
3226
+ ...
3227
+
3228
+ def getSpritesAt(self, pos: dict, radius: float = ..., group: Group = ..., cameraActiveWhenDrawn: bool = ...) -> list[Sprite]:
3229
+ ...
3230
+
3231
+ @overload
3232
+ def getSpriteAt(self, x: float, y: float, radius: float = ..., group: Group = ...) -> Sprite:
3233
+ """
3234
+ Returns the sprite at the specified position
3235
+ on the top most layer, drawn when the camera was on.
3236
+
3237
+ The sprite must have a physics body to be detected.
3238
+
3239
+ Args:
3240
+ x: x coordinate or object with x and y properties
3241
+ radius: the distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
3242
+ group: the group to search
3243
+
3244
+ Returns:
3245
+ a sprite
3246
+ """
3247
+ ...
3248
+
3249
+ @overload
3250
+ def getSpriteAt(self, pos: dict, radius: float = ..., group: Group = ...) -> Sprite:
3251
+ """
3252
+ Returns the sprite at the specified position
3253
+ on the top most layer, drawn when the camera was on.
3254
+
3255
+ The sprite must have a physics body to be detected.
3256
+
3257
+ Args:
3258
+ pos: object with x and y properties
3259
+ radius: the distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
3260
+ group: the group to search
3261
+
3262
+ Returns:
3263
+ a sprite
3264
+ """
3265
+ ...
3266
+
3267
+ def getSpriteAt(self, pos: dict, radius: float = ..., group: Group = ...) -> Sprite:
3268
+ ...
3269
+
3270
+ @property
3271
+ def allowSleeping(self) -> bool:
3272
+ """
3273
+ "Sleeping" sprites get temporarily ignored during physics
3274
+ simulation. A sprite starts "sleeping" when it stops moving and
3275
+ doesn't collide with anything that it wasn't already touching.
3276
+
3277
+ This is an important performance optimization that you probably
3278
+ shouldn't disable for every sprite in the world.
3279
+
3280
+ Default: `true`
3281
+ """
3282
+ ...
3283
+
3284
+ @allowSleeping.setter
3285
+ def allowSleeping(self, val: bool) -> None: ...
3286
+
3287
+ @overload
3288
+ def rayCast(self, startPos: list[dict | float], direction: float, maxDistance: float = ...) -> Sprite:
3289
+ """
3290
+ Finds the first sprite (with a physics body) that
3291
+ intersects a ray (line).
3292
+
3293
+ Args:
3294
+ startPos: starting position of the ray cast, object with x and y properties or array [x, y]
3295
+ direction: direction angle of the ray
3296
+ maxDistance: max distance the ray should check, default 10000
3297
+
3298
+ Returns:
3299
+ The first sprite the ray hits or undefined
3300
+ """
3301
+ ...
3302
+
3303
+ @overload
3304
+ def rayCast(self, startPos: list[dict | float], endPos: list[dict | float]) -> Sprite:
3305
+ """
3306
+ Finds the first sprite (with a physics body) that
3307
+ intersects a ray from startPos to endPos.
3308
+
3309
+ Args:
3310
+ startPos: starting position of the ray cast
3311
+ endPos: end position of the ray cast
3312
+
3313
+ Returns:
3314
+ The first sprite the ray hits or undefined
3315
+ """
3316
+ ...
3317
+
3318
+ def rayCast(self, startPos: list[dict | float], endPos: list[dict | float]) -> Sprite:
3319
+ ...
3320
+
3321
+ @overload
3322
+ def rayCastAll(self, startPos: list[dict | float], direction: float, maxDistance: float = ..., limiter: Callable[..., Any] = ...) -> list[Sprite]:
3323
+ """
3324
+ Finds all sprites (with physics bodies) that intersect
3325
+ a ray (line), sorted by distance.
3326
+
3327
+ Args:
3328
+ startPos: starting position of the ray cast, object with x and y properties or array [x, y]
3329
+ direction: direction angle of the ray
3330
+ maxDistance: max distance the ray should check, default 10000
3331
+ limiter: callback run each time the ray hits a sprite; return true to stop the ray
3332
+
3333
+ Returns:
3334
+ An array of sprites that the ray cast hit, sorted by distance. The sprite closest to the starting point will be at index 0. If a limiter is provided, this array includes the sprite that caused the ray to stop.
3335
+ """
3336
+ ...
3337
+
3338
+ @overload
3339
+ def rayCastAll(self, startPos: list[dict | float], endPos: list[dict | float], limiter: Callable[..., Any] = ...) -> list[Sprite]:
3340
+ """
3341
+ Finds all sprites (with physics bodies) that intersect
3342
+ a ray from startPos to endPos, sorted by distance.
3343
+
3344
+ Args:
3345
+ startPos: starting position of the ray cast
3346
+ endPos: end position of the ray cast
3347
+ limiter: callback run each time the ray hits a sprite; return true to stop the ray
3348
+
3349
+ Returns:
3350
+ An array of sprites that the ray cast hit, sorted by distance.
3351
+ """
3352
+ ...
3353
+
3354
+ def rayCastAll(self, startPos: list[dict | float], endPos: list[dict | float], limiter: Callable[..., Any] = ...) -> list[Sprite]:
3355
+ ...
3356
+
3357
+ def circleCast(self, startPos: list[dict | float], endPos: list[dict | float], radius: float) -> Sprite:
3358
+ """
3359
+ Finds the first sprite (with a physics body) that
3360
+ intersects a swept circle (capsule cast) from startPos to endPos.
3361
+
3362
+ Args:
3363
+ startPos: starting position of the cast, object with x and y properties or array [x, y]
3364
+ endPos: end position of the cast
3365
+ radius: radius of the circle
3366
+
3367
+ Returns:
3368
+ The first sprite hit or undefined
3369
+ """
3370
+ ...
3371
+
3372
+ def circleCastAll(self, startPos: list[dict | float], endPos: list[dict | float], radius: float, limiter: Callable[..., Any] = ...) -> list[Sprite]:
3373
+ """
3374
+ Finds all sprites (with physics bodies) that intersect
3375
+ a swept circle (capsule cast) from startPos to endPos, sorted by distance.
3376
+
3377
+ Args:
3378
+ startPos: starting position of the cast
3379
+ endPos: end position of the cast
3380
+ radius: radius of the circle
3381
+ limiter: callback run each time the cast hits a sprite; return true to stop the cast
3382
+
3383
+ Returns:
3384
+ An array of sprites hit, sorted by distance.
3385
+ """
3386
+ ...
3387
+
3388
+ @overload
3389
+ def explodeAt(self, x: float, y: float, radius: float = ..., magnitude: float = ..., falloff: float = ...) -> None:
3390
+ """
3391
+ Applies an explosive force to sprites within the radius of the explosion.
3392
+
3393
+ Args:
3394
+ x: x coordinate or object with x and y properties of the center of the explosion
3395
+ radius: the distance from the center of the explosion that sprites can be affected by the explosion
3396
+ magnitude: the strength of the explosion force, default is 1
3397
+ falloff: how much the explosion force decreases as sprites are farther from the center of the explosion, default is 0.1 (10% decrease per pixel)
3398
+ """
3399
+ ...
3400
+
3401
+ @overload
3402
+ def explodeAt(self, pos: dict, radius: float = ..., magnitude: float = ..., falloff: float = ...) -> None:
3403
+ ...
3404
+
3405
+ def explodeAt(self, pos: dict, radius: float = ..., magnitude: float = ..., falloff: float = ...) -> None:
3406
+ ...
3407
+
3408
+ @property
3409
+ def awakeBodies(self) -> float:
3410
+ """The number of physics bodies currently awake in the world."""
3411
+ ...
3412
+
3413
+ @property
3414
+ def hitThreshold(self) -> float:
3415
+ """The minimum impact velocity needed for a hit event to be fired."""
3416
+ ...
3417
+
3418
+ @hitThreshold.setter
3419
+ def hitThreshold(self, val: float) -> None: ...
3420
+
3421
+ @property
3422
+ def profile(self) -> Any:
3423
+ """Box2D world performance profile data."""
3424
+ ...
3425
+
3426
+ @property
3427
+ def debugInfo(self) -> Any:
3428
+ """Box2D world counter/statistics data."""
3429
+ ...
3430
+
3431
+ subSteps: float
3432
+ """
3433
+ The number of sub-steps per physics update.
3434
+ More sub-steps increases accuracy at the cost of performance.
3435
+
3436
+ Default: `4`
3437
+ """
3438
+
3439
+ def step(self, timeStep: float = ...) -> None:
3440
+ """Alias for `physicsUpdate`."""
3441
+ ...
3442
+
3443
+ wID: Any
3444
+ """The Box2D world ID. Don't change it!"""
3445
+
3446
+ class Camera:
3447
+ """The Camera controls the position and zoom of the view of the world that is drawn on the canvas."""
3448
+
3449
+ isActive: bool
3450
+ """
3451
+ Read only. True if the camera is active.
3452
+ Use camera.on() to activate the camera.
3453
+
3454
+ Default: `false`
3455
+ """
3456
+
3457
+ @property
3458
+ def x(self) -> float:
3459
+ """The camera's x position."""
3460
+ ...
3461
+
3462
+ @x.setter
3463
+ def x(self, val: float) -> None: ...
3464
+
3465
+ @property
3466
+ def y(self) -> float:
3467
+ """The camera's y position."""
3468
+ ...
3469
+
3470
+ @y.setter
3471
+ def y(self, val: float) -> None: ...
3472
+
3473
+ @property
3474
+ def pos(self) -> dict:
3475
+ """
3476
+ Gets the camera's position as a readonly {x, y} object that
3477
+ won't be updated if the camera moves. Useful for saving the
3478
+ camera's position at a specific moment in time.
3479
+ """
3480
+ ...
3481
+
3482
+ @pos.setter
3483
+ def pos(self, val: list[float] | dict) -> None: ...
3484
+
3485
+ @property
3486
+ def position(self) -> Vector:
3487
+ """The camera's position vector."""
3488
+ ...
3489
+
3490
+ @position.setter
3491
+ def position(self, val: list[float] | dict) -> None: ...
3492
+
3493
+ def moveTo(self, x: float, y: float, speed: float) -> Awaitable[bool]:
3494
+ """
3495
+ Moves the camera to a position.
3496
+
3497
+ Returns:
3498
+ resolves true when the camera reaches the target position
3499
+ """
3500
+ ...
3501
+
3502
+ @property
3503
+ def zoom(self) -> float:
3504
+ """
3505
+ Camera zoom.
3506
+
3507
+ A scale of 1 will be the normal size. Setting it to 2
3508
+ will make everything appear twice as big. .5 will make
3509
+ everything look half size.
3510
+
3511
+ Default: `1`
3512
+ """
3513
+ ...
3514
+
3515
+ @zoom.setter
3516
+ def zoom(self, val: float) -> None: ...
3517
+
3518
+ def zoomTo(self, target: float, speed: float) -> Awaitable[bool]:
3519
+ """
3520
+ Zoom the camera at a given speed.
3521
+
3522
+ Args:
3523
+ target: The target zoom
3524
+ speed: The amount of zoom per frame
3525
+
3526
+ Returns:
3527
+ resolves true when the camera reaches the target zoom
3528
+ """
3529
+ ...
3530
+
3531
+ def on(self) -> None:
3532
+ """
3533
+ Activates the camera.
3534
+
3535
+ The canvas will be drawn according to the camera position and scale until
3536
+ camera.off() is called.
3537
+ """
3538
+ ...
3539
+
3540
+ def off(self) -> None:
3541
+ """
3542
+ Deactivates the camera.
3543
+
3544
+ The canvas will be drawn normally, ignoring the camera's position
3545
+ and scale until camera.on() is called.
3546
+ """
3547
+ ...
3548
+
3549
+ class Joint:
3550
+ """
3551
+ A Joint is used to constrain the movement of two sprites relative
3552
+ to each other, which can lead to nuanced physics interactions.
3553
+ """
3554
+
3555
+ @classmethod
3556
+ def new(cls, spriteA: Sprite, spriteB: Sprite, type_: str = ...) -> 'Joint':
3557
+ """
3558
+ Don't use the Joint constructor directly, use one of these
3559
+ joint constructors instead:
3560
+
3561
+ GlueJoint, DistanceJoint, WheelJoint, HingeJoint,
3562
+ SliderJoint, or GrabberJoint.
3563
+ """
3564
+ ...
3565
+
3566
+ def __init__(self, spriteA: Sprite, spriteB: Sprite, type_: str = ...) -> None: ...
3567
+
3568
+ spriteA: Sprite
3569
+ """The first sprite in the joint."""
3570
+
3571
+ spriteB: Sprite
3572
+ """The second sprite in the joint."""
3573
+
3574
+ type: str
3575
+ """
3576
+ The type of joint. Can be one of:
3577
+
3578
+ "glue", "distance", "wheel", "hinge", "slider", or "grabber".
3579
+
3580
+ Can't be changed after the joint is created.
3581
+ """
3582
+
3583
+ visible: bool
3584
+ """
3585
+ Determines whether to draw the joint if spriteA
3586
+ or spriteB is drawn.
3587
+
3588
+ Default: `true`
3589
+ """
3590
+
3591
+ @property
3592
+ def offsetA(self) -> Vector:
3593
+ """
3594
+ Offset to the joint's anchorA position from the center of spriteA.
3595
+
3596
+ Only distance and hinge joints have an offsetA.
3597
+
3598
+ Default: `{x: 0, y: 0}`
3599
+ """
3600
+ ...
3601
+
3602
+ @offsetA.setter
3603
+ def offsetA(self, val: list | dict | Vector) -> None: ...
3604
+
3605
+ @property
3606
+ def offsetB(self) -> Vector:
3607
+ """
3608
+ Offset to the joint's anchorB position from the center of spriteB.
3609
+
3610
+ Only distance, hinge, and wheel joints have an offsetB.
3611
+
3612
+ Default: `{x: 0, y: 0}`
3613
+ """
3614
+ ...
3615
+
3616
+ @offsetB.setter
3617
+ def offsetB(self, val: list | dict | Vector) -> None: ...
3618
+
3619
+ @property
3620
+ def draw(self) -> Callable[..., Any]:
3621
+ """Function that draws the joint. Can be overridden by the user."""
3622
+ ...
3623
+
3624
+ @draw.setter
3625
+ def draw(self, val: Callable[..., Any]) -> None: ...
3626
+
3627
+ @property
3628
+ def collideConnected(self) -> bool:
3629
+ """
3630
+ Set to true if you want the joint's sprites to collide with
3631
+ each other.
3632
+
3633
+ Default: `false`
3634
+ """
3635
+ ...
3636
+
3637
+ @collideConnected.setter
3638
+ def collideConnected(self, val: bool) -> None: ...
3639
+
3640
+ @property
3641
+ def reactionForce(self) -> Any:
3642
+ """How much force the joint is applying to keep the two sprites together."""
3643
+ ...
3644
+
3645
+ @property
3646
+ def reactionTorque(self) -> Any:
3647
+ """How much torque the joint is applying to keep the two sprites together."""
3648
+ ...
3649
+
3650
+ @property
3651
+ def forceThreshold(self) -> float:
3652
+ """
3653
+ The amount of force that must be applied to the joint before it breaks.
3654
+
3655
+ Setting the threshold too high leads to instability. Use
3656
+ `sprite.addCollider` to simulate unbreakable bonds between shapes.
3657
+
3658
+ Default: `500`
3659
+ """
3660
+ ...
3661
+
3662
+ @forceThreshold.setter
3663
+ def forceThreshold(self, val: float) -> None: ...
3664
+
3665
+ @property
3666
+ def torqueThreshold(self) -> float:
3667
+ """
3668
+ The amount of torque that must be applied to the joint before it breaks.
3669
+
3670
+ Setting the threshold too high leads to instability. Use
3671
+ `sprite.addCollider` to simulate unbreakable bonds between shapes.
3672
+
3673
+ Default: `500`
3674
+ """
3675
+ ...
3676
+
3677
+ @torqueThreshold.setter
3678
+ def torqueThreshold(self, val: float) -> None: ...
3679
+
3680
+ def onStrain(self) -> None:
3681
+ """
3682
+ This function is run when the joint's reaction force exceeds the
3683
+ force threshold or its reaction torque exceeds the torque threshold.
3684
+
3685
+ By default, the sprites' speed and rotation speed are set to 0
3686
+ and the joint is deleted, simulating a break.
3687
+ """
3688
+ ...
3689
+
3690
+ def delete(self) -> None:
3691
+ """
3692
+ Deletes the joint from the world and from each of the
3693
+ associated sprites' joints arrays.
3694
+ """
3695
+ ...
3696
+
3697
+ jID: Any
3698
+ """The Box2D joint ID. Don't change it!"""
3699
+
3700
+ class GlueJoint(Joint):
3701
+
3702
+ def __init__(self, spriteA: Sprite, spriteB: Sprite) -> None: ...
3703
+
3704
+ @property
3705
+ def springiness(self) -> float:
3706
+ ...
3707
+
3708
+ @springiness.setter
3709
+ def springiness(self, val: float) -> None: ...
3710
+
3711
+ @property
3712
+ def damping(self) -> float:
3713
+ ...
3714
+
3715
+ @damping.setter
3716
+ def damping(self, val: float) -> None: ...
3717
+
3718
+ class DistanceJoint(Joint):
3719
+
3720
+ def __init__(self, spriteA: Sprite, spriteB: Sprite) -> None: ...
3721
+
3722
+ @property
3723
+ def currentLength(self) -> float:
3724
+ """The current distance between the two joint anchors."""
3725
+ ...
3726
+
3727
+ @property
3728
+ def length(self) -> float:
3729
+ """
3730
+ The target length of the joint between the two joint anchors.
3731
+
3732
+ It's set to the current distance between the two sprites
3733
+ when the joint is created.
3734
+ """
3735
+ ...
3736
+
3737
+ @length.setter
3738
+ def length(self, val: float) -> None: ...
3739
+
3740
+ @property
3741
+ def limitsEnabled(self) -> bool:
3742
+ """
3743
+ Whether the joint's length limits are enabled.
3744
+ When enabled a min/max length range constrains the joint.
3745
+
3746
+ Default: `false`
3747
+ """
3748
+ ...
3749
+
3750
+ @limitsEnabled.setter
3751
+ def limitsEnabled(self, val: bool) -> None: ...
3752
+
3753
+ @property
3754
+ def minLength(self) -> float:
3755
+ """The minimum length allowed when limits are enabled."""
3756
+ ...
3757
+
3758
+ @property
3759
+ def maxLength(self) -> float:
3760
+ """The maximum length allowed when limits are enabled."""
3761
+ ...
3762
+
3763
+ @property
3764
+ def range(self) -> Any:
3765
+ """
3766
+ Accepts a number to set a symmetric range
3767
+ or an array with the minimum and maximum length limits.
3768
+ """
3769
+ ...
3770
+
3771
+ @range.setter
3772
+ def range(self, val: tuple[float, float] | float) -> None: ...
3773
+
3774
+ @property
3775
+ def springEnabled(self) -> bool:
3776
+ """
3777
+ Whether spring behavior is enabled for the joint.
3778
+
3779
+ Default: `true`
3780
+ """
3781
+ ...
3782
+
3783
+ @springEnabled.setter
3784
+ def springEnabled(self, val: bool) -> None: ...
3785
+
3786
+ @property
3787
+ def springiness(self) -> float:
3788
+ """
3789
+ The springiness of the joint, a 0-1 ratio.
3790
+
3791
+ 0 is rigid, 0.5 is bouncy, 1 is loose.
3792
+
3793
+ Default: `0`
3794
+ """
3795
+ ...
3796
+
3797
+ @springiness.setter
3798
+ def springiness(self, val: float) -> None: ...
3799
+
3800
+ @property
3801
+ def damping(self) -> float:
3802
+ """
3803
+ Damping is a 0-1 ratio describing how quickly the joint loses
3804
+ vibrational energy.
3805
+
3806
+ 0.0 means no damping, 1.0 means critical damping, which will stop
3807
+ the joint from vibrating at all.
3808
+
3809
+ Damping only effects joints that have a
3810
+ springiness greater than 0.
3811
+
3812
+ Default: `0.0`
3813
+ """
3814
+ ...
3815
+
3816
+ @damping.setter
3817
+ def damping(self, val: float) -> None: ...
3818
+
3819
+ @property
3820
+ def motorEnabled(self) -> bool:
3821
+ """
3822
+ Whether the joint's motor is enabled.
3823
+
3824
+ Default: `false`
3825
+ """
3826
+ ...
3827
+
3828
+ @motorEnabled.setter
3829
+ def motorEnabled(self, val: bool) -> None: ...
3830
+
3831
+ @property
3832
+ def speed(self) -> float:
3833
+ """
3834
+ Motor speed.
3835
+
3836
+ Default: `0`
3837
+ """
3838
+ ...
3839
+
3840
+ @speed.setter
3841
+ def speed(self, val: float) -> None: ...
3842
+
3843
+ @property
3844
+ def maxPower(self) -> float:
3845
+ """Maximum motor force the motor can apply."""
3846
+ ...
3847
+
3848
+ @maxPower.setter
3849
+ def maxPower(self, val: float) -> None: ...
3850
+
3851
+ @property
3852
+ def power(self) -> float:
3853
+ """The current motor force being applied by the joint."""
3854
+ ...
3855
+
3856
+ class WheelJoint(Joint):
3857
+
3858
+ def __init__(self, spriteA: Sprite, spriteB: Sprite) -> None: ...
3859
+
3860
+ @property
3861
+ def angle(self) -> float:
3862
+ """
3863
+ The angle at which the wheel is attached to the vehicle body.
3864
+
3865
+ The default is 90 degrees (PI/2 in radians).
3866
+
3867
+ Default: `90`
3868
+ """
3869
+ ...
3870
+
3871
+ @angle.setter
3872
+ def angle(self, val: float) -> None: ...
3873
+
3874
+ @property
3875
+ def limitsEnabled(self) -> bool:
3876
+ """
3877
+ Whether the joint's suspension limits are enabled.
3878
+ When enabled a min/max distance from resting constrains the joint.
3879
+
3880
+ Default: `false`
3881
+ """
3882
+ ...
3883
+
3884
+ @limitsEnabled.setter
3885
+ def limitsEnabled(self, val: bool) -> None: ...
3886
+
3887
+ @property
3888
+ def lowerLimit(self) -> float:
3889
+ """
3890
+ The minimum distance the wheel's suspension can contract
3891
+ from 0, which represents the resting position,
3892
+ when limits are enabled.
3893
+ """
3894
+ ...
3895
+
3896
+ @property
3897
+ def upperLimit(self) -> float:
3898
+ """
3899
+ The maximum distance the wheel's suspension can extend
3900
+ from 0, which represents the resting position,
3901
+ when limits are enabled.
3902
+ """
3903
+ ...
3904
+
3905
+ @property
3906
+ def range(self) -> Any:
3907
+ """
3908
+ The distance the wheel's suspension can contract or extend
3909
+ from 0, which represents the resting position.
3910
+
3911
+ Accepts a number to set a symmetric range
3912
+ or an array with the minimum and maximum length limits.
3913
+ """
3914
+ ...
3915
+
3916
+ @range.setter
3917
+ def range(self, val: tuple[float, float] | float) -> None: ...
3918
+
3919
+ @property
3920
+ def springEnabled(self) -> bool:
3921
+ """
3922
+ Whether the wheel joint has suspension,
3923
+ which can make it ride smoother over bumps.
3924
+
3925
+ Default: `true`
3926
+ """
3927
+ ...
3928
+
3929
+ @springEnabled.setter
3930
+ def springEnabled(self, val: bool) -> None: ...
3931
+
3932
+ @property
3933
+ def springiness(self) -> float:
3934
+ """
3935
+ The springiness of the joint, a 0-1 ratio.
3936
+
3937
+ 0.0 is rigid, 0.5 is bouncy, 1.0 is loose.
3938
+
3939
+ Default: `0.0`
3940
+ """
3941
+ ...
3942
+
3943
+ @springiness.setter
3944
+ def springiness(self, val: float) -> None: ...
3945
+
3946
+ @property
3947
+ def damping(self) -> float:
3948
+ """
3949
+ Damping is a 0-1 ratio describing how quickly the joint loses
3950
+ vibrational energy.
3951
+
3952
+ 0.0 means no damping, 1.0 means critical damping, which will stop
3953
+ the joint from vibrating at all.
3954
+
3955
+ Damping only effects joints that have a
3956
+ springiness greater than 0.
3957
+
3958
+ Default: `0.0`
3959
+ """
3960
+ ...
3961
+
3962
+ @damping.setter
3963
+ def damping(self, val: float) -> None: ...
3964
+
3965
+ @property
3966
+ def motorEnabled(self) -> bool:
3967
+ """
3968
+ Whether the joint's motor is enabled.
3969
+
3970
+ Default: `false`
3971
+ """
3972
+ ...
3973
+
3974
+ @motorEnabled.setter
3975
+ def motorEnabled(self, val: bool) -> None: ...
3976
+
3977
+ @property
3978
+ def speed(self) -> float:
3979
+ """
3980
+ Motor speed.
3981
+
3982
+ Default: `0`
3983
+ """
3984
+ ...
3985
+
3986
+ @speed.setter
3987
+ def speed(self, val: float) -> None: ...
3988
+
3989
+ @property
3990
+ def maxPower(self) -> float:
3991
+ """Maximum torque the motor can apply."""
3992
+ ...
3993
+
3994
+ @maxPower.setter
3995
+ def maxPower(self, val: float) -> None: ...
3996
+
3997
+ @property
3998
+ def power(self) -> float:
3999
+ """The current torque being applied by the motor."""
4000
+ ...
4001
+
4002
+ class HingeJoint(Joint):
4003
+
4004
+ def __init__(self, spriteA: Sprite, spriteB: Sprite) -> None: ...
4005
+
4006
+ @property
4007
+ def limitsEnabled(self) -> bool:
4008
+ """
4009
+ Whether the joint's angle limits are enabled.
4010
+ When enabled a min/max angle range constrains the joint.
4011
+
4012
+ Default: `false`
4013
+ """
4014
+ ...
4015
+
4016
+ @limitsEnabled.setter
4017
+ def limitsEnabled(self, val: bool) -> None: ...
4018
+
4019
+ @property
4020
+ def minAngle(self) -> float:
4021
+ """The lower limit of rotation."""
4022
+ ...
4023
+
4024
+ @property
4025
+ def maxAngle(self) -> float:
4026
+ """The upper limit of rotation."""
4027
+ ...
4028
+
4029
+ @property
4030
+ def range(self) -> Any:
4031
+ """
4032
+ Accepts a number to set a symmetric range
4033
+ or an array with the lower and upper limits of rotation.
4034
+ """
4035
+ ...
4036
+
4037
+ @range.setter
4038
+ def range(self, val: tuple[float, float] | float) -> None: ...
4039
+
4040
+ @property
4041
+ def angle(self) -> float:
4042
+ """The joint's current angle of rotation."""
4043
+ ...
4044
+
4045
+ @property
4046
+ def springEnabled(self) -> bool:
4047
+ """
4048
+ Whether spring behavior is enabled.
4049
+
4050
+ Default: `false`
4051
+ """
4052
+ ...
4053
+
4054
+ @springEnabled.setter
4055
+ def springEnabled(self, val: bool) -> None: ...
4056
+
4057
+ @property
4058
+ def springiness(self) -> float:
4059
+ """
4060
+ The springiness of the joint, a 0-1 ratio.
4061
+
4062
+ 0 is rigid, 0.5 is bouncy, 1 is loose.
4063
+
4064
+ Default: `0`
4065
+ """
4066
+ ...
4067
+
4068
+ @springiness.setter
4069
+ def springiness(self, val: float) -> None: ...
4070
+
4071
+ @property
4072
+ def damping(self) -> float:
4073
+ """
4074
+ Damping ratio, 0-1. Higher values reduce oscillation faster.
4075
+
4076
+ Default: `0`
4077
+ """
4078
+ ...
4079
+
4080
+ @damping.setter
4081
+ def damping(self, val: float) -> None: ...
4082
+
4083
+ @property
4084
+ def motorEnabled(self) -> bool:
4085
+ """
4086
+ Whether the joint's motor is enabled.
4087
+
4088
+ Default: `false`
4089
+ """
4090
+ ...
4091
+
4092
+ @motorEnabled.setter
4093
+ def motorEnabled(self, val: bool) -> None: ...
4094
+
4095
+ @property
4096
+ def speed(self) -> float:
4097
+ """
4098
+ Motor speed.
4099
+
4100
+ Default: `0`
4101
+ """
4102
+ ...
4103
+
4104
+ @speed.setter
4105
+ def speed(self, val: float) -> None: ...
4106
+
4107
+ @property
4108
+ def maxPower(self) -> float:
4109
+ """Maximum torque the motor can apply."""
4110
+ ...
4111
+
4112
+ @maxPower.setter
4113
+ def maxPower(self, val: float) -> None: ...
4114
+
4115
+ @property
4116
+ def power(self) -> float:
4117
+ """The current torque being applied by the motor."""
4118
+ ...
4119
+
4120
+ class SliderJoint(Joint):
4121
+
4122
+ def __init__(self, spriteA: Sprite, spriteB: Sprite) -> None: ...
4123
+
4124
+ @property
4125
+ def translation(self) -> float:
4126
+ """The current displacement of spriteB along the slide axis."""
4127
+ ...
4128
+
4129
+ @property
4130
+ def limitsEnabled(self) -> bool:
4131
+ """
4132
+ Whether the joint's translation limits are enabled.
4133
+
4134
+ Default: `false`
4135
+ """
4136
+ ...
4137
+
4138
+ @limitsEnabled.setter
4139
+ def limitsEnabled(self, val: bool) -> None: ...
4140
+
4141
+ @property
4142
+ def lowerLimit(self) -> float:
4143
+ """The mathematical lower limit of translation."""
4144
+ ...
4145
+
4146
+ @property
4147
+ def upperLimit(self) -> float:
4148
+ """The mathematical upper limit of translation."""
4149
+ ...
4150
+
4151
+ @property
4152
+ def range(self) -> Any:
4153
+ """
4154
+ Accepts a number to set a symmetric range
4155
+ or an array with the lower and upper translation limits.
4156
+ """
4157
+ ...
4158
+
4159
+ @range.setter
4160
+ def range(self, val: tuple[float, float] | float) -> None: ...
4161
+
4162
+ @property
4163
+ def springEnabled(self) -> bool:
4164
+ """
4165
+ Whether spring behavior is enabled.
4166
+
4167
+ Default: `false`
4168
+ """
4169
+ ...
4170
+
4171
+ @springEnabled.setter
4172
+ def springEnabled(self, val: bool) -> None: ...
4173
+
4174
+ @property
4175
+ def springiness(self) -> float:
4176
+ """
4177
+ The springiness of the joint, a 0-1 ratio.
4178
+
4179
+ 0 is rigid, 0.5 is bouncy, 1 is loose.
4180
+
4181
+ Default: `0`
4182
+ """
4183
+ ...
4184
+
4185
+ @springiness.setter
4186
+ def springiness(self, val: float) -> None: ...
4187
+
4188
+ @property
4189
+ def damping(self) -> float:
4190
+ """
4191
+ Damping ratio, 0-1. Higher values reduce oscillation faster.
4192
+
4193
+ Default: `0`
4194
+ """
4195
+ ...
4196
+
4197
+ @damping.setter
4198
+ def damping(self, val: float) -> None: ...
4199
+
4200
+ @property
4201
+ def motorEnabled(self) -> bool:
4202
+ """
4203
+ Whether the joint's motor is enabled.
4204
+
4205
+ Default: `true`
4206
+ """
4207
+ ...
4208
+
4209
+ @motorEnabled.setter
4210
+ def motorEnabled(self, val: bool) -> None: ...
4211
+
4212
+ @property
4213
+ def speed(self) -> float:
4214
+ """
4215
+ Motor speed.
4216
+
4217
+ Default: `0`
4218
+ """
4219
+ ...
4220
+
4221
+ @speed.setter
4222
+ def speed(self, val: float) -> None: ...
4223
+
4224
+ @property
4225
+ def maxPower(self) -> float:
4226
+ """
4227
+ Maximum force the motor can apply.
4228
+
4229
+ Default: `10`
4230
+ """
4231
+ ...
4232
+
4233
+ @maxPower.setter
4234
+ def maxPower(self, val: float) -> None: ...
4235
+
4236
+ @property
4237
+ def power(self) -> float:
4238
+ """The current motor force being applied."""
4239
+ ...
4240
+
4241
+ @property
4242
+ def energy(self) -> float:
4243
+ """The current sliding speed of the joint."""
4244
+ ...
4245
+
4246
+ class GrabberJoint(Joint):
4247
+
4248
+ def __init__(self, pointer: Any, sprite: Sprite) -> None: ...
4249
+
4250
+ sprite: Sprite
4251
+ """The sprite being grabbed by the joint."""
4252
+
4253
+ @property
4254
+ def target(self) -> Any:
4255
+ """
4256
+ The target position of the joint that the sprite will be
4257
+ moved towards. Can be a coordinate array or object with x and y properties.
4258
+ """
4259
+ ...
4260
+
4261
+ @target.setter
4262
+ def target(self, val: Any) -> None: ...
4263
+
4264
+ @property
4265
+ def maxForce(self) -> float:
4266
+ """
4267
+ The maximum spring force that the joint can exert on the sprite.
4268
+
4269
+ By default it's 500 * the sprite's mass.
4270
+ """
4271
+ ...
4272
+
4273
+ @maxForce.setter
4274
+ def maxForce(self, val: float) -> None: ...
4275
+
4276
+ @property
4277
+ def maxTorque(self) -> float:
4278
+ """
4279
+ The maximum torque that the joint can exert on the sprite.
4280
+
4281
+ By default it's 0.25 * the sprite's mass * the square root
4282
+ of the rotational inertia divided by the sprite's mass.
4283
+ """
4284
+ ...
4285
+
4286
+ @maxTorque.setter
4287
+ def maxTorque(self, val: float) -> None: ...
4288
+
4289
+ class CastInfo:
4290
+
4291
+ sprite: Sprite
4292
+ """The sprite that was hit by the ray or circle cast."""
4293
+
4294
+ distance: float
4295
+ """The distance from the start of the cast to the intersection point."""
4296
+
4297
+ @property
4298
+ def intersect(self) -> dict:
4299
+ """The intersection point of the cast with the sprite's shape."""
4300
+ ...
4301
+
4302
+ @property
4303
+ def incidence(self) -> float:
4304
+ """The angle of incidence of the cast at the intersection point."""
4305
+ ...
4306
+
4307
+ class Scale:
4308
+
4309
+ def valueOf(self) -> float:
4310
+ ...
4311
+
4312
+ class FriendlyError(Exception):
4313
+ """
4314
+ A FriendlyError is a custom error class that extends the native JS
4315
+ Error class. It's used internally by q5play to make error messages
4316
+ more helpful.
4317
+ """
4318
+
4319
+ @classmethod
4320
+ def new(cls, func: Any, errorNum: Any, e: Any) -> 'FriendlyError':
4321
+ ...
4322
+
4323
+ def __init__(self, func: Any, errorNum: Any, e: Any) -> None: ...
4324
+
4325
+ class InputDevice:
4326
+
4327
+ holdThreshold: float
4328
+ """
4329
+ The amount of frames an input must be pressed to be considered held.
4330
+
4331
+ Default: `12`
4332
+ """
4333
+
4334
+ def presses(self, inp: str = ...) -> bool:
4335
+ """
4336
+
4337
+ Returns:
4338
+ true on the first frame that the user presses the input
4339
+ """
4340
+ ...
4341
+
4342
+ def pressing(self, inp: str = ...) -> float:
4343
+ """
4344
+
4345
+ Returns:
4346
+ the amount of frames the user has been pressing the input
4347
+ """
4348
+ ...
4349
+
4350
+ def pressed(self, inp: str = ...) -> bool:
4351
+ """
4352
+ Same as the `released` function, which is preferred.
4353
+
4354
+ .. deprecated::
4355
+
4356
+ Returns:
4357
+ true on the first frame that the user released the input
4358
+ """
4359
+ ...
4360
+
4361
+ def holds(self, inp: str = ...) -> bool:
4362
+ """
4363
+
4364
+ Returns:
4365
+ true on the first frame that the user holds the input
4366
+ """
4367
+ ...
4368
+
4369
+ def holding(self, inp: str = ...) -> float:
4370
+ """
4371
+
4372
+ Returns:
4373
+ the amount of frames the user has been holding the input
4374
+ """
4375
+ ...
4376
+
4377
+ def held(self, inp: str = ...) -> bool:
4378
+ """
4379
+
4380
+ Returns:
4381
+ true on the first frame that the user released a held input
4382
+ """
4383
+ ...
4384
+
4385
+ def released(self, inp: str = ...) -> bool:
4386
+ """
4387
+
4388
+ Returns:
4389
+ true on the first frame that the user released the input
4390
+ """
4391
+ ...
4392
+
4393
+ def releases(self, inp: Any = ...) -> bool:
4394
+ ...
4395
+
4396
+ class _Mouse(InputDevice):
4397
+
4398
+ x: float
4399
+ """The mouse's x position in the world."""
4400
+
4401
+ y: float
4402
+ """The mouse's y position in the world."""
4403
+
4404
+ left: float
4405
+ """The mouse's left button."""
4406
+
4407
+ center: float
4408
+ """The mouse's center button."""
4409
+
4410
+ right: float
4411
+ """The mouse's right button."""
4412
+
4413
+ scrollDelta: dict
4414
+ """Contains the scroll status of the mouse wheel."""
4415
+
4416
+ drag: dict
4417
+ """Contains the drag status of each of the mouse's buttons."""
4418
+
4419
+ isOnCanvas: bool
4420
+ """
4421
+ True if the mouse is currently on the canvas.
4422
+
4423
+ Default: `false`
4424
+ """
4425
+
4426
+ isActive: bool
4427
+ """
4428
+ True if the mouse has ever interacted with the canvas.
4429
+
4430
+ Default: `false`
4431
+ """
4432
+
4433
+ @property
4434
+ def pos(self) -> dict:
4435
+ """
4436
+ Gets the mouse's current position in the world as a readonly object {x, y}
4437
+ that won't updated if the mouse moves.
4438
+ """
4439
+ ...
4440
+
4441
+ @property
4442
+ def position(self) -> dict:
4443
+ """The mouse's current position."""
4444
+ ...
4445
+
4446
+ @property
4447
+ def cursor(self) -> str:
4448
+ """
4449
+ The mouse's CSS cursor style.
4450
+
4451
+ Default: `'default'`
4452
+ """
4453
+ ...
4454
+
4455
+ @cursor.setter
4456
+ def cursor(self, val: str) -> None: ...
4457
+
4458
+ @property
4459
+ def visible(self) -> bool:
4460
+ """
4461
+ Controls whether the mouse is visible or not.
4462
+
4463
+ Default: `true`
4464
+ """
4465
+ ...
4466
+
4467
+ @visible.setter
4468
+ def visible(self, val: bool) -> None: ...
4469
+
4470
+ def drags(self, inp: str = ...) -> bool:
4471
+ """
4472
+
4473
+ Returns:
4474
+ true on the first frame that the user moves the mouse while pressing the input
4475
+ """
4476
+ ...
4477
+
4478
+ def dragging(self, inp: str = ...) -> float:
4479
+ """
4480
+
4481
+ Returns:
4482
+ the amount of frames the user has been moving the mouse while pressing the input
4483
+ """
4484
+ ...
4485
+
4486
+ def dragged(self, inp: str = ...) -> bool:
4487
+ """
4488
+
4489
+ Returns:
4490
+ true on the first frame that the user releases the input after dragging the mouse
4491
+ """
4492
+ ...
4493
+
4494
+ def scrolls(self) -> bool:
4495
+ """
4496
+
4497
+ Returns:
4498
+ true on the first frame that the user scrolls the mouse wheel
4499
+ """
4500
+ ...
4501
+
4502
+ def scrolling(self) -> float:
4503
+ """
4504
+
4505
+ Returns:
4506
+ the amount of frames the user has been scrolling the mouse wheel
4507
+ """
4508
+ ...
4509
+
4510
+ def scrolled(self) -> bool:
4511
+ """
4512
+
4513
+ Returns:
4514
+ true on the first frame that the user stops scrolling the mouse wheel
4515
+ """
4516
+ ...
4517
+
4518
+ class _Pointer(InputDevice):
4519
+
4520
+ @classmethod
4521
+ def new(cls, pointer: Any) -> '_Pointer':
4522
+ ...
4523
+
4524
+ def __init__(self, pointer: Any) -> None: ...
4525
+
4526
+ x: float
4527
+ """The pointer's x position in the physics world."""
4528
+
4529
+ y: float
4530
+ """The pointer's y position in the physics world."""
4531
+
4532
+ id: float
4533
+ """The pointer's unique identifier."""
4534
+
4535
+ duration: float
4536
+ """The amount of frames the pointer has been active for."""
4537
+
4538
+ canvasPos: dict
4539
+ """The pointer's absolute position on the canvas."""
4540
+
4541
+ pressure: float
4542
+ """
4543
+ The pointer's pressure level, from 0 to 1.
4544
+
4545
+ On devices that do not support pressure sensitivity,
4546
+ the value is 0.5 when the pointer is pressing.
4547
+ """
4548
+
4549
+ press: float
4550
+ """
4551
+ The amount of frames the user has been clicking, touching,
4552
+ or drawing on the screen with the pointer.
4553
+ """
4554
+
4555
+ def grabs(self) -> bool:
4556
+ """
4557
+
4558
+ Returns:
4559
+ true on the first frame that the pointer grabs a sprite
4560
+ """
4561
+ ...
4562
+
4563
+ def grabbing(self) -> float:
4564
+ """
4565
+
4566
+ Returns:
4567
+ the amount of frames the pointer has been grabbing a sprite
4568
+ """
4569
+ ...
4570
+
4571
+ def grabbed(self) -> bool:
4572
+ """
4573
+
4574
+ Returns:
4575
+ true on the first frame that the pointer releases a grabbed sprite
4576
+ """
4577
+ ...
4578
+
4579
+ def overlaps(self, sprite: Sprite) -> bool:
4580
+ """
4581
+
4582
+ Returns:
4583
+ true on the first frame that the pointer overlaps the sprite
4584
+ """
4585
+ ...
4586
+
4587
+ def overlapping(self, sprite: Sprite) -> float:
4588
+ """
4589
+
4590
+ Returns:
4591
+ the amount of frames the pointer has been overlapping the sprite
4592
+ """
4593
+ ...
4594
+
4595
+ def overlapped(self, sprite: Sprite) -> bool:
4596
+ """
4597
+
4598
+ Returns:
4599
+ true on the first frame that the pointer stops overlapping the sprite
4600
+ """
4601
+ ...
4602
+
4603
+ class _Keyboard(InputDevice):
4604
+
4605
+ alt: float
4606
+
4607
+ arrowUp: float
4608
+
4609
+ arrowDown: float
4610
+
4611
+ arrowLeft: float
4612
+
4613
+ arrowRight: float
4614
+
4615
+ backspace: float
4616
+
4617
+ capsLock: float
4618
+
4619
+ control: float
4620
+
4621
+ enter: float
4622
+
4623
+ meta: float
4624
+
4625
+ shift: float
4626
+
4627
+ tab: float
4628
+
4629
+ @property
4630
+ def visible(self) -> bool:
4631
+ ...
4632
+
4633
+ @visible.setter
4634
+ def visible(self, val: bool) -> None: ...
4635
+
4636
+ @property
4637
+ def cmd(self) -> float:
4638
+ ...
4639
+
4640
+ @property
4641
+ def command(self) -> float:
4642
+ ...
4643
+
4644
+ @property
4645
+ def ctrl(self) -> float:
4646
+ ...
4647
+
4648
+ @property
4649
+ def space(self) -> Any:
4650
+ ...
4651
+
4652
+ @property
4653
+ def opt(self) -> float:
4654
+ ...
4655
+
4656
+ @property
4657
+ def option(self) -> float:
4658
+ ...
4659
+
4660
+ @property
4661
+ def win(self) -> float:
4662
+ ...
4663
+
4664
+ @property
4665
+ def windows(self) -> float:
4666
+ ...
4667
+
4668
+ class Contro(InputDevice):
4669
+
4670
+ @classmethod
4671
+ def new(cls, gp: Any | str) -> 'Contro':
4672
+ """
4673
+ Stores the input status of buttons, triggers, and sticks on
4674
+ game controllers. Used internally to create controller objects
4675
+ for the `contros` array (aka `controllers`).
4676
+
4677
+ Can also be used to create a mock controller object.
4678
+ """
4679
+ ...
4680
+
4681
+ def __init__(self, gp: Any | str) -> None: ...
4682
+
4683
+ connected: bool
4684
+
4685
+ a: float
4686
+
4687
+ b: float
4688
+
4689
+ x: float
4690
+
4691
+ y: float
4692
+
4693
+ l: float
4694
+ """Left shoulder button."""
4695
+
4696
+ r: float
4697
+ """Right shoulder button."""
4698
+
4699
+ lt: float
4700
+ """Digital left trigger."""
4701
+
4702
+ rt: float
4703
+ """Digital right trigger."""
4704
+
4705
+ select: float
4706
+
4707
+ start: float
4708
+
4709
+ lsb: float
4710
+ """
4711
+ Left stick button.
4712
+ Activated by pressing down on the left analog stick.
4713
+ """
4714
+
4715
+ rsb: float
4716
+ """
4717
+ Right stick button.
4718
+ Activated by pressing down on the right analog stick.
4719
+ """
4720
+
4721
+ up: float
4722
+
4723
+ down: float
4724
+
4725
+ left: float
4726
+
4727
+ right: float
4728
+
4729
+ leftStick: Any
4730
+ """
4731
+ Has x and y properties with -1 to 1 values which
4732
+ represent the position of the left analog stick.
4733
+
4734
+ {x: 0, y: 0} is the center position.
4735
+ """
4736
+
4737
+ rightStick: Any
4738
+ """
4739
+ Has x and y properties with -1 to 1 values which
4740
+ represent the position of the right analog stick.
4741
+
4742
+ {x: 0, y: 0} is the center position.
4743
+ """
4744
+
4745
+ leftTrigger: float
4746
+ """
4747
+ Analog value 0-1 of the left trigger.
4748
+
4749
+ Default: `0`
4750
+ """
4751
+
4752
+ rightTrigger: float
4753
+ """
4754
+ Analog value 0-1 of the right trigger.
4755
+
4756
+ Default: `0`
4757
+ """
4758
+
4759
+ buttonMapping: Any
4760
+ """Button names are mapped to `gamepad.buttons` indices."""
4761
+
4762
+ axeMapping: Any
4763
+ """Sticks and triggers are mapped to `gamepad.axes` indices."""
4764
+
4765
+ isMock: bool
4766
+ """If the controller is a mock controller."""
4767
+
4768
+ gamepad: Any
4769
+
4770
+ id: Any
4771
+
4772
+ hasAnalogTriggers: bool
4773
+ """
4774
+ True if the controller has analog triggers.
4775
+ False if the controller has digital (button) triggers.
4776
+ """
4777
+
4778
+ @property
4779
+ def cross(self) -> float:
4780
+ ...
4781
+
4782
+ @property
4783
+ def circle(self) -> float:
4784
+ ...
4785
+
4786
+ @property
4787
+ def square(self) -> float:
4788
+ ...
4789
+
4790
+ @property
4791
+ def triangle(self) -> float:
4792
+ ...
4793
+
4794
+ @property
4795
+ def ls(self) -> Any:
4796
+ """Alias for `leftStick`."""
4797
+ ...
4798
+
4799
+ @property
4800
+ def rs(self) -> Any:
4801
+ """Alias for `rightStick`."""
4802
+ ...
4803
+
4804
+ @property
4805
+ def lb(self) -> float:
4806
+ """
4807
+ Alias for `l` (left shoulder button).
4808
+ `lb` is what it's called on Xbox controllers.
4809
+ """
4810
+ ...
4811
+
4812
+ @property
4813
+ def rb(self) -> float:
4814
+ """
4815
+ Alias for `r` (right shoulder button).
4816
+ `rb` is what it's called on Xbox controllers.
4817
+ """
4818
+ ...
4819
+
4820
+ @property
4821
+ def l1(self) -> float:
4822
+ """
4823
+ Alias for `l` (left shoulder button).
4824
+ `l1` is what it's called on PlayStation controllers.
4825
+ """
4826
+ ...
4827
+
4828
+ @property
4829
+ def r1(self) -> float:
4830
+ """
4831
+ Alias for `r` (right shoulder button).
4832
+ `r1` is what it's called on PlayStation controllers.
4833
+ """
4834
+ ...
4835
+
4836
+ @property
4837
+ def zl(self) -> float:
4838
+ """
4839
+ Alias for `lt` (digital left trigger).
4840
+ `zl` is what it's called on Nintendo controllers.
4841
+ """
4842
+ ...
4843
+
4844
+ @property
4845
+ def zr(self) -> float:
4846
+ """
4847
+ Alias for `rt` (digital right trigger).
4848
+ `zr` is what it's called on Nintendo controllers.
4849
+ """
4850
+ ...
4851
+
4852
+ @property
4853
+ def l2(self) -> float:
4854
+ """
4855
+ Alias for `leftTrigger` (analog left trigger).
4856
+ `l2` is what it's called on PlayStation controllers.
4857
+ """
4858
+ ...
4859
+
4860
+ @property
4861
+ def r2(self) -> float:
4862
+ """
4863
+ Alias for `rightTrigger` (analog right trigger).
4864
+ `r2` is what it's called on PlayStation controllers.
4865
+ """
4866
+ ...
4867
+
4868
+ @property
4869
+ def leftStickButton(self) -> float:
4870
+ """Verbose alias for `lsb`."""
4871
+ ...
4872
+
4873
+ @property
4874
+ def rightStickButton(self) -> float:
4875
+ """Verbose alias for `rsb`."""
4876
+ ...
4877
+
4878
+ @property
4879
+ def l3(self) -> float:
4880
+ """
4881
+ Alias for `lsb` (left stick button).
4882
+ `l3` is what it's called on PlayStation controllers.
4883
+ """
4884
+ ...
4885
+
4886
+ @property
4887
+ def r3(self) -> float:
4888
+ """
4889
+ Alias for `rsb` (right stick button).
4890
+ `r3` is what it's called on PlayStation controllers.
4891
+ """
4892
+ ...
4893
+
4894
+ class _Contros(list[Contro]):
4895
+
4896
+ @classmethod
4897
+ def new(cls) -> '_Contros':
4898
+ """
4899
+ Used internally to create the `contros` array (aka `controllers`)
4900
+ of `Contro` objects, which store the input status of buttons,
4901
+ triggers, and sticks on game controllers.
4902
+ """
4903
+ ...
4904
+
4905
+ def __init__(self) -> None: ...
4906
+
4907
+ def swap(self, indexA: float, indexB: float) -> None:
4908
+ """Swap controller positions in this controllers array."""
4909
+ ...
4910
+
4911
+ def remove(self, index: float) -> None: # type: ignore[override]
4912
+ """
4913
+ Removes a controller from this controllers array
4914
+ by setting `contros[index] = null`.
4915
+
4916
+ Newly connected controllers fill the first empty slot.
4917
+ """
4918
+ ...
4919
+
4920
+ def onConnect(self, gamepad: Any) -> bool:
4921
+ """
4922
+ Runs when a controller is connected. By default it
4923
+ always returns true. Overwrite this function to customize
4924
+ the behavior.
4925
+
4926
+ For example, it could be customized to filter
4927
+ controllers based on their model info.
4928
+
4929
+ Doesn't run if a controller in the `controllers` array
4930
+ is reconnected.
4931
+
4932
+ Returns:
4933
+ true if the controller should be added to this q5play controllers array
4934
+ """
4935
+ ...
4936
+
4937
+ def onDisconnect(self, gamepad: Any) -> bool:
4938
+ """
4939
+ Runs when a controller is disconnected. by default it
4940
+ always returns false. Overwrite this function to customize
4941
+ the behavior.
4942
+
4943
+ Removing a controller from the `controllers` array
4944
+ usually is not desirable, because the controller could be
4945
+ reconnected later. By default, the controller is kept in
4946
+ the array and its state is reset.
4947
+
4948
+ Returns:
4949
+ true if the controllers should be removed from this q5play controllers array
4950
+ """
4951
+ ...
4952
+
4953
+ def colorPal(c: str, palette: list[dict | str]) -> str:
4954
+ ...
4955
+
4956
+ def EmojiImage(emoji: str, textSize: float) -> Image:
4957
+ ...
4958
+
4959
+ def spriteArt(txt: str, scale: float, palette: list[dict | str]) -> Image:
4960
+ ...
4961
+
4962
+ def animation(ani: Ani, x: float, y: float, dW: float, dH: float) -> None:
4963
+ """
4964
+ Draws an animation.
4965
+
4966
+ Args:
4967
+ ani: the animation
4968
+ x: x coordinate to draw the animation at
4969
+ y: y coordinate to draw the animation at
4970
+ dW: display width
4971
+ dH: display height
4972
+ """
4973
+ ...
4974
+
4975
+ def delay(milliseconds: float = ...) -> Awaitable[None]:
4976
+ """
4977
+
4978
+ Args:
4979
+ milliseconds: if not specified, delays until the next frame draw
4980
+
4981
+ Returns:
4982
+ resolves after the delay
4983
+ """
4984
+ ...
4985
+
4986
+ allSprites: Group
4987
+
4988
+ world: World
4989
+
4990
+ camera: Camera
4991
+
4992
+ mouse: _Mouse
4993
+
4994
+ pointers: list[_Pointer]
4995
+
4996
+ pointer: _Pointer
4997
+
4998
+ kb: _Keyboard
4999
+
5000
+ keyboard: _Keyboard
5001
+
5002
+ contros: _Contros
5003
+
5004
+ controllers: _Contros
5005
+
5006
+ contro: Contro
5007
+