Ajout des images pour les tokens et de l'image pour les cases normales.

This commit is contained in:
DotoroIII 2024-03-08 00:23:22 +01:00
parent 58f88c30fe
commit cc3897daaf

View File

@ -7,12 +7,12 @@ import arcade
import cubito
SCREEN_MULTILPLIER = 1
SCREEN_MULTILPLIER = 1.5
SCREEN_MULTILPLIER /= 4
# Screen title and size
SCREEN_TITLE = "Cubito"
SCREEN_WIDTH = int(500*SCREEN_MULTILPLIER)
SCREEN_HEIGHT = int(500*SCREEN_MULTILPLIER)
SCREEN_WIDTH = int(2000* SCREEN_MULTILPLIER)
SCREEN_HEIGHT = int(2000* SCREEN_MULTILPLIER)
# Margin between mat & screen side
VERTICAL_MARGIN_PERCENT = 0.10
@ -22,29 +22,28 @@ HORIZONTAL_MARGIN_PERCENT = 0.10
TOKEN_ROW = 10
#Token start
X_TOKEN_START = int(50*SCREEN_MULTILPLIER)
Y_TOKEN_START = int(450*SCREEN_MULTILPLIER)
X_TOKEN_START = int(208*SCREEN_MULTILPLIER)
Y_TOKEN_START = int(1400*SCREEN_MULTILPLIER)
# Space between tokens
X_SPACING_TOKEN = int(45*SCREEN_MULTILPLIER)
Y_SPACING_TOKEN = int(45*SCREEN_MULTILPLIER)
# Token size
TOKEN_SCALE = 0.5*SCREEN_MULTILPLIER
TOKEN_HEIGHT = 75 * TOKEN_SCALE
TOKEN_WIDTH = 75 * TOKEN_SCALE
TOKEN_HEIGHT = int(160 * SCREEN_MULTILPLIER)
TOKEN_WIDTH = int(160 * SCREEN_MULTILPLIER)
# List of token types
TOKEN_TYPES = ["up", "left", "right", "hamburger"]
TOKEN_TYPES = ["up", "left", "right", "function"]
#Mat start
X_MAT_START = int(250*SCREEN_MULTILPLIER)
Y_MAT_START = int(400*SCREEN_MULTILPLIER)
X_MAT_START = int(1072 * SCREEN_MULTILPLIER)
Y_MAT_START = int(1648 * SCREEN_MULTILPLIER)
# Mat size
MAT_PERCENT_OVERSIZE = 1.25
MAT_HEIGHT = int(TOKEN_HEIGHT * MAT_PERCENT_OVERSIZE)
MAT_WIDTH = int(TOKEN_WIDTH * MAT_PERCENT_OVERSIZE)
MAT_HEIGHT = int(200 * SCREEN_MULTILPLIER)
MAT_WIDTH = int(200 * SCREEN_MULTILPLIER)
# Number of column & row mat
MAT_COLUMN = 4
@ -52,8 +51,8 @@ MAT_ROW = 4
MAT_FUNCTION_ROW = 2
# Space between mats
X_SPACING_MAT = MAT_WIDTH + MAT_WIDTH * HORIZONTAL_MARGIN_PERCENT
Y_SPACING_MAT = MAT_HEIGHT + MAT_HEIGHT * VERTICAL_MARGIN_PERCENT
X_SPACING_MAT = int(MAT_WIDTH + 30 * SCREEN_MULTILPLIER)
Y_SPACING_MAT = int(MAT_WIDTH + 30 * SCREEN_MULTILPLIER)
# Top for mats
TOP_Y = SCREEN_HEIGHT - MAT_HEIGHT - MAT_HEIGHT * VERTICAL_MARGIN_PERCENT
@ -64,9 +63,12 @@ BOTTOM_Y = MAT_HEIGHT / 2 + MAT_HEIGHT * VERTICAL_MARGIN_PERCENT
# Start from left side
START_X = MAT_WIDTH / 2 + MAT_WIDTH * HORIZONTAL_MARGIN_PERCENT
# Image
X_START_MAIN_MAT_IMAGE = 1415 * SCREEN_MULTILPLIER
Y_START_MAIN_MAT_IMAGE = 1304 * SCREEN_MULTILPLIER
# Couleur
BACKGROUND_COLOR = (133, 100, 100)
class Start_mat(arcade.SpriteSolidColor):
def __init__(self, height, width, color=arcade.color.AMBER):
@ -80,18 +82,23 @@ class Mat_function(arcade.SpriteSolidColor):
def __init__(self, height, width, color=arcade.color.AMBER):
super().__init__(width, height, color)
class Token_sprite(arcade.Sprite):
""" Token sprite """
def __init__(self, token_type, scale=1):
# Attributes for token type
self.token_type = token_type
self.image_file_name = f":resources:onscreen_controls/shaded_dark/{self.token_type}.png"
scale *= SCREEN_MULTILPLIER
self.image_file_name = f"Img/token/{self.token_type}.png"
# Call the parent
super().__init__(self.image_file_name, scale, hit_box_algorithm="None")
class Image(arcade.Sprite):
def __init__(self, file_name, scale=1):
self.image_file_name = f"Img/{file_name}"
scale *= SCREEN_MULTILPLIER
# Call the parent
super().__init__(self.image_file_name, scale, hit_box_algorithm="None")
@ -102,7 +109,7 @@ class Cubito(arcade.Window):
# Init parent class
super().__init__(int(SCREEN_WIDTH), int(SCREEN_HEIGHT), SCREEN_TITLE)
# Set background color
arcade.set_background_color(arcade.color.AMAZON)
arcade.set_background_color(BACKGROUND_COLOR)
# List of tokens
self.token_list = None
@ -122,6 +129,9 @@ class Cubito(arcade.Window):
# List of mats function
self.mat_function_list = None
# List of mats
self.image_list = None
def setup(self):
"""Set up the game"""
@ -136,12 +146,13 @@ class Cubito(arcade.Window):
self.mat_list = arcade.SpriteList()
self.start_mat_list = arcade.SpriteList()
self.mat_function_list = arcade.SpriteList()
self.image_list = arcade.SpriteList()
for y in range(TOKEN_ROW):
x = X_TOKEN_START
for token_type in TOKEN_TYPES:
#placer les tokens
token = Token_sprite(token_type, TOKEN_SCALE)
token = Token_sprite(token_type)
token.position = x, Y_TOKEN_START - Y_SPACING_TOKEN * y
x += X_SPACING_TOKEN
self.token_list.append(token)
@ -168,14 +179,22 @@ class Cubito(arcade.Window):
mat.position = X_MAT_START + X_SPACING_MAT * x, Y_MAT_FUNCTION_START - Y_SPACING_MAT * y
self.mat_function_list.append(mat)
# Placer les images
image = Image(file_name="case/Principal.png", scale=1)
image.position = X_START_MAIN_MAT_IMAGE, Y_START_MAIN_MAT_IMAGE
self.image_list.append(image)
def on_draw(self):
"""Render the screen"""
# Clear the screen
self.clear()
#Draw the images
self.image_list.draw()
#Draw the mat
self.mat_list.draw()
#self.mat_list.draw()
#Draw the start mat
self.start_mat_list.draw()
@ -287,7 +306,7 @@ class Cubito(arcade.Window):
cubito.left()
if token_type == "right":
cubito.right()
if token_type == "hamburger":
if token_type == "function":
self.cubito(function=True)