I have a game which asks you a question if you get three matching images in a row, it then pops up with a question, this question stays on the screen and when they win again the question goes over the top and neither question can be read, is there a way to, on key-press remove the current question?
// images are 720 by 540
String[] questions = new String[4];
// link to answers
boolean overBox = false;
int[] answers = new int[4];
//int[] questions = new int[4];
int numFrames = 6; // The number of frames in the animation
int frame = 0;
int spincount = 0;
int state = 0;
//questions
int q = 0;
// answers
int an = 0;
//timer
int savedTime;
int totalTime = 11;
//randomise wheel start position variable
int wheel1;
int wheel2;
//pixels to test
// middle pixels
int a;
int b;
int c;
PImage[] images1 = new PImage[6];
PImage[] images2 = new PImage[6];
PImage[] images3 = new PImage[6];
PImage bg;
void setup() {
size(1080, 720);
frameRate(12);
bg = loadImage("smbg5.png");
// wheel 1
images1[0] = loadImage("bell1.png");
images1[1] = loadImage("diamond1.png");
images1[2] = loadImage("cherry1.png");
images1[3] = loadImage("bell1.png");
images1[4] = loadImage("diamond1.png");
images1[5] = loadImage("cherry1.png");
// wheel 3
images3[0] = loadImage("cherry1.png");
images3[1] = loadImage("diamond1.png");
images3[2] = loadImage("bell1.png");
images3[3] = loadImage("cherry1.png");
images3[4] = loadImage("diamond1.png");
images3[5] = loadImage("bell1.png");
// wheel 2
images2[0] = loadImage("bell1.png");
images2[1] = loadImage("diamond1.png");
images2[2] = loadImage("bell1.png");
images2[3] = loadImage("cherry1.png");
images2[4] = loadImage("diamond1.png");
images2[5] = loadImage("bell1.png");
questions[0] = "Which Apollo 11 astronaut did not set foot on the moon? A:Micheal Collins B: Collin Mitchels C: Harold Greenoff";
questions[1] = "What two colours make up the Polish flag A:blue and white B: blue and red C: red and white?";
questions[2] = "What is a female swan called? A: Cob B:Pen C:Boogle";
questions[3] = "What is a group of Owls called? A:parliament B: murder C: Library";
answers[0] = 1;
answers[1] = 3;
answers[2] = 2;
answers[3] = 1;
}
void draw() {
background (bg);
//test state to see if I should be spinning
if(state == 1) {
randomstart();
spin();
}
}
//if a key is pressed then set the wheel to spin
void keyReleased() {
state = 1;
}
void randomstart() {
wheel1 = int(random(5));
wheel2 = int(random(5));
//wheel3 = int(random(5));
}
void spin() {
frame = (frame+1) % numFrames;
//spin for 5 times the break out
if (frame == 5) {
frame = 0;
spincount ++;
if (spincount == 1) {
state = 0;
spincount = 0;
//check if its a win
a = images1[(frame + 1) % numFrames].get(2,2);
b = images2[(frame + 1 + wheel1) % numFrames].get(2,2);
c = images3[(frame + 1 + wheel2) % numFrames].get(2,2);
winner();
// print(a);
// print(b);
// print(c);
}
}
// wheel 1
image(images1[(frame) % numFrames], 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) % numFrames], 300, 0);
image(images3[(frame + 1 + wheel1) % numFrames], 300, 200); //this is the image to test
I have a color variable to change the color of an object using a keyPress but I wanted to change that object into a Pimage is there a way I could make a tint variable?
color c; // variable to store the current color
void draw() {
// draw ellipse at mouse location with the current color and no stroke
noStroke();
fill(c);
ellipse(mouseX,mouseY,80,80);
}
void keyPressed() {
if (key == 'b') { c = color(0); } // press b to make the current color black
if (key == 'w') { c = color(255); } // press w to make current color white
I seem to be having a problem, but I can't work out, my code when the mouse hovered would play piano music and this worked fine, I then wanted to add background music over the top which could be controlled with a keypress however adding the background music seems to stop the piano working, any ideas why?
import arb.soundcipher.*;
SoundCipher sc = new SoundCipher(this);
SoundCipher ex = new SoundCipher(this);
SoundCipher bg = new SoundCipher(this);
import ddf.minim.*;
import ddf.minim.effects.*;
Minim minim;
AudioPlayer groove;
int t = 0;
int fps = 100;
int adding = -1;
String newPosition = "";
int playingExample = -1;
color c; // variable to store the current color
//PImage img;
void setup() {
//img = loadImage ("brushtest.png");
size (1600, 700);
smooth();
frameRate(fps);
minim = new Minim(this);
groove = minim.loadFile("background.mp3");
// generate piano
for( int i = 3; i < height / 14 - 3; i++ ) {
Key k = new Key(i);
}
// Instrument 49 is piano
bg.instrument(21);
}
void draw() {
frameRate(fps);
// draw ellipse at mouse location with the current color and no stroke
I'm trying to make a timer to start only if some conditions are met first however no matter what I do the timer seems to just start count from as soon as I hit run. I need this timer to start in this if statement for my game to work, any help would really help (anything involving the timer I've highlighted in red)
// images are 720 by 540
String[] questions = new String[4];
int[] answers = new int[4];
//int[] questions = new int[4];
int numFrames = 6; // The number of frames in the animation
int frame = 0;
int spincount = 0;
int state = 0;
//questions
int q = 0;
// answers
int an = 0;
//timer
int savedTime;
int totalTime = 11;
//randomise wheel start position variable
int wheel1;
int wheel2;
//pixels to test
// middle pixels
int a;
int b;
int c;
PImage[] images1 = new PImage[6];
PImage[] images2 = new PImage[6];
PImage[] images3 = new PImage[6];
void setup() {
size(1080, 720);
frameRate(12);
// wheel 1
images1[0] = loadImage("bell1.png");
images1[1] = loadImage("diamond1.png");
images1[2] = loadImage("cherry1.png");
images1[3] = loadImage("bell1.png");
images1[4] = loadImage("diamond1.png");
images1[5] = loadImage("cherry1.png");
// wheel 3
images3[0] = loadImage("cherry1.png");
images3[1] = loadImage("diamond1.png");
images3[2] = loadImage("bell1.png");
images3[3] = loadImage("cherry1.png");
images3[4] = loadImage("diamond1.png");
images3[5] = loadImage("bell1.png");
// wheel 2
images2[0] = loadImage("bell1.png");
images2[1] = loadImage("diamond1.png");
images2[2] = loadImage("bell1.png");
images2[3] = loadImage("cherry1.png");
images2[4] = loadImage("diamond1.png");
images2[5] = loadImage("bell1.png");
questions[0] = "Which Apollo 11 astronaut did not set foot on the moon? A:Micheal Collins B: Collin Mitchels C: Harold Greenoff";
questions[1] = "What two colours make up the Polish flag A:blue and white B: blue and red C: red and white?";
questions[2] = "what is a feamle swan called? A: Cob B:Pen C:Boogle";
questions[3] = "What is a group of Owls called? A:parliament B: murder C: Library";
answers[0] = 1;
answers[1] = 3;
answers[2] = 2;
answers[3] = 1;
}
void draw() {
//background(0);
//test state to see if I should be spinning
if(state == 1) {
randomstart();
spin();
}
}
//if a key is pressed then set the wheel to spin
void keyReleased() {
state = 1;
}
void randomstart() {
wheel1 = int(random(5));
wheel2 = int(random(5));
//wheel3 = int(random(5));
}
void spin() {
frame = (frame+1) % numFrames;
//spin for 5 times the break out
if (frame == 5) {
frame = 0;
spincount ++;
if (spincount == 1) {
state = 0;
spincount = 0;
//check if its a win
a = images1[(frame + 1) % numFrames].get(2,2);
b = images2[(frame + 1 + wheel1) % numFrames].get(2,2);
c = images3[(frame + 1 + wheel2) % numFrames].get(2,2);
winner();
// print(a);
// print(b);
// print(c);
}
}
// wheel 1
image(images1[(frame) % numFrames], 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) % numFrames], 300, 0);
image(images3[(frame + 1 + wheel1) % numFrames], 300, 200); //this is the image to test
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
Hi I'm trying to create essentially a keyboard which you can play the keys using a mouse hover (You can't see keys but different areas of the screen are different notes)
I found this online I really can't remember where:
Which makes the ellipse follow the mouse and stay on the screen I want this but the colours to be controlled through key presses rather than the mouse (I'm playing with speech software and motion controls so I can't have mouse click)
So I wrote this code:
// Click on the image to give it focus,
// and then press any key.
int black = 'b';
int white = 'w';
void setup() {
size (1600, 700);
}
void draw() {
fill(black, white);
}
void keyReleased() {
if (key == 'b') {
black = 0;
} else {
black = 255;
if (key == 'w') {
white = 255;
} else {
white = 0;
}
}
noStroke();
ellipse(mouseX,mouseY,80,80);
}
Which works with the key released (again can't be pressed because of voice software) and only places a ellipse where the mouse is rather than making a continuous line of them follow the mouse, any ideas how I could fix this?
Hopefully a simple question but I have this code for hand tracking and I'm trying to make it into a painting game, a good place to start would be able to change the point into a ellipse so I have control over the size colour and I guess this has a decay rate?
This code is an example from the openNI library called Hands3d
I'm new at code so I'm trying to work out what does what in the code.
Hello I am very new to processing and am basically trying to use blob tracking to make an interactive painting game. My main issue is I can't get any blob tracking to work, the only thing I've got to work is SimpleOpenNI and Blobscanner (blob scanner keeps saying no capture device connected to computer even though simpleopen NI can see my kinect camera.
Any way my question is can anyone help? how do I get Blobscanner to register the kinect or can I add tracking points to the depth in simpleOpenNI I have almost no coding knowlege so an example of this made would be very appreciated.