嗨,我正在构建一个老虎机游戏,但遇到了一些问题,我对处理很陌生。
我制作了这段代码,需要“轮子”是随机的,但它们都具有相同的图像(垂直)
我知道您将无法看到这些图像,所以如果您想要它们,这里有一些链接。
http://tinypic.com/r/i1jq7t/6(钻石1)
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
}
}
}
// }
我在获得“获胜者”方面也遇到了问题(如果左侧角匹配中的水平图像像素进入“获胜者”。
我非常感谢任何人可以提供的任何帮助。