Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. //Matthew Schram
  2. //12/6/17
  3. //file location D:\cst 112\the_lotto
  4. //http://abc7chicago.com/finance/powerball-drawing-yields-no-winner;-jackpot-climbs-to-$510-million/2317374/
  5. boolean startPowerball;
  6. IntList lotto;
  7. IntList numbers;
  8. PFont f1;
  9.  
  10.  
  11. void setup() {
  12. size(500, 500);
  13. frameRate(60);
  14. f1 = createFont("ComicSansMS", 20);
  15. lotto = new IntList();
  16. numbers= new IntList();
  17. imageMode(CORNERS);
  18.  
  19. //Makes 59 numbers for lottery
  20. for (int i = 0; i < 59; i++) {
  21. //append expands array
  22. lotto.append(i);
  23. }
  24. }
  25.  
  26.  
  27. void draw() {
  28. background(51);
  29. PImage powerball;
  30. powerball = loadImage("the_powerball.png");
  31. image(powerball, 0, 0, 500, 500);
  32. rect(280,310,100,30);
  33. noFill();
  34. textFont(f1);
  35. text("START",315,330);
  36.  
  37. if (!startPowerball)
  38. return;
  39.  
  40.  
  41. //shuffle = mixing up numbers
  42. lotto.shuffle();
  43. showList(lotto, 40, 250);
  44. showList(numbers, 16, 300);
  45.  
  46.  
  47. // every 60 frames a new number is shown
  48. if (frameCount % 10 ==0) {
  49. if (numbers.size() < 6) {
  50. int val = lotto.remove(0);
  51. numbers.append(val);
  52. } else {
  53. for (int i = 0; i < numbers.size(); i++) {
  54.  
  55. lotto.append(numbers.get(i));
  56. }
  57. //stops lottary numbers from changing
  58. numbers.clear();
  59. noLoop();
  60. }
  61. }
  62. }
  63.  
  64.  
  65. void mousePressed(){
  66. if (mouseX>280 && mouseX<380 && mouseY> 310 && mouseY< 340){
  67. startPowerball = !startPowerball;
  68. }
  69. }
  70.  
  71. // Makes a list of numbers and start position
  72. void showList(IntList list, float x, float y) {
  73. for (int i = 0; i< list.size(); i++) {
  74. int val = list.get(i);
  75. stroke(255);
  76. noFill();
  77. ellipse(x+i*32, y, 24, 24);
  78. textAlign(CENTER);
  79. fill(255);
  80. text(val, x+i*32, y+6);
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement