Hey guys. I am pretty new to coding so I may not have that great of code. But I was planing to make a game where you have to defend yourself from enemy ships attacking back at you. It is kind of like space invaders. My problem is that I cannot make my enemy spaceship shoot back at the user. (the "badguy" is the enemy spaceship I trying to program to shoot towards the bottom of the screen.) Here is my code:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class laserv3bad here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class laserv3bad extends Actor
{
/**
* Act - do whatever the laserv3bad wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
setRotation(270);
setLocation(getX(), getY()-10);
disappear();
}
public void disappear()
{
Actor SpaceShip;
SpaceShip = getOneObjectAtOffset(0, 0, SpaceShip.class);
if (badguy != null)
{
World world;
world = getWorld();
world.removeObject(SpaceShip);
world.removeObject(this);
}
}
}

