Here is the code I have so far and I need to include the random function and draw dots on my dice. I'm not sure where to put in the random function and how to draw dots. I want to keep all my code except for the last section with the random integers because I'm not sure where to put in that part into my code. Help is much appreciated!
from nodebox.graphics import * import random class FlatDie: def __init__(self): self.roll() def roll(self): self.dots = 3 def show(self,x,y): stroke(0) fill(0) rect(x,y,30,30) fill(1) text(str(self.dots),x+10,y+10) def draw (canvas): if canvas.mouse.pressed or canvas.frame == 1: total = 0 i = 0 while i < 6: Zac = FlatDie() Zac.roll() Zac.show(i * 35,85) total = total + Zac.dots i+=1 fill(0) text("Total roll: " + str(total),10,10) canvas.size = 200,200 canvas.run(draw) die1=random.randint(1,6) die2=random.randint(1,6) die3=random.randint(1,6) die4=random.randint(1,6) die5=random.randint(1,6) die6=random.randint(1,6) total=int(die1+die2+die3+die4+die5+die6)
This post has been edited by macosxnerd101: 09 February 2013 - 06:21 PM
Reason for edit:: The code goes between the code tags: [code] Code goes here [/code]