def tour():
sprite = codesters.Sprite("person1", -150, -60)
sprite.say("I can take you on a tour")
sprite.move_forward(550)
tour()
variable = "x"
y = 225
spacing = 30
line1 = codesters.Text("def tour():", -163, y-1, "black")
y -= spacing
indent = codesters.Rectangle(-190, y, 30, 20, "green")
line2 = codesters.Text(" = codesters.Sprite( )", -18, y, "black")
line2a = codesters.Text("sprite", -145, y, "orange")
line2b = codesters.Text('"person1"', 96, y, "lightgreen")
y -= spacing
indent = codesters.Rectangle(-190, y, 30, 20, "green")
line3 = codesters.Text(".say( )", 25, y, "black")
line3a = codesters.Text("sprite", -145, y, "orange")
line3b = codesters.Text('"I can take you on a tour!"', 45, y, "lightgreen")
y -= spacing
indent = codesters.Rectangle(-190, y, 30, 20, "green")
line4 = codesters.Text(".move_forward( )", -25, y, "black")
line4a = codesters.Text("sprite", -145, y, "orange")
line4b = codesters.Text('550', 42, y, "dodgerblue")
y -= spacing * 1.5
line5 = codesters.Text("tour()", -180, y, "black")
y = 90
highlight = codesters.Rectangle(-25, y, 400, spacing, None, "black")
highlight.set_opacity(.8)
counter = 0
# my_display = codesters.Display(counter, -200, -100)
explanation = codesters.Text("This line calls the function using the function's name.", 0, -75, "green")
guide = codesters.Sprite("person7", 0, -250)
# my_display = codesters.Display(counter, -200, -150)
text = codesters.Text("Next Step", 0, -115)
def click():
global sprite
global counter
if highlight.get_y() == 90:
highlight.set_y(225)
explanation.set_text("This line creates a function and names it tour.")
counter += 1
# my_display.update(counter)
elif highlight.get_y() != 90:
highlight.set_y(highlight.get_y() - spacing)
counter += 1
# my_display.update(counter)
elif highlight.get_y() == 45:
highlight.set_y(highlight.get_y() - spacing)
sprite.turn_left(360)
text.hide()
counter += 1
# my_display.update(counter)
if counter == 2:
sprite = codesters.Sprite("person1", -150, -60)
explanation.hide()
elif counter == 3:
sprite.say("I can take you on a tour!")
explanation.hide()
elif counter == 4:
sprite.move_forward(550)
explanation.hide()
text.hide()
text.event_click(click)