Skip to content

Commit

Permalink
Update Dice.pde
Browse files Browse the repository at this point in the history
  • Loading branch information
MylesLinden authored Oct 14, 2024
1 parent 11e650c commit 432013e
Showing 1 changed file with 68 additions and 25 deletions.
93 changes: 68 additions & 25 deletions Dice.pde
Original file line number Diff line number Diff line change
@@ -1,29 +1,72 @@
void setup()
{
noLoop();
void setup() {
size(300, 300);
noLoop();
}
void draw()
{
//your code here

void draw() {
background(255);
int total = 0;


for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {

Die die = new Die(50 + i * 60, 50 + j * 60);
die.roll();
die.show();
total += die.value;
}
}


fill(0);
textSize(24);
text("Total: " + total, 100, 250);
}
void mousePressed()
{
redraw();

void mousePressed() {
redraw();
}
class Die //models one single dice cube
{
//variable declarations here

Die(int x, int y) //constructor
{
//variable initializations here
}
void roll()
{
//your code here
}
void show()
{
//your code here
}

class Die {
int x, y;
int size;
int value;


Die(int x, int y) {
this.x = x;
this.y = y;
this.size = 50;
roll();
}


void roll() {
value = (int)(Math.random() * 6) + 1;
}


void show() {
fill(255);
rect(x, y, size, size);


fill(0);
if (value == 1 || value == 3 || value == 5) {
ellipse(x + size/2, y + size/2, 10, 10);
}
if (value >= 2) {
ellipse(x + size/4, y + size/4, 10, 10);
ellipse(x + 3*size/4, y + 3*size/4, 10, 10);
}
if (value >= 4) {
ellipse(x + 3*size/4, y + size/4, 10, 10);
ellipse(x + size/4, y + 3*size/4, 10, 10);
}
if (value == 6) {
ellipse(x + size/4, y + size/2, 10, 10);
ellipse(x + 3*size/4, y + size/2, 10, 10);
}
}
}

0 comments on commit 432013e

Please sign in to comment.