forked from MDL29/JacoBot
Compare commits
1 Commits
main
...
test_turlt
Author | SHA1 | Date | |
---|---|---|---|
0f0e5eb512 |
|
@ -1,4 +1,4 @@
|
|||
from turtle import *
|
||||
import turtle
|
||||
|
||||
"""host = "192.168.20.49"
|
||||
channel = "LPH"
|
||||
|
@ -9,68 +9,90 @@ r = redis.Redis(host=host)
|
|||
p = r.pubsub()
|
||||
p.psubscribe(channel)
|
||||
"""
|
||||
|
||||
DISTANCE = 84
|
||||
X_START = -210
|
||||
Y_START = 194
|
||||
|
||||
angle = 0
|
||||
|
||||
def cubetto_init():
|
||||
turtle.bgpic("fond.png")
|
||||
turtle.register_shape("Cubetto_forme_haut.gif")
|
||||
turtle.register_shape("Cubetto_forme_bas.gif")
|
||||
turtle.register_shape("Cubetto_forme_gauche.gif")
|
||||
turtle.register_shape("Cubetto_forme_droite.gif")
|
||||
turtle.shape("Cubetto_forme_droite.gif")
|
||||
turtle.shapesize(3,3,6)
|
||||
turtle.penup()
|
||||
turtle.goto(-210,194)
|
||||
|
||||
def cubetto_forme_init():
|
||||
global angle
|
||||
if angle == 360 or angle == -360:
|
||||
angle=0
|
||||
if angle == 0:
|
||||
turtle.shape("Cubetto_forme_droite.gif")
|
||||
if angle == 90 or angle == -270:
|
||||
turtle.shape("Cubetto_forme_haut.gif")
|
||||
if angle == 180 or angle == -180:
|
||||
turtle.shape("Cubetto_forme_gauche.gif")
|
||||
if angle == 270 or angle == -90:
|
||||
turtle.shape("Cubetto_forme_bas.gif")
|
||||
|
||||
def cubetto_forward():
|
||||
turtle.forward(DISTANCE)
|
||||
print(turtle.pos())
|
||||
|
||||
if turtle.xcor() < X_START-1:
|
||||
turtle.backward(DISTANCE)
|
||||
print("Sortie a gauche")
|
||||
|
||||
elif turtle.xcor() > X_START+DISTANCE*5:
|
||||
turtle.backward(DISTANCE)
|
||||
print("Sortie a droit")
|
||||
|
||||
elif turtle.ycor() > Y_START+1:
|
||||
turtle.backward(DISTANCE)
|
||||
print("Sortie en haut")
|
||||
|
||||
elif turtle.ycor() < Y_START-DISTANCE*5:
|
||||
turtle.backward(DISTANCE)
|
||||
print("Sotrie en bas")
|
||||
|
||||
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()
|
||||
|
||||
def cubetto_backward():
|
||||
turtle.right(180)
|
||||
turtle.forward(84)
|
||||
turtle.right(180)
|
||||
|
||||
cubetto_init()
|
||||
|
||||
def main():
|
||||
|
||||
angle = 0
|
||||
|
||||
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)
|
||||
|
||||
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")
|
||||
|
||||
def cubetto_forward():
|
||||
forward(84)
|
||||
|
||||
def cubetto_left():
|
||||
global angle
|
||||
left(90)
|
||||
angle += 90
|
||||
cubetto_forme_init()
|
||||
|
||||
def cubetto_right():
|
||||
global angle
|
||||
right(90)
|
||||
angle -= 90
|
||||
cubetto_forme_init()
|
||||
|
||||
def cubetto_backward():
|
||||
right(180)
|
||||
forward(84)
|
||||
right(180)
|
||||
|
||||
cubetto_init()
|
||||
|
||||
while True:
|
||||
message = []
|
||||
|
||||
if message == "FORDWARD":
|
||||
message = input("Action : ")
|
||||
if message == "f":
|
||||
cubetto_forward()
|
||||
elif message == "LEFT":
|
||||
elif message == "l":
|
||||
cubetto_left()
|
||||
elif message == "RIGHT":
|
||||
elif message == "r":
|
||||
cubetto_right()
|
||||
elif message == "i":
|
||||
cubetto_init()
|
||||
elif message == "FUNCTION":
|
||||
pass
|
||||
|
||||
|
||||
|
||||
main()
|
Loading…
Reference in New Issue
Block a user