0

我不确定如何摆脱黑色箭头,如果您能提供帮助,那就太好了!谢谢,如果您有任何其他修改以使游戏变得更好,那也很棒!再次感谢!

它说我需要写更多的细节,所以我只是继续打字,希望我有足够的单词来写。这里应该不错。

import math
import random

score = 0
print ("\n" * 40)
print("Welcome Player, I Hope You Have What it Takes to be the Next WARLORD BOSS")
print("Enemies Killed:\n0")

#Title
t=turtle.Pen()
t.pencolor("magenta")
t.hideturtle()
t.penup()
t.setposition(-300,350)
t.write("Catch 40 turtles for a suprise  ( ͡° ͜ʖ ͡°)", font=("Verdana", 18))

#Tip
text=turtle.Pen()
t.pencolor("magenta")
t.hideturtle()
turtle.clear()
t.penup()
t.setposition(-100, -350)
t.write("TOUCH THE EDGES, I DARE YOU", font=("Verdana", 18))```



#Set up screen
wn = turtle.Screen()
wn.bgcolor("dim gray")
wn.title("EXEXEXEXEEXXEXEXE HACK COMMENCING␀␀␀␀␀")

#Draw border
mypen = turtle.Turtle()
mypen.penup()
mypen.speed(10)
mypen.hideturtle()
mypen.setposition(-300,-300)
mypen.pendown()
mypen.pensize(3)
for side in range(4):
    mypen.color("crimson")
    mypen.forward(300)
    mypen.color("gold")
    mypen.forward(300)
    mypen.left(90)
mypen.hideturtle()


#Create player turtle
player = turtle.Turtle()
player.color("powder blue")
player.shape("arrow")
player.penup()
player.speed(0)

#Create goal
goal = turtle.Turtle()
goal.color("red")
goal.shape("turtle")
goal.penup()
goal.speed(0)
goal.setposition(-100, -100)

#Set speed
speed = 1

#Define functions

def turnleft():
    player.left(30)

def turnright():
    player.right(30)

def increasespeed():
    global speed
    speed +=0.5

def decreasespeed():
    global speed
    speed -= 1

#Set keyboard binding
turtle.listen()
turtle.onkey(turnleft, "Left")
turtle.onkey(turnright, "Right")
turtle.onkey(increasespeed, "Up")
turtle.onkey(decreasespeed, "Down")



while True:
    player.forward(speed)

    #Boundary check
    if player.xcor() > 300 or player.xcor() < -300:
        print("I Knew you could never be a WARLORD... Try Again")
        quit()

    if player.ycor() > 300 or player.ycor() < -300:
        print("I Knew you could never be a WARLORD... Try Again")
        quit()

    #Collision checking
    d= math.sqrt(math.pow(player.xcor()-goal.xcor(),2) + math.pow(player.ycor()-goal.ycor(),2))
    if d < 20 :
        goal.setposition(random.randint(-300,300), random.randint(-300, 300))
        score = score + 1
        print ("\n" * 40)
        print("Wow, You Actually got one!")
        print("I think you Might Have What it Takes to be the Next WARLORD BOSS")
        print("Enemies Killed")
        print (score)

4

1 回答 1

1

这段代码是你的问题:

text=turtle.Pen()
t.pencolor("magenta")
t.hideturtle()
turtle.clear()
t.penup()
t.setposition(-100, -350)
t.write("TOUCH THE EDGES, I DARE YOU", font=("Verdana", 18))

您复制并粘贴但忘记更新t.text. 另外,turtle.clear()没有意义,因为这完全指的是不同的海龟:

text = turtle.Pen()
text.hideturtle()
text.pencolor("magenta")
text.penup()
text.setposition(-100, -350)
text.write("TOUCH THE EDGES, I DARE YOU", font=("Verdana", 18))
于 2019-10-04T20:52:38.457 回答