-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
463: Adds ordinal direction unit vectors. r=astronouth7303 a=pathunstrom Primary use case is to reduce the cognitive load in early lessons: ```python class OurSprite(Sprite): def on_update(): self.facing = Left ``` Co-authored-by: Piper Thunstrom <pathunstrom@gmail.com>
- Loading branch information
Showing
4 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.. py:currentmodule:: ppb.directions | ||
=============================== | ||
Directions | ||
=============================== | ||
|
||
.. automodule:: ppb.directions | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,5 @@ decisions are made, see the :doc:`/discussion/index` section. | |
engine | ||
sound | ||
camera | ||
directions | ||
features/index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
""" | ||
The ordinal directions. | ||
A collection of normalized vectors to be referenced by name. | ||
Best used for the positions or facings of :class:`Sprites <ppb.Sprite>`. | ||
""" | ||
from ppb_vector import Vector | ||
|
||
Up = Vector(0, 1).normalize() #: Unit vector to the top of the screen from center. | ||
Down = Vector(0, -1).normalize() #: Unit vector to the bottom of the screen from center. | ||
Left = Vector(-1, 0).normalize() #: Unit vector to the left of the screen from center. | ||
Right = Vector(1, 0).normalize() #: Unit vector to the right of the screen from center. | ||
UpAndLeft = (Up + Left).normalize() #: Unit vector diagonally up and to the left of the screen from center. | ||
UpAndRight = (Up + Right).normalize() #: Unit vector diagonally up and to the right of the screen from center. | ||
DownAndLeft = (Down + Left).normalize() #: Unit vector diagonally down and to the left of the screen from center. | ||
DownAndRight = (Down + Right).normalize() #: Unit vector diagonally down and to the right of the screen from center. |