so i am working on a project for school and i need my rocket to move in all directions and shoot. it moves but when it shoot it decides to stop. What can i do to change this?
import greenfoot.*;
public class Me extends Actor
{
int eX, eY, aX, aY;
static int shoot = 1;
int speed = 3;
public void act()
{
String key = Greenfoot.getKey();
if(getWorld().getObjects(EnemyBullet.class).size() != 0)
{
if(Greenfoot.isKeyDown("right")) {
setRotation(0);
move(5);
}
if(Greenfoot.isKeyDown("down"))
{
setRotation(90);
move(5);
}
if(Greenfoot.isKeyDown("left"))
{
setRotation(180);
move(5);
}
if(Greenfoot.isKeyDown("up"))
{
setRotation(270);
move(5);
if(isAtEdge())
{
Greenfoot.setWorld(new world2());
}
}
if(shoot == 1)
{
getWorld().addObject(new Bullet(),getX(),getY());
shoot = 0;
}
}
else if(getWorld().getObjects(Enemy.class).size() != 0)
{
eX = ((Enemy)getWorld().getObjects(Enemy.class).get(0)).getX();
eY = ((Enemy)getWorld().getObjects(Enemy.class).get(0)).getY();
turnTowards(eX, eY);
if(eX < getWorld().getWidth()/2)
{
if(shoot == 1)
{
getWorld().addObject(new Bullet(),getX(),getY());
shoot = 0;
}
}
}
if("space".equals(key))
{
getWorld().addObject(new Bullet(),getX(), getY());
}
}
}
this is the code i am using, i would like to change worlds when i get to the end of the world also, can anyone help? if so it would be appreciated!!