import turtle
import random
def clear_screen():
response = screen.textinput("Clear Screen", "Type 'yes' to clear the page:")
if response and response.lower() == "yes":
screen.clearscreen()
return "yes"
else:
return"no"
def plot_zigzag():
border_turtle.speed(0)
border_turtle.penup()
border_turtle.goto(-270, -240)
border_turtle.pendown()
for i in range(18):
border_turtle.left(60)
border_turtle.forward(30)
border_turtle.right(120)
border_turtle.forward(30)
border_turtle.left(60)
def title(text):
layout_turtle = turtle.Turtle()
layout_turtle.penup()
layout_turtle.goto(0, 250)
layout_turtle.color("black")
layout_turtle.write(text, align="center", font=("Arial", 24, "bold"))
layout_turtle.hideturtle()
def display_text(text):
writer = turtle.Turtle()
writer.hideturtle()
writer.penup()
writer.speed(0)
font = ("Arial", 16, "normal")
line_spacing = 24
x_start = -300
y_start = 235
writer.goto(x_start, y_start)
for line in text.split("\n"):
writer.write(line, font=font)
y_start -= line_spacing
writer.goto(x_start, y_start)
screen = turtle.Screen()
screen.title("Text Adventure Game Character Page")
screen.setup(width=800, height=600)
screen.bgcolor("lightgrey")
stats = {
"Strength": random.randint(8, 18),
"Dexterity": random.randint(8, 18),
"Constitution": random.randint(8, 18),
"Intelligence": random.randint(8, 18),
"Wisdom": random.randint(8, 18),
"Charisma": random.randint(8, 18)
}
layout_turtle = turtle.Turtle()
layout_turtle.speed(0)
layout_turtle.penup()
y_position = 130
layout_turtle.pensize(3)
for stat, value in stats.items():
layout_turtle.goto(80, y_position)
layout_turtle.color("black", "yellow")
layout_turtle.pendown()
layout_turtle.begin_fill()
for _ in range(2):
layout_turtle.forward(200)
layout_turtle.right(90)
layout_turtle.forward(50)
layout_turtle.right(90)
layout_turtle.end_fill()
layout_turtle.penup()
layout_turtle.goto(110, y_position - 35)
layout_turtle.color("black")
layout_turtle.write(f"{stat}: {value}", font=("Arial", 14, "normal"))
y_position -= 55
layout_turtle.penup()
layout_turtle.goto(-300, 250)
layout_turtle.pendown()
layout_turtle.pensize(5)
layout_turtle.color("black")
for _ in range(2):
layout_turtle.forward(600)
layout_turtle.right(90)
layout_turtle.forward(500)
layout_turtle.right(90)
layout_turtle.penup()
layout_turtle.goto(0, 260)
layout_turtle.write("Epic Text Adventure Character Sheet", align="center",
font=("Arial", 20, "bold"))
border_turtle = turtle.Turtle()
border_turtle.penup()
border_turtle.goto(80, 220)
border_turtle.pendown()
border_turtle.pensize(4)
border_turtle.color("black","lightgreen")
border_turtle.begin_fill()
for _ in range(2):
border_turtle.forward(200)
border_turtle.right(90)
border_turtle.forward(80)
border_turtle.right(90)
border_turtle.end_fill()
border_turtle.penup()
layout_turtle.goto(100, 180)
layout_turtle.write("Race: Elf", font=("Arial", 16, "normal"))
layout_turtle.goto(100, 150)
layout_turtle.write("Class: Ranger", font=("Arial", 16, "normal"))
layout_turtle.goto(-275, 200)
layout_turtle.pendown()
layout_turtle.color("black")
layout_turtle.begin_fill()
layout_turtle.fillcolor("white")
for _ in range(2):
layout_turtle.forward(150)
layout_turtle.right(90)
layout_turtle.forward(150)
layout_turtle.right(90)
layout_turtle.end_fill()
layout_turtle.penup()
layout_turtle.goto(-280, 210)
layout_turtle.color("black")
layout_turtle.write("Arannis the Brave", font=("Arial", 16, "italic"))
try:
screen.addshape("character.gif")
except Exception as e:
print("Image could not be loaded:", e)
portrait_turtle = turtle.Turtle()
portrait_turtle.penup()
portrait_turtle.shape("character.gif")
portrait_turtle.goto(-200, 125)
portrait_turtle.stamp()
plot_zigzag()
layout_turtle.hideturtle()
portrait_turtle.penup()
layout_turtle.goto(-280, -35)
layout_turtle.color("black", "orange")
layout_turtle.pendown()
layout_turtle.begin_fill()
for _ in range(2):
layout_turtle.forward(350)
layout_turtle.right(90)
layout_turtle.forward(160)
layout_turtle.right(90)
layout_turtle.end_fill()
layout_turtle.penup()
layout_turtle.goto(-260, -190)
layout_turtle.color("black")
character_description = (
"Arannis the Brave:\n"
"\n"
"Arannis is a skilled Elven Ranger,\n"
"hailing from the ancient woods.\n"
"With unmatched agility and a keen\n"
"sense of wisdom, Arannis protects \n"
"the realm from dark forces lurking \n"
"beyond the forests."
)
layout_turtle.write(character_description, align="left", font=("Arial", 12, "bold"))
answer = clear_screen()
if answer == "yes":
screen.bgcolor("lightblue")
title("Turtle Adventure ")
intro_text = """
The moon hangs low in the ink-black sky, its pale
light barely piercing the dense canopy of towering trees that
surround you. Shadows dance and flicker with every subtle movement
of the wind, their shapes twisting into eerie forms that vanish
as quickly as they appear.
You find yourself in the heart of an ancient forest. The air is
heavy with the scent of damp earth and pine, and the soft crunch
of fallen leaves beneath your feet is the only sound you can control.
All around you, strange noises fill the night: a distant howl, the
rustling of unseen creatures, and the occasional snap of a branch
too close for comfort.
You are alone—or at least, you think you are.
Will you brave the unknown depths of the forest, or will fear
root you to the spot?
Your adventure begins now..."""
display_text(intro_text)
answer = clear_screen()
turtle.done()