Ok so I am relatively new to Processing. I've been taking a class that focuses on it all semester and right now I'm working on the final project. In my sketch I use the Procontroll library with Processing to use an xbox 360 controller as the input device.
The controller works fine and I have all the buttons set up but I'm having a problem with the functionality of my other code, governing how the game itself should run.
At this point, my addNewButton function works, because on start up it does highlight a button that it wants me to copy. However, it doesn't seem to be turning it over to me to copy it after that, and when I copy it, nothing happens. If anyone could take a look at my code and help me out with what I need to change/what I am missing, that would be much appreciated.
Thanks.
Code:import processing.opengl.*;
import procontroll.*;
import net.java.games.input.*;
Simon simon;
ControllIO controllIO;
ControllDevice joypad;
ControllStick stick1;
ControllStick stick2;
ControllButton button11;
ControllButton button12;
ControllButton button13;
ControllButton button14;
ControllButton button8;
ControllButton button9;
ControllButton button6;
ControllButton button7;
ControllButton button4;
PImage controller;
PImage controllera;
PImage controllerb;
PImage controllerx;
PImage controllery;
PImage controllerleftbumper;
PImage controllerrightbumper;
PImage controllerleftthumb;
PImage controllerrightthumb;
PImage title;
PImage titlescreen;
PImage gameover;
boolean screen = false;
boolean button11state = false;
boolean button12state = false;
boolean button13state = false;
boolean button14state = false;
boolean button6state = false;
boolean button7state = false;
boolean button8state = false;
boolean button9state = false;
boolean playerMode = false;
void setup(){
size(900,684,OPENGL);
frameRate(6);
simon = new Simon();
controllIO = ControllIO.getInstance(this);
joypad = controllIO.getDevice("Wireless 360 Controller");
joypad.plug(this, "handleButton1Press", ControllIO.ON_PRESS, 1);
joypad.plug(this, "handleButton1Release", ControllIO.ON_RELEASE, 1);
controller = loadImage("controller.png");
controllera = loadImage("controllera.png");
controllerb = loadImage("controllerb.png");
controllerx = loadImage("controllerx.png");
controllery = loadImage("controllery.png");
controllerleftbumper = loadImage("controllerleftbumper.png");
controllerrightbumper = loadImage("controllerrightbumper.png");
controllerleftthumb = loadImage("controllerleftthumb.png");
controllerrightthumb = loadImage("controllerrightthumb.png");
titlescreen = loadImage("titlescreen.png");
gameover = loadImage("gameover.png");
title = loadImage("title.png");
stick1 = joypad.getStick(0);
stick1.setMultiplier(PI);
stick2 = joypad.getStick(1);
stick2.setTolerance(0.06f);
stick2.setMultiplier(0.05f);
button11 = joypad.getButton(11);
// button11.pressed();
button12 = joypad.getButton(12);
// button12.pressed();
button13 = joypad.getButton(13);
// button13.pressed();
button14 = joypad.getButton(14);
// button14.pressed();
button8 = joypad.getButton(8);
// button8.pressed();
button9 = joypad.getButton(9);
// button9.pressed();
button6 = joypad.getButton(6);
// button6.pressed();
button7 = joypad.getButton(7);
// button7.pressed();
button4 = joypad.getButton(4);
// button4.pressed();
}
void handleButton1Press(){
fill(255,0,0);
joypad.rumble(1);
}
void handleButton1Release(){
fill(255);
}
void draw(){
if (screen){
background(255);
image(controller,60,130);
image(title,45,-140);
simon.addNewButton();
simon.showNextButton();
if(button11.pressed() && button11state==false){
button11state = true;
simon.checkButtonPress(11);
}
if(!button11.pressed() && button11state==true){
//simon.checkButtonPress(11);
button11state = false;
}
if(button12.pressed() && button12state==false){
button12state = true;
simon.checkButtonPress(12);
}
if(!button12.pressed() && button12state==true){
//simon.checkButtonPress(12);
button12state = false;
}
if(button13.pressed() && button13state==false){
button13state = true;
simon.checkButtonPress(13);
}
if(!button13.pressed() && button13state==true){
//simon.checkButtonPress(13);
button13state = false;
}
if(button14.pressed() && button14state==false){
button14state = true;
simon.checkButtonPress(14);
}
if(!button14.pressed() && button14state==true){
//simon.checkButtonPress(14);
button14state = false;
}
if(button8.pressed() && button8state==false){
button8state = true;
simon.checkButtonPress(8);
}
if(!button8.pressed() && button8state==true){
//simon.checkButtonPress(8);
button8state = false;
}
if(button9.pressed() && button9state==false){
button9state = true;
simon.checkButtonPress(9);
}
if(!button9.pressed() && button9state==true){
//simon.checkButtonPress(9);
button9state = false;
}
if(button6.pressed() && button6state==false){
button6state = true;
simon.checkButtonPress(6);
}
if(!button6.pressed() && button6state==true){
//simon.checkButtonPress(6);
button6state = false;
}
if(button7.pressed() && button7state==false){
button7state = true;
simon.checkButtonPress(7);
}
if(!button7.pressed() && button7state==true){
//simon.checkButtonPress(7);
button7state = false;
}
} else {
image(titlescreen,0,0);
}
if(button4.pressed()){
screen = true;
}
}
Here is the initial Sketch code.