1
0
Fork 0

Avancement de la scéance

This commit is contained in:
HS-157 2024-02-25 05:09:36 +01:00
parent 14eaf2aa88
commit b4eab7c444
1 changed files with 23 additions and 3 deletions

View File

@ -58,12 +58,18 @@ Y_MAT_POS = TOP_Y
class Token(arcade.Sprite):
"""Token sprite"""
sprite = {}
sprite = {
"FORDWARD": "up",
"RIGHT": "r",
"LEFT": "l",
"PAUSE": "pause_square",
"FUNCTION": "hamburger",
}
def __init__(self, token_type, scale=1):
"""Token constructor"""
# Type of token
self.type = None
self.type = token_type
# Get sprite for type of token
self.image_file_name = (
":resources:onscreen_controls/shaded_dark/%s.png"
@ -179,7 +185,21 @@ class Cubito(arcade.Window):
if self.held_token is None:
return
# Release hold token
# Release holdosert mat from held token
mat, distance = arcade.get_closest_sprite(self.held_token, self.mat_list)
reset_position = True
# Check collision between held token et the closert mat
if arcade.check_for_collision(self.held_token, mat):
# Set held token position on mat
self.held_token.position = mat.center_x, mat.center_y
reset_position = False
# If no collision between held token et the closert mat, reset held token position
if reset_position:
self.held_token.position = self.held_token_original_position
self.held_token = None
def on_mouse_motion(self, x, y, dx, dy):