Advertisement
marwanpro

processing code 1

Oct 7th, 2015
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.57 KB | None | 0 0
  1. int Dice1;
  2. int Dice2;
  3. int Dice3;
  4. IntList DiceList;
  5. int DiceSize = 160;
  6. int PointSize = 20;
  7.  
  8. void setup() {
  9.   size(800, 400);
  10.   surface.setTitle("Jeu du 421 - Such WOW");
  11.   background(0, 153, 0);
  12.   noLoop();
  13.   DiceList = new IntList();
  14. }
  15.  
  16. void draw() {
  17.   DisplayDice();
  18.   Randomizer();
  19.   DisplayNumber();
  20.   DiagnosticVoid();
  21. }
  22.  
  23. void DiagnosticVoid(){
  24.   print(DiceList);
  25. }
  26.  
  27. void DisplayDice() {
  28.   generateDice(200, 200, DiceSize);
  29.   generateDice(400, 200, DiceSize);
  30.   generateDice(600, 200, DiceSize);
  31. }
  32.  
  33. void generateDice(int XLocation, int YLocation, int SquareSize) {
  34.   rectMode(CENTER);
  35.   fill(255);
  36.   rect(XLocation, YLocation, SquareSize, SquareSize, 7);
  37. }
  38.  
  39. void Randomizer() {
  40.   Dice1 = int(random(1, 6));
  41.   Dice2 = int(random(1, 6));
  42.   Dice3 = int(random(1, 6));
  43.   DiceList.append(Dice1);
  44.   DiceList.append(Dice2);
  45.   DiceList.append(Dice3);
  46.   DiceList.sort();
  47. }
  48.  
  49. void DisplayNumber() {
  50.   dispFace(200, 200, DiceSize, Dice1);
  51.   dispFace(400, 200, DiceSize, Dice2);
  52.   dispFace(600, 200, DiceSize, Dice3);
  53. }
  54.  
  55. void dispFace(int XLocation, int YLocation, int DiceSize, int DiceValue) {
  56.   switch(DiceValue) {
  57.     case 1:
  58.       Disp1(XLocation, YLocation);
  59.       break;
  60.     case 2:
  61.       Disp2(XLocation, YLocation);
  62.       break;
  63.     case 3:
  64.       Disp1(XLocation, YLocation);
  65.       Disp2(XLocation, YLocation);
  66.       break;
  67.     case 4:
  68.       Disp2(XLocation, YLocation);
  69.       Disp4(XLocation, YLocation);
  70.       break;
  71.     case 5:
  72.       Disp1(XLocation, YLocation);
  73.       Disp2(XLocation, YLocation);
  74.       Disp4(XLocation, YLocation);
  75.       break;
  76.     case 6:
  77.       Disp2(XLocation, YLocation);
  78.       Disp4(XLocation, YLocation);
  79.       Disp6(XLocation, YLocation);
  80.       break;
  81.   }
  82. }
  83.  
  84. void Disp1(int XLocation, int YLocation) {
  85.   fill(0);
  86.   ellipse(XLocation, YLocation, PointSize, PointSize);
  87. }
  88.  
  89. void Disp2(int XLocation, int YLocation) {
  90.   fill(0);
  91.   ellipse(XLocation+int(0.25*DiceSize), YLocation-int(0.25*DiceSize),PointSize, PointSize);
  92.   fill(0);
  93.   ellipse(XLocation-int(0.25*DiceSize), YLocation+int(0.25*DiceSize), PointSize, PointSize);
  94. }
  95.  
  96. void Disp4(int XLocation, int YLocation) {
  97.   fill(0);
  98.   ellipse(XLocation+int(0.25*DiceSize), YLocation+int(0.25*DiceSize), PointSize, PointSize);
  99.   fill(0);
  100.   ellipse(XLocation-int(0.25*DiceSize), YLocation-int(0.25*DiceSize), PointSize, PointSize);
  101. }
  102.  
  103. void Disp6(int XLocation, int YLocation) {
  104.   fill(0);
  105.   ellipse(XLocation+int(0.25*DiceSize), YLocation, PointSize, PointSize);
  106.   fill(0);
  107.   ellipse(XLocation-int(0.25*DiceSize), YLocation, PointSize, PointSize);
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement