background(228)
rectMode(CORNER)
rect(0, 0, 100, 100)
fill(0)
circle(50, 50, 25)
def drawDice(x, y):
background(228)
rectMode(CORNER)
rect(x, y, 100, 100)
fill(0)
circle(50+x, 50+y, 25)
drawDice(20, 40)
def drawDice(x, y):
background(228)
rectMode(CORNER)
rect(x, y, 100, 100)
fill(0)
circle(50+x, 50+y, 25)
def draw():
drawDice(mouseX(), mouseY())
timer(draw)
def drawDice(x, y, points):
fill(255, 0) # 0 = transparent, otherwise white
rectMode(CORNER)
rect(x, y, 100, 100)
fill(0)
if points == 1:
circle(100/2+x, 100/2+y, 20)
elif points == 2:
circle(100/4+x, 100/4+y, 20)
circle(100/4+50+x, 100/4+50+y, 20)
elif points == 3:
drawDice(x, y, 1)
drawDice(x, y, 2)
elif points == 4:
drawDice(x, y, 2)
circle(100/4+50+x, 100/4+y, 20)
circle(100/4+x, 100/4+50+y, 20)
elif points == 5:
drawDice(x, y, 1)
drawDice(x, y, 4)
elif points == 6:
drawDice(x, y, 4)
circle(100/4+50+x, 100/2+y, 20)
circle(100/4+x, 100/2+y, 20)
background(228)
drawDice(0,0,1)
drawDice(100,0,2)
drawDice(200,0,3)
drawDice(300,0,4)
drawDice(400,0,5)
drawDice(500,0,6)
def drawDice(x, y, points):
fill(255, 0) # 0 = transparent, otherwise white
rectMode(CORNER)
rect(x, y, 100, 100)
fill(0)
if points == 1:
circle(100/2+x, 100/2+y, 20)
elif points == 2:
circle(100/4+x, 100/4+y, 20)
circle(100/4+50+x, 100/4+50+y, 20)
elif points == 3:
drawDice(x, y, 1)
drawDice(x, y, 2)
elif points == 4:
drawDice(x, y, 2)
circle(100/4+50+x, 100/4+y, 20)
circle(100/4+x, 100/4+50+y, 20)
elif points == 5:
drawDice(x, y, 1)
drawDice(x, y, 4)
elif points == 6:
drawDice(x, y, 4)
circle(100/4+50+x, 100/2+y, 20)
circle(100/4+x, 100/2+y, 20)
def draw():
global points
background(228)
if mouseIsPressed():
points = random(1, 7)
points = int(points)
print(points)
drawDice(mouseX(), mouseY(), points)
background(228)
timer(draw)
points = random(1, 7)
points = int(points)