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

Support Sprite.rect property, a 4-tuple controlling whthe src-rect to… #475

Open
wants to merge 1 commit into
base: canon
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions ppb/systems/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,19 @@ def compute_rectangles(self, texture, game_object, camera):

src_rect = SDL_Rect(x=0, y=0, w=img_w, h=img_h)

if hasattr(game_object, 'width'):
obj_w = game_object.width
obj_h = game_object.height
if hasattr(game_object, 'rect'):
rect = game_object.rect
src_rect = SDL_Rect(*rect)
win_w, win_h = self.target_resolution(rect[2], rect[3], game_object.size, game_object.size, camera.pixel_ratio)

else:
obj_w, obj_h = game_object.size
if hasattr(game_object, 'width'):
obj_w = game_object.width
obj_h = game_object.height
else:
obj_w, obj_h = game_object.size

win_w, win_h = self.target_resolution(img_w.value, img_h.value, obj_w, obj_h, camera.pixel_ratio)
win_w, win_h = self.target_resolution(img_w.value, img_h.value, obj_w, obj_h, camera.pixel_ratio)

center = camera.translate_point_to_screen(game_object.position)
dest_rect = SDL_Rect(
Expand Down