xxxxxxxxxx
34
function setup() {
createCanvas(400, 400);
frameRate(1);
}
function draw() {
background(220);
var randomValue = random();
if (randomValue < 0.1666) {
text("You rolled a 1!", 25, 55);
ellipse(random(0,width), random(0,height), 50,50);
} else if (randomValue < 0.3333)
{
text("You rolled a 2!", 25, 55);
rect(random(0,width), random(0,height), 50,50);
} else if (randomValue < .5)
{
text("You rolled a 3!", 25, 55)
}
else if (randomValue < .6666)
{
text("You rolled a 4!", 25, 55)
}
else if (randomValue < .8333)
{
text("You rolled a 5!", 25, 55)
} else
{
text("You rolled a 6!", 25, 55)
}
}