Random Image and get winner?
in
Programming Questions
•
11 months ago
Hi I'm building a slot machine game and am having a few problems I'm pretty new with processing.
I've made this code and need the "wheels" to be random but they all have the same image (vertically)
I realise you won't be able to see the images so here's some links if you want them.
http://tinypic.com/r/i1jq7t/6 (diamond1)
http://tinypic.com/r/29fe5cg/6 (cherry1)
http://tinypic.com/r/sen1jo/6 (bell1)
int numFrames = 3; // The number of frames in the animation
int frame = 0;
int spincount = 0;
int state = 0;
PImage[] images1 = new PImage[3];
PImage[] images2 = new PImage[3];
PImage[] images3 = new PImage[3];
void setup() {
size(1080, 720);
frameRate(12);
// wheel 1
images1[0] = loadImage("bell1.png");
images1[1] = loadImage("cherry1.png");
images1[2] = loadImage("diamond1.png");
// wheel 3
images3[0] = loadImage("cherry1.png");
images3[1] = loadImage("bell1.png");
images3[2] = loadImage("diamond1.png");
// wheel 2
images2[0] = loadImage("diamond1.png");
images2[1] = loadImage("bell1.png");
images2[2] = loadImage("cherry1.png");
}
void draw() {
background(o);
//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], 20, 0);
image(images1[frame], 20, 170); //this is the image to test
image(images1[frame], 20, 340);
// wheel 2
image(images3[frame], 200, 0);
image(images3[frame], 200, 170); //this is the image to test
image(images3[frame], 200, 340);
// wheel 3
image(images2[frame], 400, 0);
image(images2[frame], 400, 170); //this is the image to test
image(images2[frame], 400, 340);
frame ++;
}
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'm also having issues with getting the "winner" (if the horizontal images's pixel in the left hand corner match go onto "winner".
I'd really appreciate any help anyone can offer.
1