forked from MDL29/JacoBot
Change the method of detecting trash
This commit is contained in:
parent
2256891430
commit
8aba34d938
|
@ -115,14 +115,14 @@ class Pad(arcade.Window):
|
|||
"""Called when the user presses a mouse button"""
|
||||
logging.info(f"Mouse relase at {x},{y}")
|
||||
|
||||
# Get list of tokens_trash we've release on
|
||||
tokens_trash = arcade.get_sprites_at_point((x, y), self.tokens_trash)
|
||||
if self.held_token is not None:
|
||||
# Find the closest trash
|
||||
trash, distance = arcade.get_closest_sprite(self.held_token, self.tokens_trash)
|
||||
|
||||
# If we are on a tokens_trash delete the held token
|
||||
if len(tokens_trash) > 0:
|
||||
if self.held_token is not None:
|
||||
tokens_trash[-1].remove_token(self.held_token)
|
||||
|
||||
# See if we are in contact with the closest trash, it yes delete the held token
|
||||
if arcade.check_for_collision(self.held_token, trash):
|
||||
trash.remove_token(self.held_token)
|
||||
|
||||
# remove token from hand
|
||||
if self.held_token != None:
|
||||
self.held_token = None
|
||||
|
|
Loading…
Reference in New Issue
Block a user