Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int dice;
- int circlesize = 50;
- void setup(){
- size(700, 700);
- dice = (int)random(1, 7);
- background (random(0, 255), random(0, 255), random(0, 255));
- }
- void draw(){
- if (keyPressed && key == ' '){
- dice = (int)random(1, 7);
- println(dice);
- background (random(0, 255), random(0, 255), random(0, 255));
- }
- switch (dice) {
- case 1: one(); break;
- case 2: two(); break;
- case 3: three(); break;
- case 4: four(); break;
- case 5: five(); break;
- case 6: six(); break;
- }
- result();
- }
- void one(){
- ellipse(350, 350, circlesize, circlesize);
- }
- void two(){
- ellipse(50, 50, circlesize, circlesize);
- ellipse(650, 650, circlesize, circlesize);
- }
- void three(){
- ellipse(350, 350, circlesize, circlesize);
- ellipse(50, 50, circlesize, circlesize);
- ellipse(650, 650, circlesize, circlesize);
- }
- void four(){
- ellipse(50, 50, circlesize, circlesize);
- ellipse(650, 650, circlesize, circlesize);
- ellipse(650, 50, circlesize, circlesize);
- ellipse(50, 650, circlesize, circlesize);
- }
- void five(){
- ellipse(50, 50, circlesize, circlesize);
- ellipse(650, 650, circlesize, circlesize);
- ellipse(650, 50, circlesize, circlesize);
- ellipse(50, 650, circlesize, circlesize);
- ellipse(350, 350, circlesize, circlesize);
- }
- void six(){
- ellipse(50, 50, circlesize, circlesize);
- ellipse(650, 650, circlesize, circlesize);
- ellipse(650, 50, circlesize, circlesize);
- ellipse(50, 650, circlesize, circlesize);
- ellipse(50, 350, circlesize, circlesize);
- ellipse(650, 350, circlesize, circlesize);
- }
- void result(){
- textSize(60);
- fill(255);
- rect(300, 20, 100, 100);
- fill(0);
- text(dice, 330, 80);
- fill(255);
- }
Add Comment
Please, Sign In to add comment