I'm new to python and I can't find any answers online, whenever I move my Player (turtle) it stops the Enemy (Genshape, turtle). Can anyone help with my code?
These are my functions for movement, left and right:
def move_left():
if player.xcor() == 100:
winsound.Beep(200, 100)
player.setx(0)
elif player.xcor() == 0:
winsound.Beep(200, 100)
player.setx(-100)
def move_right():
if player.xcor() == -100:
player.setx(0)
winsound.Beep(200, 100)
elif player.xcor() == 0:
winsound.Beep(200, 100)
player.setx(100)
This is my code for the looping statement:
generate_shapes()
screen.listen()
screen.onkey(move_left, "Left")
screen.onkey(move_right, "Right")
while True:
Genshape.clear()
screen.update()
Genshape.sety(Genshape.ycor() - 60)
if Genshape.ycor() < -352:
generate_shapes()
turtle.done()
Screenshot:
If you need it, here's the full code on GitHub: https://github.com/googlez-bit/simpleGame.git
I want to remove the loop interruption whenever I move.