Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

File attached below...relating to last post.

$
0
0
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)

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>