Skip to content

Commit

Permalink
Merge #257
Browse files Browse the repository at this point in the history
257: rotate_image now clock-wise r=pathunstrom a=ZackOConnor

Fixes target and animated_sprite examples for the new rotation direction
Fixes #251 

Co-authored-by: zoconnor <zoconnor@p-sl-1805-d6gv>
  • Loading branch information
bors[bot] and zoconnor committed May 6, 2019
2 parents 2f6bf6e + 904d10a commit dd0c0d8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/animated_sprite.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def on_mouse_motion(self, event: events.MouseMotion, signal):
def on_update(self, event: events.Update, signal):
intent_vector = self.target - self.position
self.position += intent_vector.scale(self.speed * event.time_delta)
self.rotation = math.degrees(math.atan2(intent_vector.y, intent_vector.x)) + 90
self.rotation = math.degrees(math.atan2(intent_vector.y, intent_vector.x)) - 90


def setup(scene):
Expand Down
2 changes: 2 additions & 0 deletions examples/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Player(MoverMixin, ppb.BaseSprite):
# and adding it on press and subtracting it on release.
left_vector = Vector(-1, 0)
right_vector = Vector(1, 0)
_rotation = 180

def on_key_pressed(self, event, signal):
if event.key in (keycodes.A, keycodes.Left):
Expand Down Expand Up @@ -44,6 +45,7 @@ def _fire_bullet(self, scene):

class Bullet(MoverMixin, ppb.BaseSprite):
velocity = Vector(0, 2)
_rotation = 180

def on_update(self, update, signal):
super().on_update(update, signal) # Execute movement
Expand Down
4 changes: 2 additions & 2 deletions ppb/systems/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def resize_image(self, image, game_unit_size):
return resized_image

def rotate_image(self, image, rotation):
"""Rotates image counter-clockwise {rotation} degrees."""
return pygame.transform.rotate(image, -rotation)
"""Rotates image clockwise {rotation} degrees."""
return pygame.transform.rotate(image, rotation)

def target_resolution(self, width, height, game_unit_size):
values = [width, height]
Expand Down

0 comments on commit dd0c0d8

Please sign in to comment.