Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Matthew Schram
- //12/6/17
- //file location D:\cst 112\the_lotto
- //http://abc7chicago.com/finance/powerball-drawing-yields-no-winner;-jackpot-climbs-to-$510-million/2317374/
- boolean startPowerball;
- IntList lotto;
- IntList numbers;
- PFont f1;
- void setup() {
- size(500, 500);
- frameRate(60);
- f1 = createFont("ComicSansMS", 20);
- lotto = new IntList();
- numbers= new IntList();
- imageMode(CORNERS);
- //Makes 59 numbers for lottery
- for (int i = 0; i < 59; i++) {
- //append expands array
- lotto.append(i);
- }
- }
- void draw() {
- background(51);
- PImage powerball;
- powerball = loadImage("the_powerball.png");
- image(powerball, 0, 0, 500, 500);
- rect(280,310,100,30);
- noFill();
- textFont(f1);
- text("START",315,330);
- if (!startPowerball)
- return;
- //shuffle = mixing up numbers
- lotto.shuffle();
- showList(lotto, 40, 250);
- showList(numbers, 16, 300);
- // every 60 frames a new number is shown
- if (frameCount % 10 ==0) {
- if (numbers.size() < 6) {
- int val = lotto.remove(0);
- numbers.append(val);
- } else {
- for (int i = 0; i < numbers.size(); i++) {
- lotto.append(numbers.get(i));
- }
- //stops lottary numbers from changing
- numbers.clear();
- noLoop();
- }
- }
- }
- void mousePressed(){
- if (mouseX>280 && mouseX<380 && mouseY> 310 && mouseY< 340){
- startPowerball = !startPowerball;
- }
- }
- // Makes a list of numbers and start position
- void showList(IntList list, float x, float y) {
- for (int i = 0; i< list.size(); i++) {
- int val = list.get(i);
- stroke(255);
- noFill();
- ellipse(x+i*32, y, 24, 24);
- textAlign(CENTER);
- fill(255);
- text(val, x+i*32, y+6);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement