git fix 2 git add *
|
@ -1 +0,0 @@
|
|||
# JacoVirt
|
Before Width: | Height: | Size: 455 KiB |
Before Width: | Height: | Size: 412 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 23 KiB |
|
@ -1,160 +0,0 @@
|
|||
import turtle
|
||||
from importlib import resources
|
||||
import math
|
||||
from time import sleep
|
||||
import redis
|
||||
|
||||
r = redis.Redis(host="localhost")
|
||||
|
||||
mobile = r.pubsub()
|
||||
|
||||
mobile.subscribe('jacobot-instructions')
|
||||
|
||||
poscubettox = 0
|
||||
poscubettoy = 0
|
||||
|
||||
xstart = 0
|
||||
ystart = 0
|
||||
|
||||
xmax = 5
|
||||
ymax = 5
|
||||
|
||||
distance = 0
|
||||
angle = 0
|
||||
|
||||
theme = 0
|
||||
|
||||
def main():
|
||||
|
||||
def dark_theme():
|
||||
global posxstart, posystart, distance, theme
|
||||
with resources.path("jacovirt", 'Img') as img_folder :
|
||||
turtle.bgpic(str(img_folder/ "bot" / "background" / "Background_dark.png"))
|
||||
|
||||
turtle.shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_droite_dark.gif"))
|
||||
turtle.shapesize(3,3,6)
|
||||
|
||||
distance = 84
|
||||
|
||||
posxstart = -211
|
||||
posystart = 200
|
||||
|
||||
theme = 1
|
||||
|
||||
def light_theme():
|
||||
global posxstart, posystart, distance, theme
|
||||
with resources.path("jacovirt", 'Img') as img_folder :
|
||||
turtle.bgpic(str(img_folder/ "bot" / "background" / "Background_light.png"))
|
||||
|
||||
turtle.shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_droite_light.gif"))
|
||||
turtle.shapesize(10,10,6)
|
||||
|
||||
distance = 90
|
||||
|
||||
posxstart = -226
|
||||
posystart = 225
|
||||
|
||||
theme = 2
|
||||
|
||||
def cubetto_init():
|
||||
global posxstart, posystart, distance
|
||||
with resources.path("jacovirt", 'Img') as img_folder :
|
||||
turtle.register_shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_haut_dark.gif"))
|
||||
turtle.register_shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_bas_dark.gif"))
|
||||
turtle.register_shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_gauche_dark.gif"))
|
||||
turtle.register_shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_droite_dark.gif"))
|
||||
turtle.register_shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_haut_light.gif"))
|
||||
turtle.register_shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_bas_light.gif"))
|
||||
turtle.register_shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_gauche_light.gif"))
|
||||
turtle.register_shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_droite_light.gif"))
|
||||
|
||||
dark_theme()
|
||||
|
||||
turtle.penup()
|
||||
turtle.goto(posxstart, posystart)
|
||||
|
||||
def cubetto_forme_init():
|
||||
global angle, theme
|
||||
with resources.path("jacovirt", 'Img') as img_folder :
|
||||
if angle == 360 or angle == -360:
|
||||
angle=0
|
||||
if angle == 0:
|
||||
if theme == 1:
|
||||
turtle.shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_droite_dark.gif"))
|
||||
elif theme == 2:
|
||||
turtle.shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_droite_light.gif"))
|
||||
if angle == 90 or angle == -270:
|
||||
if theme == 1:
|
||||
turtle.shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_haut_dark.gif"))
|
||||
elif theme == 2:
|
||||
turtle.shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_haut_light.gif"))
|
||||
if angle == 180 or angle == -180:
|
||||
if theme == 1:
|
||||
turtle.shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_gauche_dark.gif"))
|
||||
elif theme == 2:
|
||||
turtle.shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_gauche_light.gif"))
|
||||
if angle == 270 or angle == -90:
|
||||
if theme == 1:
|
||||
turtle.shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_bas_dark.gif"))
|
||||
elif theme == 2:
|
||||
turtle.shape(str(img_folder/ "bot" / "cubetto" /"Cubetto_forme_bas_light.gif"))
|
||||
|
||||
def cubetto_forward():
|
||||
global xmax, ymax, xstart, ystart, distance, poscubettox, poscubettoy
|
||||
|
||||
FuturXRight = (poscubettox+1)
|
||||
FuturXLeft = (poscubettox-1)
|
||||
FuturYTop = (poscubettoy-1)
|
||||
FuturYBottom = (poscubettoy+1)
|
||||
|
||||
turtle.forward(distance)
|
||||
|
||||
if angle == 0 and FuturXRight <= xmax:
|
||||
poscubettox += 1
|
||||
|
||||
elif (angle == 90 or angle == -270) and FuturYTop >= ystart:
|
||||
poscubettoy -= 1
|
||||
|
||||
elif (angle == 180 or angle == -180) and FuturXLeft >= xstart:
|
||||
poscubettox -= 1
|
||||
|
||||
elif (angle == 270 or angle == -90) and FuturYBottom <= ymax:
|
||||
poscubettoy += 1
|
||||
|
||||
else:
|
||||
print("You are out of the carpet !")
|
||||
exit()
|
||||
|
||||
def cubetto_left():
|
||||
global angle
|
||||
turtle.left(90)
|
||||
angle += 90
|
||||
cubetto_forme_init()
|
||||
|
||||
def cubetto_right():
|
||||
global angle
|
||||
turtle.right(90)
|
||||
angle -= 90
|
||||
cubetto_forme_init()
|
||||
|
||||
cubetto_init()
|
||||
|
||||
while True:
|
||||
for m_recu in mobile.listen():
|
||||
|
||||
if m_recu:
|
||||
m_data = m_recu["data"]
|
||||
|
||||
if m_data == b"FORWARD":
|
||||
cubetto_forward()
|
||||
elif m_data == b"LEFT":
|
||||
cubetto_left()
|
||||
elif m_data == b"RIGHT":
|
||||
cubetto_right()
|
||||
elif m_data == b"INIT":
|
||||
cubetto_init()
|
||||
elif m_data == b"EXIT":
|
||||
exit()
|
||||
sleep(0.3)
|
||||
|
||||
main()
|
|
@ -1,48 +0,0 @@
|
|||
import arcade
|
||||
|
||||
|
||||
# Screen title and size
|
||||
SCREEN_TITLE = "Jaco Pad"
|
||||
SCREEN_MULTILPLIER = 1
|
||||
SCREEN_WIDTH = int(1000* SCREEN_MULTILPLIER)
|
||||
SCREEN_HEIGHT = int(1000* SCREEN_MULTILPLIER)
|
||||
|
||||
# Window color
|
||||
BACKGROUND_COLOR = (133, 100, 100)
|
||||
|
||||
|
||||
|
||||
class Pad(arcade.Window):
|
||||
"""Main application class"""
|
||||
|
||||
def __init__(self):
|
||||
# Init parent class
|
||||
super().__init__(int(SCREEN_WIDTH), int(SCREEN_HEIGHT), SCREEN_TITLE)
|
||||
# Set background color
|
||||
arcade.set_background_color(BACKGROUND_COLOR)
|
||||
|
||||
def setup(self):
|
||||
"""Set up the pad"""
|
||||
...
|
||||
|
||||
def on_draw(self):
|
||||
"""Render the screen"""
|
||||
|
||||
# Clear the screen
|
||||
self.clear()
|
||||
|
||||
def on_key_press(self, symbol, modifiers):
|
||||
"""Called when the user presses key"""
|
||||
if symbol == arcade.key.R:
|
||||
self.setup()
|
||||
print("Restart !")
|
||||
|
||||
if symbol == arcade.key.Q:
|
||||
arcade.exit()
|
||||
|
||||
|
||||
def main():
|
||||
"""Main method"""
|
||||
window = Pad()
|
||||
window.setup()
|
||||
arcade.run()
|
|
@ -1,23 +0,0 @@
|
|||
[tool.poetry]
|
||||
name = "jacovirt"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["LPH"]
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.11"
|
||||
arcade = "^2.6.17"
|
||||
redis = "^5.0.3"
|
||||
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
jacovirt-bot = "jacovirt.jacobot:main"
|
||||
jacovirt-pad = "jacovirt.pad.window:main"
|
||||
|
||||
[[tool.poetry.include]]
|
||||
path = "jacovirt/jacovirt/Img/*"
|