Skip to content

111 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 108 additions & 25 deletions Dice.pde
Original file line number Diff line number Diff line change
@@ -1,29 +1,112 @@
void setup()
{
noLoop();
Die bob;
int d=0;
int total=0;

void mousePressed(){
total=0;
redraw();
}
void draw()
{
//your code here

void setup(){
size(600,600);
background(227,165,198);
bob = new Die(40,40);
noLoop();
}
void mousePressed()
{
redraw();

void draw(){
fill(227,165,198);
noStroke();
rect(300,550,200,80);
for (int b=40; b<=500; b+=130){
for (int a=40; a<=500; a+=130){
bob = new Die(a,b);
bob.show();
bob.roll();
total=total+d;
}
}
textSize(28);
text("total dots: "+total,300,570);
}
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{
boolean one = false;
boolean two = false;
boolean three = false;
boolean four = false;
boolean five = false;
boolean six = false;
int myX, myY;
int num=(int)(Math.random()*6+1);
void roll(){
if (num == 1){
one=true;
d=1;
}else if (num==2){
two=true;
d=2;
}else if (num==3){
three=true;
d=3;
}else if (num==4){
four=true;
d=4;
}else if (num==5){
five=true;
d=5;
}else if (num==6){
six=true;
d=6;
}
}
void show(){
stroke(255,255,255);
strokeWeight(8);
fill(227,165,198);
rect(myX,myY,100,100);
fill(255,255,255);
noStroke();
if (one==true){
//one
ellipse(myX+50,myY+50,20,20);
}else if (two==true){
//two
ellipse(myX+30,myY+30,20,20);
ellipse(myX+70,myY+70,20,20);
}else if (three==true){
//three
ellipse(myX+20,myY+20,20,20);
ellipse(myX+50,myY+50,20,20);
ellipse(myX+80,myY+80,20,20);
}else if (four==true){
//four
ellipse(myX+20,myY+20,20,20);
ellipse(myX+80,myY+80,20,20);
ellipse(myX+20,myY+80,20,20);
ellipse(myX+80,myY+20,20,20);
}
else if (five==true){
//five
ellipse(myX+50,myY+50,20,20);
ellipse(myX+20,myY+20,20,20);
ellipse(myX+80,myY+80,20,20);
ellipse(myX+20,myY+80,20,20);
ellipse(myX+80,myY+20,20,20);
}
else if (six==true){
//six
ellipse(myX+30,myY+20,20,20);
ellipse(myX+70,myY+20,20,20);
ellipse(myX+30,myY+50,20,20);
ellipse(myX+70,myY+50,20,20);
ellipse(myX+30,myY+80,20,20);
ellipse(myX+70,myY+80,20,20);
}
}
Die(int x,int y){
roll();
myX = x;
myY = y;
}
}
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
</head>
<body>
<header>
<h1>Headline</h1>
<h1>Pink Dice</h1>
</header>
<section id="content">
<canvas id="Dice" data-processing-sources="Dice.pde">
</canvas>
</section>
<footer>
Footer
Lushi Zeng, AP CSA, 3rd Block
</footer>
</body>
</html>