pythonarcade / arcade

Easy to use Python library for creating 2D arcade games.
http://arcade.academy
Other
1.69k stars 319 forks source link

enhance typing for classes arcade.Sprite and arcade.SpriteList #1867

Open Snipy7374 opened 1 year ago

Snipy7374 commented 1 year ago

Enhancement request:

arcade.Sprite.draw and arcade.Sprite.register_physic_engine have unannotated arguments (AKA Unknown) as well as arcade.SpriteList.draw

What should be added/changed?

Add type hints for the mentioned above members.

What would it help with?

It'll help users with development and understanding the actual valid type of arguments.

einarf commented 8 months ago
pushfoo commented 7 months ago

PhysicsEngine could possible have some type/interface

I've brought this idea up before, but the response I got was that it's hard to standardize on physics engine behavior.

pushfoo commented 7 months ago

TL;DR: SpriteList's typing is better now, but please help with Sprite if you have time and avoid a PhysicsEngine type until after 3.0.

Sprite & SpriteList Typing

A Unified Physics Engine Type Probably Needs to Wait

As to the engine type / Protocol, here are my current thoughts after starting on #1981:

  1. There seems to be a repeated pattern of inlined expansion into a list of SpriteLists + properties for checking collision
  2. Abstracting some of that collision checking may clean up code at the price of execution 3.It's worth reconsidering Scene's layers and structuring and how it interacts with physics engine objects, but probably after 3.0
  3. I haven't looked at the pymunk engine in months, so I I'm not yet sure about what a physics engine Protocol type should look like