Pause function?
in
Programming Questions
•
11 months ago
Hi, I'm making a fruit machine and was wondering how I could separate the times with my wheels, so making wheel one appear then two seconds later wheel two then wheel three, is there some sort of pause function I could implement if so where in my code should I write this?
- // images are 720 by 540
- int numFrames = 3; // The number of frames in the animation
- int frame = 0;
- int spincount = 0;
- int state = 0;
- PImage[] images1 = new PImage[6];
- PImage[] images2 = new PImage[6];
- PImage[] images3 = new PImage[6];
- void setup() {
- size(1080, 720);
- frameRate(20);
- // wheel 1
- images1[0] = loadImage("bell1.png");
- images1[1] = loadImage("bellcherry.png");
- images1[2] = loadImage("cherry1.png");
- images1[3] = loadImage("cherrydiamond.png");
- images1[4] = loadImage("diamond1.png");
- images1[5] = loadImage("diamondbell.png");
- // wheel 3
- images3[0] = loadImage("cherry1.png");
- images3[1] = loadImage("cherrybell.png");
- images3[2] = loadImage("bell1.png");
- images3[3] = loadImage("belldiamond.png");
- images3[4] = loadImage("diamond1.png");
- images3[5] = loadImage("diamondcherry.png");
- // wheel 2
- images2[0] = loadImage("diamond1.png");
- images2[1] = loadImage("diamondbell.png");
- images2[2] = loadImage("bell1.png");
- images2[3] = loadImage("bellcherry.png");
- images2[4] = loadImage("cherry1.png");
- images2[5] = loadImage("cherrydiamond.png");
- }
- void draw() {
- background(0);
- //test state to see if I should be spinning
- if(state == 1) {
- spin();
- }
- }
- //if a key is pressed then set the wheel to spin
- void keyReleased() {
- state = 1;
- }
- void spin() {
- //spin for 5 times the break out
- if (frame == 3) {
- frame = 0;
- spincount ++;
- if (spincount == 10) {
- state = 0;
- spincount = 0;
- //check if its a win and do stuff
- winner();
- }
- }
- // wheel 1
- image(images1[frame], 0, 0);
- image(images1[(frame + 1) % numFrames], 0, 200); //this is the image to test
- image(images1[(frame + 2) % numFrames], 0, 400);
- // wheel 2
- image(images3[frame], 300, 0);
- image(images3[(frame + 1) % numFrames], 300, 200); //this is the image to test
- image(images3[(frame + 2) % numFrames], 300, 400);
- // wheel 3
- image(images2[frame], 600, 0);
- image(images2[(frame + 1) % numFrames], 600, 200); //this is the image to test
- image(images2[(frame + 2) % numFrames], 600, 400);
- //slow stuff down so we can see it
- delay(200);
- frame = (frame+1) % numFrames;
- }
- void winner() {
- //are the names of the images the same
- //if ((images3[frame].get(0,0)) == (images2[frame].get(0,0)) == (images1[frame].get(0,0))) {
- // display a question from you list of questions by generating a random number and selecting the text
- // wait for an answer
- for (int i = 0; i < 400; i = i+1) {
- if (keyPressed == true) {
- // whats the key is it correct
- }
- if (i > 400) {
- //display times up
- }
- }
- }
- // }
I'd really appreciate any advice for this :)
1