vencinachev

Dice=Processing

Aug 2nd, 2021 (edited)
260
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int dice;
  2. int circlesize = 50;
  3.  
  4. void setup(){
  5.   size(700, 700);
  6.   dice = (int)random(1, 7);
  7.   background (random(0, 255), random(0, 255), random(0, 255));
  8. }
  9.  
  10. void draw(){
  11.   if (keyPressed && key == ' '){
  12.     dice = (int)random(1, 7);
  13.     println(dice);
  14.     background (random(0, 255), random(0, 255), random(0, 255));
  15.   }
  16.  
  17.   switch (dice) {
  18.     case 1: one(); break;
  19.     case 2: two(); break;
  20.     case 3: three(); break;
  21.     case 4: four(); break;
  22.     case 5: five(); break;
  23.     case 6: six(); break;
  24.   }
  25.  
  26.   result();
  27. }
  28.  
  29. void one(){
  30.    ellipse(350, 350, circlesize, circlesize);
  31. }
  32.  
  33. void two(){
  34.   ellipse(50, 50, circlesize, circlesize);
  35.   ellipse(650, 650, circlesize, circlesize);
  36. }
  37.  
  38. void three(){
  39.   ellipse(350, 350, circlesize, circlesize);
  40.   ellipse(50, 50, circlesize, circlesize);
  41.   ellipse(650, 650, circlesize, circlesize);
  42. }
  43.  
  44. void four(){
  45.   ellipse(50, 50, circlesize, circlesize);
  46.   ellipse(650, 650, circlesize, circlesize);
  47.   ellipse(650, 50, circlesize, circlesize);
  48.   ellipse(50, 650, circlesize, circlesize);
  49. }
  50.  
  51. void five(){
  52.   ellipse(50, 50, circlesize, circlesize);
  53.   ellipse(650, 650, circlesize, circlesize);
  54.   ellipse(650, 50, circlesize, circlesize);
  55.   ellipse(50, 650, circlesize, circlesize);
  56.   ellipse(350, 350, circlesize, circlesize);
  57. }
  58.  
  59. void six(){
  60.   ellipse(50, 50, circlesize, circlesize);
  61.   ellipse(650, 650, circlesize, circlesize);
  62.   ellipse(650, 50, circlesize, circlesize);
  63.   ellipse(50, 650, circlesize, circlesize);
  64.   ellipse(50, 350, circlesize, circlesize);
  65.   ellipse(650, 350, circlesize, circlesize);
  66. }
  67.  
  68. void result(){
  69.   textSize(60);
  70.   fill(255);
  71.   rect(300, 20, 100, 100);
  72.   fill(0);
  73.   text(dice, 330, 80);
  74.   fill(255);
  75. }
RAW Paste Data