Changing variables in if statements
Hey I'm trying to work out how to make a JLabel move around the screen with the wasd keys.
To do this I'm doing something like this:
int x = 0;
int y = 0;
if (input == 'w') {
y -= 5;
}
else if (input == 'a') {
x -= 5;
}
label.setLocation(x, y);
Only problem is, since I'm changing the value of the x and y variables inside an if statement, its not actually changing the value of the variable outside.
How do I make it do that?
Sorry for the dumb question, bit of a newbie :(think):