xxxxxxxxxx
52
let diceImages = [];
let dicePositions = [];
let randomPickerNumbers = [];
let score = 0;
function preload() {
for (let i = 0; i < 6; i++) {
diceImages[i] = loadImage("die-" + i + ".png");
}
}
function setup() {
createCanvas(600, 200);
background(220);
for (let i = 0; i < 5; i++) {
dicePositions[i] = i * 100;
randomPickerNumbers[i] = floor(random(0, 6));
}
drawDiceImages();
}
function draw()
{
}
function mousePressed() {
for (let i = 0; i < 5; i++) {
randomPickerNumbers[i] = floor(random(0, 6));
score += randomPickerNumbers[i];
}
drawDiceImages();
print(randomPickerNumbers)
print(score)
}
function drawDiceImages() {
for (let i = 0; i < 5; i++) {
image(diceImages[randomPickerNumbers[i]], dicePositions[i], 10);
}
}
//chat gpt explained removing draw function and creating a function to draw the dice seperately