Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. import java.util.Collections;
  2.  
  3. PImage src, patch0, patch1, patch2, patch3;
  4. ArrayList<PImage> list;
  5. IntList choices;
  6. IntList correct;
  7. int answer_size = 0;
  8. String msg = "Try Again";
  9.  
  10. void setup()
  11. {
  12. src = loadImage("mario.png");
  13. size(512, 512);
  14. noFill();
  15. rectMode(CORNERS);
  16. image(src,0,0);
  17. patch0 = get(0,0,256,256);
  18. patch1 = get(257,0,256,256);
  19. patch2 = get(0,257,256,256);
  20. patch3 = get(257,257,256,256);
  21. list = new ArrayList<PImage>();
  22. list.add(patch0);
  23. list.add(patch1);
  24. list.add(patch2);
  25. list.add(patch3);
  26. Collections.shuffle(list);
  27. choices = new IntList();
  28. correct = new IntList();
  29. if(list.get(0) == patch0)
  30. correct.append(0);
  31. else if(list.get(0) == patch1)
  32. correct.append(1);
  33. else if(list.get(0) == patch2)
  34. correct.append(2);
  35. else if(list.get(0) == patch3)
  36. correct.append(3);
  37. if(list.get(1) == patch0)
  38. correct.append(0);
  39. else if(list.get(1) == patch1)
  40. correct.append(1);
  41. else if(list.get(1) == patch2)
  42. correct.append(2);
  43. else if(list.get(1) == patch3)
  44. correct.append(3);
  45. if(list.get(2) == patch0)
  46. correct.append(0);
  47. else if(list.get(2) == patch1)
  48. correct.append(1);
  49. else if(list.get(2) == patch2)
  50. correct.append(2);
  51. else if(list.get(2) == patch3)
  52. correct.append(3);
  53. if(list.get(3) == patch0)
  54. correct.append(0);
  55. else if(list.get(3) == patch1)
  56. correct.append(1);
  57. else if(list.get(3) == patch2)
  58. correct.append(2);
  59. else if(list.get(3) == patch3)
  60. correct.append(3);
  61. }
  62.  
  63. void draw()
  64. {
  65. image(list.get(0), 0,0);
  66. image(list.get(1), 257,0);
  67. image(list.get(2), 0,257);
  68. image(list.get(3), 257,257);
  69. if (answer_size >= 4)
  70. {
  71. if (choices.get(0) == correct.get(0) && choices.get(1) == correct.get(1) && choices.get(2) == correct.get(2) && choices.get(3) == correct.get(3))
  72. msg = "Correct!";
  73. print(msg);
  74. }
  75. else
  76. {
  77. print(choices.get(1));
  78. }
  79. }
  80.  
  81. void mouseClicked()
  82. {
  83. if(answer_size < 4)
  84. {
  85. if (mouseX < 257 && mouseY < 257)
  86. choices.append(1);
  87. else if (mouseX > 257 && mouseY < 257)
  88. choices.append(2);
  89. else if (mouseX < 257 && mouseY > 257)
  90. choices.append(3);
  91. else
  92. choices.append(4);
  93. }
  94. answer_size++;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement