2024-01-27 11:42:01 +00:00
|
|
|
import turtle
|
2024-03-09 11:53:51 +00:00
|
|
|
import os.path
|
2024-01-27 11:42:01 +00:00
|
|
|
|
2024-03-09 11:53:51 +00:00
|
|
|
CURRENT_PATH = os.path.dirname(os.path.realpath(__file__))
|
2024-01-27 11:42:01 +00:00
|
|
|
# Cell size
|
|
|
|
distance = 90
|
|
|
|
|
2024-02-27 18:26:33 +00:00
|
|
|
def start():
|
|
|
|
# Set background - ocean
|
2024-03-09 11:53:51 +00:00
|
|
|
turtle.bgpic(f"{CURRENT_PATH}/background.png")
|
2024-01-27 11:42:01 +00:00
|
|
|
|
2024-02-27 18:26:33 +00:00
|
|
|
# Set turtle cusor
|
|
|
|
turtle.pensize(10)
|
|
|
|
turtle.pencolor("gray")
|
|
|
|
turtle.color("red", "lightgreen")
|
|
|
|
turtle.shape("turtle")
|
|
|
|
turtle.shapesize(2)
|
2024-01-27 11:42:01 +00:00
|
|
|
|
2024-02-27 18:26:33 +00:00
|
|
|
# Goto to first cell
|
|
|
|
turtle.penup()
|
|
|
|
turtle.goto(-225,225)
|
2024-03-16 16:16:40 +00:00
|
|
|
#turtle.pendown()
|
2024-01-27 11:42:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
def fordward():
|
|
|
|
"""
|
|
|
|
Forward fonction
|
|
|
|
"""
|
2024-03-16 16:30:22 +00:00
|
|
|
print(f"x : {turtle.xcor()}, y : {turtle.ycor()}")
|
2024-01-27 11:42:01 +00:00
|
|
|
turtle.forward(distance)
|
2024-03-16 16:30:22 +00:00
|
|
|
|
|
|
|
if turtle.xcor() > 226 or turtle.xcor() < -226:
|
2024-03-16 16:16:40 +00:00
|
|
|
turtle.backward(distance)
|
2024-03-16 16:30:22 +00:00
|
|
|
if turtle.ycor() > 226 or turtle.ycor() < -226:
|
2024-03-16 16:16:40 +00:00
|
|
|
turtle.backward(distance)
|
|
|
|
|
2024-01-27 11:42:01 +00:00
|
|
|
def left():
|
|
|
|
"""
|
|
|
|
Turn left fonction
|
|
|
|
"""
|
|
|
|
turtle.left(90)
|
|
|
|
|
|
|
|
def right():
|
|
|
|
"""
|
|
|
|
Turn right fonction
|
|
|
|
"""
|
|
|
|
turtle.right(90)
|
2024-02-27 18:26:33 +00:00
|
|
|
|
|
|
|
def reset():
|
|
|
|
turtle.clearscreen()
|
|
|
|
start()
|
|
|
|
|
|
|
|
|
|
|
|
start()
|