If I use the same name variable in an object and as a global how do I access the global one from the class with the variable with the same name. Sorry if that is badly worded I will show some example code:
int variable = 1;
void setup() {
Object object = new Object();
object.function();
}
class Object {
int variable = 2;
Object() {
}
void function() {
print(this.variable);
print(variable);
}
}
Now this will print "22" when i want it to print "21" how do i access the global when I have a class variable with the same.
And some general explanations on how to use global and class variables will be highly appreciated too!
I was wondering what an efficient way to make configurable controls would be? I was hoping to have it so that in the controls menu when you clicked on one of the configurable controls it would change color (or something like that) and then wait for a button press which it would then retrieve the ASCII value of and would set that to be the control it uses. Most games do it this way and i was wondering how i could do this in processing.
Currently i can only think of using this code:
boolean upValue = false;
string upControl = "";
boolean wKey = false;
boolean upKey = false;
void draw(){
switch(upControl){
case wKey:
upValue = wKey;
break;
case upKey:
upValue = upKey;
break;
}
}
}
void keyPressed(){
if (key == 119){
wKey = true;
}
if (keyCode == up){
upKey = true;
}
}
//repeated for keyReleased() but with false instead of true
And then of course i would have some way of changing upControl in game through the menu (which i will figure out the code for later)
Is there atleast a way to simplify it a little by switching the "switch / case" statement for some sort of statement that will automatically set the value of "upValue" to the value of the variable that is named in string "upControl" instead of having to put a case for every key and for every control?
How do i import XML and where should i store the XML? Can i store it within the .jar file but have it so that the webpage won't load it until it is requested to save loading time? Is there any better or different alternatives to using XML for loading data after the game is fully loaded?
Basically all i want to know is how to load level data and whatnot after the game is loaded and playing so i can make a good game without initial loading time being too high. It's also so that i can use online login data so that i don't need to use cookies to store how far someone has got in the game. On a side note how do i use cookies to store data? What's the best way to have server side login data stored XML or mySQL or what else could i use?
when i compile an applet it creates a .jar file a .html file and a bunch of pde files which makes sense.
.jar is for the application
.html is too run it in browser
and
.pde is too publish my code as well
but what is the significance of the .java file? i removed it from the applet and it still ran ok? should i leave it in the applet to avoid causing problems or is it just there to show all of my code in one place or something? I really don't understand what its used for.
How can i make separate files to store data that are stored in the java zip file where all the data is stored that can be accessed when playing the processing application. I would like to do this for organizational purposes and also so that when the game loads in browser it doesn't have to retrieve the data values for every level in the game just the functional code. Would the separate files be processing files that you run or would they be database files that you access or what?
I was wondering if there was a fair to retrieve variables from a sound file according to they volume/pitch at a certain time in the sound in order to turn it into a graphic image of some sort. If not what is the best way for me to retrieve those variables and whatnot in a separate program to input it into processing? The most important part of it is the volume for now but being able to retrieve pitch and tone and other parts of a sound would be nice to.
I noticed that if you have a division equation that needs to end up being an int it will still let you do the equation however it will not allow you to add a decimal. This strikes me as being weird as many times the division equation returns a non integer value yet it seems that it still allows it to be converted into an Int. Am i mistaken here or is it simply truncated or rounding the float? if it is which of the two is it doing?
when i include openGL in a .pde it allows me to run it just fine and use openGL normally but if i export applet and then run it through chrome it just gives me a white screen and doesn't run it. Anyone know why this is happening?
Is there a way to have 2D shapes like ellipse and such to have anti-aliasing on the sides so they look more HD. Mainly with vector images but also is there a way to have it anti-alias bitmap images too?