Hello. My game was almost done but I can't find way on how my game will be over if the Player was fired by the enemy. I can't make the enemy shot by the player.
I have here a code and this code is for one of my enemy, the problem is How am I gonna kill the enemy or the player using that code so the game will be over while the Time is running.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.*;
/**
* Write a description of class Snake here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Snake extends Actor
{
private int Speed = 3;
private int shotLate = 5;
public int deSync = Greenfoot.getRandomNumber(40);
public void act()
{
move();
checkEdges();
shoot();
}
public void move()
{
move(Speed);
}
public void checkEdges()
{
if(getX() > 990)
{
Speed = -3;
}
if(getX() <= 10)
{
Speed = 3;
}
}
public void shoot()
{
if(shotLate >= 25 && shotLate > deSync)
{
getWorld().addObject(new Fire(60), getX(), getY());
shotLate = 5;
}
shotLate++;
}
}

