I'm trying to make a connect 4 game in Python turtle graphics, and it was going well, but then this happened: xy
simply won't change! Here is the code:
import turtle
from turtle import *
from turtle import Turtle, Screen
speed(0)
xy = 1
def circle1 ():
forward(90)
fillcolor("white")
begin_fill()
circle(40)
end_fill()
def getCoords(x,y):
global xy
#print("( " + str(x) + ", " + str(y) + " )")
if y < 252 and x < -316:
print ("test")
xy = 1
elif y < 252 and x > -316 and x < -187:
xy = 2
elif y < 252 and x > -187 and x < -59:
xy = 3
elif y < 252 and x > -59 and x < 65:
xy = 4
elif y < 252 and x > 65 and x < 194:
xy = 5
elif y < 252 and x > 194 and x < 327:
xy = 6
elif y < 252 and x > 327 and x < 453:
xy = 7
window = Screen()
wn = window
wn.screensize()
wn.setup(width = 1.0, height = 1.0)
begin_fill()
width(5)
penup()
goto(-450,250)
right(90)
pendown()
forward(580)
left(90)
forward(450*2)
left(90)
forward(580)
left(90)
forward(450*2)
end_fill()
right(180)
forward(30)
right(90)
forward(50)
fillcolor("white")
begin_fill()
circle(40)
end_fill()
circle1 ()
circle1 ()
circle1 ()
circle1 ()
circle1 ()
goto(-450,250)
left(90)
forward(160)
right(90)
forward(50)
fillcolor("white")
begin_fill()
circle(40)
end_fill()
circle1 ()
circle1 ()
circle1 ()
circle1 ()
circle1 ()
penup()
goto(-450,250)
pendown()
left(90)
forward(290)
right(90)
forward(50)
fillcolor("white")
begin_fill()
circle(40)
end_fill()
circle1 ()
circle1 ()
circle1 ()
circle1 ()
circle1 ()
penup()
goto(-450,250)
pendown()
left(90)
forward(410)
right(90)
forward(50)
fillcolor("white")
begin_fill()
circle(40)
end_fill()
circle1 ()
circle1 ()
circle1 ()
circle1 ()
circle1 ()
penup()
goto(-450,250)
pendown()
left(90)
forward(540)
right(90)
forward(50)
fillcolor("white")
begin_fill()
circle(40)
end_fill()
circle1 ()
circle1 ()
circle1 ()
circle1 ()
circle1 ()
penup()
goto(-450,250)
pendown()
left(90)
forward(670)
right(90)
forward(50)
fillcolor("white")
begin_fill()
circle(40)
end_fill()
circle1 ()
circle1 ()
circle1 ()
circle1 ()
circle1 ()
penup()
goto(-450,250)
pendown()
left(90)
forward(800)
right(90)
forward(50)
fillcolor("white")
begin_fill()
circle(40)
end_fill()
circle1 ()
circle1 ()
circle1 ()
circle1 ()
circle1 ()
turtle.onscreenclick(getCoords)
turtle.listen()
if xy == 1:
textinput("test","dis is 1")
For some odd reason when I tabbed everything over it copied a part of it, so ignore that last bit.