Turtle game has text input on screen, but won't display attempts and correct on screen python

Viewed 15

I've tried to use the tur .write for attempts and correct, but it won't display on screen. The coordinates work fine and it prints them to the screen and the console, but I want basically everything to run through the screen, not the console.

import turtle
from turtle import *
from turtle import Turtle, Screen
import random

screen = Screen()       # use nouns for objects, play is a verb
screen.bgpic('Housegame.gif')
screen.setup(width=800, height=600)

tur = Turtle()
tur = Turtle(shape="turtle")
tur.color("orange")
tur.speed("fastest")
tur.color("orange")
tur.goto(x=-350, y=0)

attempts = 0
right = 0

while True:
    coords = turtle.textinput("First Puzzle", "Enter correct Letter code To continue")
    dispcoords = ["abc", "abc"]
    if coords == random.choice(dispcoords):
        tur.setposition(150, 110)

        p = tur.pos()  # here you get the coordinates of the turtle
        tur.write(str(p), True)  # and you print a string representation on screen
        tur.penup()
        print(p)  # this prints to the console
        while True:
            combo1 = turtle.textinput("Second Puzzle", "Enter The Correct Combination to Enter")
            combo1num = ["00000", "00000"]

            if combo1 == random.choice(combo1num):
                print("Access Granted")
                attempts = attempts + 1
                right = right + 1
                print("Total Correct", right)
                print("Global Attempts", attempts)
                tur.write("Global Attempts", attempts)
            else:
                print("Access Denied...Try Again")
                attempts = attempts + 1
                print("Global Attempts", attempts)
                continue
 
0 Answers
Related