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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 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++; } } |