I am making a game where the player is in the bottom center and can only rotate. They shoot to destroy object that will be launched at them. I am having two problems:
1. I know that if i just say
if (Greenfoot.isKeyDown("space"))
{
Shoot(getRotation()); //ignore the getRotation() parameter until question 2
}
then it will keep shooting if I hold the space bar. I have a few ideas but they all involve public variables which seems very difficult (oddly) to do in Java. How are public variables done?
2. Class "Shoot" goes like this:
public void Shoot(int castleRotation)
{
Rock rock = new Rock();
getWorld().addObject(rock, 302, 399);
setRotation(castleRotation);
}
I would think that that would create a new Rock right where my castle is, then add it to the world and rotate it to match what angle the Castle shot it at. All of the shots are going 0 degrees though.
Lots to look through, please give some advice. Public Variables are the most crucial thing I need help with.