I spent a lot of time making my first game ever and I was right about finishing it that this weird error appeared. Apparently, I am missing a reference pointer and the result prevents me from compiling/ running the game. I am not sure how I got there but I remember the last changes I made anterior to the bug was in the class called Rocket and I was playing around with the instances ad and adSpeed. Any help would be appreciated and thank you for your time:)
public class Rocket extends Actor
{
private int shotTimer = 0;
private static int ad=50;
public static int xPos=0;
public static int yPos=0;
private static boolean upupup= false;
private static int adSpeed=20;
public Rocket(int ad, int adSpeed)
{
this.ad=ad;
this.adSpeed= adSpeed;
}
private void setAdSpeed(int adSpeed)
{
this.adSpeed= adSpeed;
}
public void setAd(int ad)
{
this.ad=ad;
}
public static boolean getUp()
{
return upupup;
}
public static int getAd()
{
return ad;
}
public static int xPos()
{
return xPos;
}
public static int yPos()
{
return yPos;
}
/**
* Act - do whatever the Ship wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
xPos= getX();
yPos= getY();
if(Greenfoot.isKeyDown("w"))
{
this.setLocation(getX(), getY()-2);
}
if(Greenfoot.isKeyDown("s"))
{
this.setLocation(getX(), getY()+2);
}
if(Greenfoot.isKeyDown("a")&&this.getX()!=118)
{
this.setLocation(getX()-2, getY());
}
if(Greenfoot.isKeyDown("d"))
{
this.setLocation(getX()+2, getY());
}
if (shotTimer > 0) {
shotTimer = shotTimer - 1;
}
else if (Greenfoot.isKeyDown("space")) {
getWorld().addObject(new Shot(this), getX(), getY());
shotTimer = 20; // delay next shot
}
upgrade();
}
private void hit()
{
Actor rock= getOneObjectAtOffset(0,0,Asteroid.class);
Actor life= getOneObjectAtOffset(0,0,Life.class);
if(rock!=null)
{
getWorld().removeObject(this);
//getWorld().removeObject(life);
}
}
public void respawn()
{
getWorld().addObject(new Rocket(50,5),750, 650);
//if 1 set image 1 else if 2 set image 2
}
private void upgrade()
{
int money= Counter.getTotal();
if(Greenfoot.isKeyDown("m") &&money>=40)
{
setAd(60);
setAdSpeed(5);
setImage(new GreenfootImage("rocket27.png"));
Counter.backMoney();
}
}
}
