Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set dimensions for missing image #700

Merged
merged 1 commit into from
Apr 8, 2024
Merged

set dimensions for missing image #700

merged 1 commit into from
Apr 8, 2024

Conversation

davidism
Copy link
Contributor

@davidism davidism commented Apr 8, 2024

When a RectangleSprite falls back to rendering a default shape instead
of an image, use its dimensions rather than a default square.

This adds a private _file_missing_dimensions tuple to Image, which defaults to (1, 1). RectangleSprite.__image__ sets this to its dimensions so that the default shape is a rectangle instead of a square.

fixes #691

import ppb


class Platform(ppb.RectangleSprite):
    pass


class Player(ppb.Sprite):
    pass


def setup(scene):
    platform = Platform(width=3, height=1, position=ppb.Vector(0, -5))
    scene.add(platform)
    player = Player()
    scene.add(player)


ppb.run(setup)
Screenshot 2024-04-08 at 09 57 41

When a RectangleSprite falls back to rendering a default shape instead
of an image, use its dimensions rather than a default square.
@davidism davidism requested a review from a team as a code owner April 8, 2024 17:02
Copy link
Collaborator

@pathunstrom pathunstrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pathunstrom pathunstrom merged commit 229a351 into ppb:canon Apr 8, 2024
22 checks passed
@davidism davidism deleted the rectangle branch April 8, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RectangleSprite objects create a Square image as default.
2 participants