Actors from simple shapes #371
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #235
This PR introduces classmethods to Actor to create actors from simple filled shapes with a given color.
Available functions:
Actor.Square(side, color)Actor.Rectangle(width, height, color)Actor.Circle(diameter, color)Actor.Ellipse(width, height, color)Actor.Triangle(width, height, color)All keyword assignments as well as anchor and starting position as positional arguments remain available when using these functions, for example
player = Actor.Square(15, "blue", (40, 25))The actors are completely normal actors, the shapes are created as image surfaces and saved in the image cache so that creating many actors with the same shape, dimensions and color does not increase cost. This way, users can begin to implement features that rely on Actor functionality without having image files yet. Once they have an image file they want, as long as it has the same dimensions, they can swap to it simply by changing
Actor.Shape(dimensions, color)toActor(image_string).I am still thinking about whether
SquareandCircleshould be removed, since the same results can easily be achieved viaRectangleandEllipse. I am leaning towards doing so to lower the number of functions that are available, making it easier for beginners to keep an overview. I would like feedback on that before we merge anything though.Documentation and tests have been added.