So, I'm making a much simpler tic tac toe game, the ones on here are too complicated :P. When you run the game you will see the tic tac toe rubric and 3 buttons underneath. The one on the left turn the draw colour blue, one in the middle turns the draw colour red. The one on the right, erases everything.
If you play with it you'll notice that tapping the button changes the draw colour but I need it to change the new draw colour and leave the old colour as it is.
Thanks in advance!
Here's the code:
from scene import *
class MyScene (Scene):
def setup(self):
global count
count=0
self.lines = []
self.button = Button(Rect(self.size.w/2+85, self.size.h/2-245, 75, 50))
self.button.background = Color(1,1,1)
self.button.stroke = Color(1,1,1)
self.button.action = self.add_clicks
self.add_layer(self.button)
self.redbutton = Button(Rect(self.size.w/2-35, self.size.h/2-245, 75, 50))
self.redbutton.background = Color(1,0,0)
self.redbutton.stroke = Color(1,1,1)
self.redbutton.action = self.turnred
self.add_layer(self.redbutton)
self.bluebutton = Button(Rect(self.size.w/2-155, self.size.h/2-245, 75, 50))
self.bluebutton.background = Color(0,0,1)
self.bluebutton.stroke = Color(1,1,1)
self.bluebutton.action = self.turnblue
self.add_layer(self.bluebutton)
def add_clicks(self):
run(MyScene())
def turnred(self):
global count
count=1
self.redbutton.background = Color(1,0,0)
def turnblue(self):
global count
count=2
self.bluebutton.background = Color(0,0,1)
def draw(self):
background(0,0,0)
self.button.draw()
self.redbutton.draw()
self.bluebutton.draw()
fill(1,1,1)
rect(0,180,320,15)
rect(0,290,320,15)
rect(92,87,15,310)
rect(208,87,15,310)
#draw colour
global count
if count==0:
one=1
two=1
three=1
if count==1:
one=1
two=0
three=0
if count==2:
one=0
two=0
three=1
stroke(int(one), int(two), int(three))
stroke_weight(4)
for l in self.lines:
line(*l)
def touch_moved(self, touch):
x = touch.location.x
y = touch.location.y
ppos = touch.prev_location
self.lines.append((ppos.x, ppos.y, x, y))
run(MyScene())
If I'm not explicit enough, please let me know.