From 719527317ad4ee50c91439ff77b65fe0a68bd236 Mon Sep 17 00:00:00 2001 From: HS-157 Date: Sat, 27 Jan 2024 12:42:01 +0100 Subject: [PATCH] Init commit --- .gitignore | 162 ++++++++++++++++++++++++++++++++++++++++++++ cubito.py | 38 +++++++++++ tablette_arcarde.py | 114 +++++++++++++++++++++++++++++++ 3 files changed, 314 insertions(+) create mode 100644 .gitignore create mode 100644 cubito.py create mode 100644 tablette_arcarde.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3a8816c --- /dev/null +++ b/.gitignore @@ -0,0 +1,162 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm-project.org/#use-with-ide +.pdm.toml +.pdm-python +.pdm-build/ + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/cubito.py b/cubito.py new file mode 100644 index 0000000..d56c228 --- /dev/null +++ b/cubito.py @@ -0,0 +1,38 @@ +import turtle + +# Cell size +distance = 90 + +# Set background - ocean +turtle.bgpic("background.png") + +# Set turtle cusor +turtle.pensize(10) +turtle.pencolor("gray") +turtle.color("red", "lightgreen") +turtle.shape("turtle") +turtle.shapesize(2) + +# Goto to first cell +turtle.penup() +turtle.goto(-225,225) +turtle.pendown() + + +def fordward(): + """ + Forward fonction + """ + turtle.forward(distance) + +def left(): + """ + Turn left fonction + """ + turtle.left(90) + +def right(): + """ + Turn right fonction + """ + turtle.right(90) diff --git a/tablette_arcarde.py b/tablette_arcarde.py new file mode 100644 index 0000000..4162940 --- /dev/null +++ b/tablette_arcarde.py @@ -0,0 +1,114 @@ +""" +Cubito +""" + +import arcade +# import cubito + +# Screen title and size +SCREEN_TITLE = "Cubito" +SCREEN_WIDTH = 500 +SCREEN_HEIGHT = 500 + +# 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 + + +class Cubito(arcade.Window): + """Main application class""" + + def __init__(self): + # Init parent class + super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) + # Set background color + arcade.set_background_color(arcade.color.AMAZON) + + # List of tokens + self.token_list = None + + # Hold token + self.held_token = None + + # Origin pos for hold token + self.held_token_original_position = None + + # List of mats + self.mat_list = None + + # List of mats function + self.mat_function_list = None + + def setup(self): + """Set up the game""" + ... + + def on_draw(self): + """Render the screen""" + # Clear the screen + arcade.start_render() + + def on_mouse_press(self, x, y, button, key_modifiers): + """Called when the user presses a mouse button""" + ... + + def on_mouse_release(self, x, y, button, modifiers): + """Called when the user presses a mouse button""" + ... + + def on_mouse_motion(self, x, y, dx, dy): + """Called when the user moves the mouse""" + ... + + def on_key_press(self, symbol, modifiers): + """Called when the user presses key""" + ... + + def cubito(self, function=False): + """Move cubito !""" + ... + +def main(): + """Main method""" + window = Cubito() + window.setup() + arcade.run() + + +if __name__ == "__main__": + main()