LPH-cubito/cubito.py

54 lines
989 B
Python
Raw Permalink Normal View History

2024-01-27 11:42:01 +00:00
import turtle
import os.path
2024-01-27 11:42:01 +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
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
"""
print(f"x : {turtle.xcor()}, y : {turtle.ycor()}")
2024-01-27 11:42:01 +00:00
turtle.forward(distance)
if turtle.xcor() > 226 or turtle.xcor() < -226:
2024-03-16 16:16:40 +00:00
turtle.backward(distance)
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()