Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 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.  
  9. void setup()
  10. {
  11. src = loadImage("mario.png");
  12. size(512, 512);
  13. fill(0);
  14. rectMode(CORNERS);
  15. textSize(64);
  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. text("Correct!", 120, 256);
  73. else
  74. text("Try Again", 120, 256);
  75. print(choices.get(0));
  76. print(correct.get(0));
  77. print(choices.get(1));
  78. print(correct.get(1));
  79. print(choices.get(2));
  80. print(correct.get(2));
  81. print(choices.get(3));
  82. print(correct.get(3));
  83. print(" ");
  84. }
  85. }
  86.  
  87. void mouseClicked()
  88. {
  89. if(answer_size < 4)
  90. {
  91. if (mouseX < 257 && mouseY < 257)
  92. choices.append(0);
  93. else if (mouseX >= 257 && mouseY < 257)
  94. choices.append(1);
  95. else if (mouseX < 257 && mouseY >= 257)
  96. choices.append(2);
  97. else
  98. choices.append(3);
  99. }
  100. answer_size++;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement