Skip to content

Commit

Permalink
Added a function to check whether an actor is at the edge of the world.
Browse files Browse the repository at this point in the history
  • Loading branch information
neilccbrown committed Dec 3, 2024
1 parent 95a42cd commit a599261
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions public/public_libraries/strype/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,19 @@ def turn(self, degrees):
"""
self.set_rotation(_strype_graphics_internal.getImageRotation(self.__id) + degrees)

def is_at_edge(self):
"""
Checks whether the central point of the actor is at the edge of the screen.
An actor is determined to be at the edge if it's position is within one pixel of the edge of the screen.
So if its X is less than -399 or greater than 399, or its Y is less than -299 or greater than 299.
:return: True if the actor is at the edge of the world, False otherwise.
"""
x = self.get_exact_x()
y = self.get_exact_y()
return x < -399 or x > 399 or y < -299 or y > 299

def is_touching(self, actor):
"""
Checks if this actor is touching the given actor. Two actors are deemed to be touching if the
Expand Down

0 comments on commit a599261

Please sign in to comment.