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

Program 2

The document is a script for an interactive program where a user is prompted to create a square using a turtle graphics interface. The user can set the pen width and color, and control the turtle's movement with arrow keys. The program responds to user inputs to change the turtle's direction and color based on the key pressed.

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 2

The document is a script for an interactive program where a user is prompted to create a square using a turtle graphics interface. The user can set the pen width and color, and control the turtle's movement with arrow keys. The program responds to user inputs to change the turtle's direction and color based on the key pressed.

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

TextWindow.WriteLine("Hi, I'm Mr. Smort.

")
TextWindow.WriteLine("You are going to make a square.")
TextWindow.Write("What is your name?")
name = TextWindow.Read()
TextWindow.WriteLine("Hi, " + name)
TextWindow.Write("Choose a number from 1 to 50.")
number = TextWindow.ReadNumber()
GraphicsWindow.PenWidth = number
TextWindow.Write("Black, Red, Green, Blue, or Multicolour?")
color = TextWindow.Read()
If color = "black" Then
GraphicsWindow.PenColor = "black"
ElseIf color = "red" Then
GraphicsWindow.PenColor = "red"
ElseIf color = "green" Then
GraphicsWindow.PenColor = "green"
ElseIf color = "blue" Then
GraphicsWindow.PenColor = "blue"
ElseIf color = "multicolour" Then
EndIf
Turtle.Show()

SME = GraphicsWindow.KeyDown
Sub SME
If GraphicsWindow.LastKey = "ArrowUp" Then
GraphicsWindow.PenColor = "red"
Turtle.Move(15)
EndIf
If GraphicsWindow.LastKey = "ArrowDown" Then
GraphicsWindow.PenColor = "blue"
Turtle.Move(-15)
EndIf
If GraphicsWindow.LastKey = "ArrowLeft" Then
GraphicsWindow.PenColor = "black"
Turtle.TurnLeft()
Turtle.Move(15)
EndIf
If GraphicsWindow.LastKey = "ArrowRight" Then
GraphicsWindow.PenColor = "green"
Turtle.TurnRight()
Turtle.Move(15)
EndIf
EndSub

You might also like