0% found this document useful (0 votes)
2 views

Program 3

The document describes a simple interactive program where a user can draw shapes using a turtle graphics interface. It prompts the user for their name, pen thickness, and color preferences, allowing navigation with arrow keys. The program changes the turtle's pen color based on user input or predefined colors associated with arrow key movements.

Uploaded by

rishabhunni0912
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Program 3

The document describes a simple interactive program where a user can draw shapes using a turtle graphics interface. It prompts the user for their name, pen thickness, and color preferences, allowing navigation with arrow keys. The program changes the turtle's pen color based on user input or predefined colors associated with arrow key movements.

Uploaded by

rishabhunni0912
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Turtle.

Show()
GraphicsWindow.BackgroundColor = "black"
TextWindow.WriteLine("Hi, I'm Mr. Smort.")
TextWindow.WriteLine("I can help you draw a square or rectangle. Use me to
navigate.")
TextWindow.Write("What is your name?")
name = TextWindow.Read()
TextWindow.WriteLine("Hi, " + name)
TextWindow.Write("Choose a number from 1 to 25 to define the thickness of your
pen.")
number = TextWindow.ReadNumber()
GraphicsWindow.PenWidth = number
TextWindow.Write("Your colour is currently multicolour.")
TextWindow.Write("To change it Choose 'yes'/'no'")
answer = TextWindow.Read()

If answer = "yes" then


TextWindow.Write("Which colour would you like to choose?")
colour = TextWindow.Read()
GraphicsWindow.PenColor = colour
TextWindow.WriteLine("You can begin..use the arrow keys to navigate. Have fun!")
Else
TextWindow.Write ("Continuing with multicolour mode")
EndIf

GraphicsWindow.KeyDown = SME

Sub SME
If answer = "yes" then
GraphicsWindow.PenColor = colour
Else
If GraphicsWindow.LastKey = "ArrowUp" Then
GraphicsWindow.PenColor = "red"
ElseIf GraphicsWindow.LastKey = "ArrowDown" Then
GraphicsWindow.PenColor = "blue"
ElseIf GraphicsWindow.LastKey = "ArrowLeft" Then
GraphicsWindow.PenColor = "green"
ElseIf GraphicsWindow.LastKey = "ArrowRight" Then
GraphicsWindow.PenColor = "cyan"
EndIf
EndIf

If GraphicsWindow.LastKey = "ArrowRight" Then


Turtle.TurnRight()
Turtle.Move(80)
ElseIf GraphicsWindow.LastKey = "ArrowLeft" Then
Turtle.TurnLeft()
Turtle.Move(80)
ElseIf GraphicsWindow.LastKey = "ArrowUp" Then
Turtle.Move(15)
ElseIf GraphicsWindow.LastKey = "ArrowDown" Then
Turtle.Move(-15)
EndIf
EndSub

You might also like