Improve JacoVirt Bot with dark & light theme
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.5 KiB |
BIN
jacovirt/jacovirt/Img/Background_dark.png
Normal file
After Width: | Height: | Size: 455 KiB |
BIN
jacovirt/jacovirt/Img/Background_light.png
Normal file
After Width: | Height: | Size: 412 KiB |
BIN
jacovirt/jacovirt/Img/Cubetto_forme_bas_dark.gif
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
jacovirt/jacovirt/Img/Cubetto_forme_bas_light.gif
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
jacovirt/jacovirt/Img/Cubetto_forme_droite_dark.gif
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
jacovirt/jacovirt/Img/Cubetto_forme_droite_light.gif
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
jacovirt/jacovirt/Img/Cubetto_forme_gauche_dark.gif
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
jacovirt/jacovirt/Img/Cubetto_forme_gauche_light.gif
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
jacovirt/jacovirt/Img/Cubetto_forme_haut_dark.gif
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
jacovirt/jacovirt/Img/Cubetto_forme_haut_light.gif
Normal file
After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 414 KiB |
|
@ -3,63 +3,138 @@ from turtle import *
|
|||
"""host = "192.168.20.49"
|
||||
channel = "LPH"
|
||||
|
||||
# Connexion à Redis
|
||||
r = redis.Redis(host=host)
|
||||
poscubettox = 0
|
||||
poscubettoy = 0
|
||||
|
||||
xstart = 0
|
||||
ystart = 0
|
||||
|
||||
xmax = 5
|
||||
ymax = 5
|
||||
|
||||
distance = 0
|
||||
angle = 0
|
||||
|
||||
theme = 0
|
||||
|
||||
p = r.pubsub()
|
||||
p.psubscribe(channel)
|
||||
"""
|
||||
def main():
|
||||
|
||||
angle = 0
|
||||
def dark_theme():
|
||||
global posxstart, posystart, distance, theme
|
||||
with resources.path("jacovirt", 'Img') as img_folder :
|
||||
turtle.bgpic(str(img_folder/ "Background_dark.png"))
|
||||
|
||||
turtle.shape(str(img_folder/ "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/ "Background_light.png"))
|
||||
|
||||
turtle.shape(str(img_folder/ "Cubetto_forme_droite_light.gif"))
|
||||
turtle.shapesize(10,10,6)
|
||||
|
||||
distance = 90
|
||||
|
||||
posxstart = -226
|
||||
posystart = 225
|
||||
|
||||
theme = 2
|
||||
|
||||
def cubetto_init():
|
||||
|
||||
bgpic("fond.png")
|
||||
register_shape("Cubetto_forme_haut.gif")
|
||||
register_shape("Cubetto_forme_bas.gif")
|
||||
register_shape("Cubetto_forme_gauche.gif")
|
||||
register_shape("Cubetto_forme_droite.gif")
|
||||
shape("Cubetto_forme_droite.gif")
|
||||
shapesize(3,3,6)
|
||||
penup()
|
||||
goto(-210,194)
|
||||
global posxstart, posystart, distance
|
||||
with resources.path("jacovirt", 'Img') as img_folder :
|
||||
turtle.register_shape(str(img_folder/ "Cubetto_forme_haut_dark.gif"))
|
||||
turtle.register_shape(str(img_folder/ "Cubetto_forme_bas_dark.gif"))
|
||||
turtle.register_shape(str(img_folder/ "Cubetto_forme_gauche_dark.gif"))
|
||||
turtle.register_shape(str(img_folder/ "Cubetto_forme_droite_dark.gif"))
|
||||
turtle.register_shape(str(img_folder/ "Cubetto_forme_haut_light.gif"))
|
||||
turtle.register_shape(str(img_folder/ "Cubetto_forme_bas_light.gif"))
|
||||
turtle.register_shape(str(img_folder/ "Cubetto_forme_gauche_light.gif"))
|
||||
turtle.register_shape(str(img_folder/ "Cubetto_forme_droite_light.gif"))
|
||||
|
||||
dark_theme()
|
||||
|
||||
turtle.penup()
|
||||
turtle.goto(posxstart, posystart)
|
||||
|
||||
def cubetto_forme_init():
|
||||
global angle
|
||||
if angle == 360 or angle == -360:
|
||||
angle=0
|
||||
if angle == 0:
|
||||
shape("Cubetto_forme_droite.gif")
|
||||
if angle == 90 or angle == -270:
|
||||
shape("Cubetto_forme_haut.gif")
|
||||
if angle == 180 or angle == -180:
|
||||
shape("Cubetto_forme_gauche.gif")
|
||||
if angle == 270 or angle == -90:
|
||||
shape("Cubetto_forme_bas.gif")
|
||||
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/ "Cubetto_forme_droite_dark.gif"))
|
||||
elif theme == 2:
|
||||
turtle.shape(str(img_folder/ "Cubetto_forme_droite_light.gif"))
|
||||
if angle == 90 or angle == -270:
|
||||
if theme == 1:
|
||||
turtle.shape(str(img_folder/ "Cubetto_forme_haut_dark.gif"))
|
||||
elif theme == 2:
|
||||
turtle.shape(str(img_folder/ "Cubetto_forme_haut_light.gif"))
|
||||
if angle == 180 or angle == -180:
|
||||
if theme == 1:
|
||||
turtle.shape(str(img_folder/ "Cubetto_forme_gauche_dark.gif"))
|
||||
elif theme == 2:
|
||||
turtle.shape(str(img_folder/ "Cubetto_forme_gauche_light.gif"))
|
||||
if angle == 270 or angle == -90:
|
||||
if theme == 1:
|
||||
turtle.shape(str(img_folder/ "Cubetto_forme_bas_dark.gif"))
|
||||
elif theme == 2:
|
||||
turtle.shape(str(img_folder/ "Cubetto_forme_bas_light.gif"))
|
||||
|
||||
def cubetto_forward():
|
||||
forward(84)
|
||||
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
|
||||
left(90)
|
||||
turtle.left(90)
|
||||
angle += 90
|
||||
cubetto_forme_init()
|
||||
|
||||
def cubetto_right():
|
||||
global angle
|
||||
right(90)
|
||||
turtle.right(90)
|
||||
angle -= 90
|
||||
cubetto_forme_init()
|
||||
|
||||
def cubetto_backward():
|
||||
right(180)
|
||||
forward(84)
|
||||
right(180)
|
||||
|
||||
cubetto_init()
|
||||
|
||||
|
||||
while True:
|
||||
message = []
|
||||
|
||||
|
@ -74,3 +149,4 @@ def main():
|
|||
elif message == "FUNCTION":
|
||||
pass
|
||||
|
||||
main()
|