Hello Spyder Community,
For some reason, spyder4 hangs on the running turtle module.
I'm trying to use the turtle module to teach my 8 and 10 years old kids
gaming and programming using Spyder ( I'm a big fanatic of Spyder and my
kids wants to use too. )
Recently I upgrade to Spyder4 from Spyder3. I noticed wired hanging state
when I run/execute the program.
Attached the program/source code. Please download it and test it and
execute it. I dont know where I'm doing the mistake or whats the error.
Please help me to fix this issue or give me the hints to fix this hanging
issue.
Thanks
Kylix
--
You received this message because you are subscribed to the Google Groups
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/spyderlib/7f35bfc5-967c-4859-b234-d51afe47df75%40googlegroups.com.
# Falling Skies in Python for Beginners
# Part 1 : Getting Started --- Setting up Screen
# Part 2 : Adding the deer
# Part 3 : Moving the deer
# Part 4 : nuts falling and collisions
import turtle
import random
wn = turtle.Screen()
wn.title("Falling Skies")
wn.bgcolor("light green")
wn.setup(width=800, height=600)
wn.tracer(0)
# Add the deer
deer = turtle.Turtle()
deer.speed(0)
deer.shape("square")
deer.color("white")
deer.penup()
deer.goto(0, -250)
deer.direction = "stop"
# Add the nut
nut = turtle.Turtle()
nut.speed(0)
nut.shape("circle")
nut.color("blue")
nut.penup()
nut.goto(0, 250)
# Functions
def go_left():
deer.direction = "left"
def go_right():
deer.direction = "right"
# Keyboard Bindings
wn.listen()
wn.onkeypress(go_left, "Left")
wn.onkeypress(go_right, "Right")
# Main game loop
while True:
# Update screen
wn.update()
# Move the deer
if deer.direction == "left":
x = deer.xcor()
x -= 3
deer.setx(x)
if deer.direction == "right":
x = deer.xcor()
x += 3
deer.setx(x)
# Move the nut
y = nut.ycor()
y -= 3
nut.sety(y)
# Check if off the screen
if y < -300:
x = random.randint(-380, 380)
y = random.randint(300, 400)
nut.goto(x, y)
# check for a collison with the deer
if nut.distance(deer) < 20:
x = random.randint(-380, 380)
y = random.randint(300, 400)
nut.goto(0, 250)
wn.mainloop()