Try to add square for the carptet

This commit is contained in:
mdl29 2024-04-24 17:21:04 +02:00
parent ed319f0a2e
commit 26f7665d12

View File

@ -1,4 +1,5 @@
import arcade
from itertools import count
import jacovirt.logger
import logging
@ -8,8 +9,65 @@ SCREEN_MULTILPLIER = 1
SCREEN_WIDTH = int(1000 * SCREEN_MULTILPLIER)
SCREEN_HEIGHT = int(1000 * SCREEN_MULTILPLIER)
# Window color
BACKGROUND_COLOR = arcade.color.CATALINA_BLUE
BACKGROUND_COLOR = arcade.color.OXFORD_BLUE
# Margin between mat & screen side
VERTICAL_MARGIN_PERCENT = 0.10
HORIZONTAL_MARGIN_PERCENT = 0.10
# Token size
TOKEN_SCALE = 0.5
TOKEN_HEIGHT = 75 * TOKEN_SCALE
TOKEN_WIDTH = 75 * TOKEN_SCALE
# Space between tokens
X_SPACING_TOKEN = TOKEN_WIDTH + TOKEN_WIDTH * HORIZONTAL_MARGIN_PERCENT
Y_SPACING_TOKEN = TOKEN_HEIGHT + TOKEN_HEIGHT * VERTICAL_MARGIN_PERCENT
# List of token types
TOKEN_TYPES = ["FORDWARD", "RIGHT", "LEFT", "PAUSE", "FUNCTION"]
# Mat size
MAT_PERCENT_OVERSIZE = 1.25
MAT_HEIGHT = int(TOKEN_HEIGHT * MAT_PERCENT_OVERSIZE)
MAT_WIDTH = int(TOKEN_WIDTH * MAT_PERCENT_OVERSIZE)
# Number of column & row mat
MAT_COLUMN = 4
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
# Top for mats
TOP_Y = SCREEN_HEIGHT - MAT_HEIGHT - MAT_HEIGHT * VERTICAL_MARGIN_PERCENT
# Bottom for tokens
BOTTOM_Y = MAT_HEIGHT / 2 + MAT_HEIGHT * VERTICAL_MARGIN_PERCENT
# Start from left side
START_X = MAT_WIDTH / 2 + MAT_WIDTH * HORIZONTAL_MARGIN_PERCENT
# Mat pos
X_MAT_POS = START_X + SCREEN_WIDTH / 2
Y_MAT_POS = TOP_Y
class Case(arcade.SpriteSolidColor):
"""Case sprite"""
# Count instance mat classes
ids = count(0)
def __init__(self, wigth, height, color=arcade.color.BLEU_DE_FRANCE):
# Get id from number of instance classes
self.id = next(self.ids)
# Init parent class
super().__init__(wigth, height, color)
class Bot(arcade.Window):
"""Main application class"""
@ -20,9 +78,25 @@ class Bot(arcade.Window):
# Set background color
arcade.set_background_color(BACKGROUND_COLOR)
self.mat_list = None
def setup(self):
"""Set up the pad"""
"""Set up the bot"""
logging.info("Set up the bot.")
self.mat_list = arcade.SpriteList()
for y in range(MAT_ROW):
# Create the top "play" piles
for x in range(MAT_COLUMN):
mat = Case(MAT_WIDTH, MAT_HEIGHT)
mat.position = (
X_MAT_POS + X_SPACING_MAT * x,
Y_MAT_POS - Y_SPACING_MAT * y - 60
)
self.mat_list.append(mat)
def on_draw(self):
"""Render the screen"""
@ -30,6 +104,9 @@ class Bot(arcade.Window):
# Clear the screen
self.clear()
arcade.draw_lrwh_rectangle_textured(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, arcade.color.QUEEN_BLUE)
def on_key_press(self, symbol, modifiers):
"""Called when the user presses key"""
if symbol == arcade.key.R: