Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 85913cc627 | |||
| 754ab27db7 |
3 changed files with 4 additions and 2 deletions
|
|
@ -62,3 +62,4 @@ Halle Jones|HJones@aliacy.com||
|
|||
[Julie Fisher](https://github.com/julielinx) | | |
|
||||
[Sheena O'Connell](https://github.com/sheenarbw) | [@sheena@fosstodon.org](https://fosstodon.org/@sheena) | [blog](https://sheenaoc.com/) |
|
||||
[Quinn Redwoods](https://github.com/qredwoods) | | |
|
||||
[Jeff Epler](https://github.com/jepler) | | |
|
||||
|
|
|
|||
|
|
@ -111,7 +111,8 @@ class KeyBoardMovementSprite(ppb.Sprite):
|
|||
key_bindings = arrow_direction_key_bindings
|
||||
|
||||
def on_update(self, update_event, signal):
|
||||
self.position += self.direction * self.speed * update_event.time_delta
|
||||
displacement = self.direction.scale_to(self.speed * update_event.time_delta)
|
||||
self.position += displacement
|
||||
|
||||
def on_key_pressed(self, key_event: KeyPressed, signal):
|
||||
if key_event.key == self.key_bindings.left:
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ def test_keyboard_movement_sprite_move_down_left_wasd():
|
|||
keyboard_sprite.on_update(ppb.events.Update(1), lambda x: None)
|
||||
|
||||
assert keyboard_sprite.direction.isclose((-1, -1))
|
||||
assert keyboard_sprite.position.isclose((-1, -1))
|
||||
assert keyboard_sprite.position.isclose((-1/2**.5, -1/2**.5))
|
||||
|
||||
|
||||
def test_mouse_target_sprite():
|
||||
|
|
|
|||
Loading…
Reference in a new issue