ahh, this gonna sound like a really simple question but i have a scenario where i have a class that gets "attacked2 by zombies and ive made it so that if the zombie "hits the survivor" the survivor eats the zombie and some of his health is taken away(1/3) however i cant figure out how to subtract this health by twenty also when i "eat" a healthkit i need to add 20, any help?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
/**
* Write a description of class Survivor here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Survivor extends Players
{
private int counter = 0;
private int counter1 = 0;
private int health = 60;
/**
* Act - do whatever the Survivor wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
shoot();
move();
AssaultClass();
TntClass();
Helper();
Healer();
shooter();
HealthKit();
ZombieHit();
MouseInfo m = Greenfoot.getMouseInfo();
if(m != null)
turnTowards(m);
}
public void shooter()
{
Actor zombie;
zombie = getOneObjectAtOffset(0, 0, PreHelper3.class);
if (zombie != null)
{
World world;
world = getWorld();
world.removeObject(zombie);
getWorld().addObject(new Shooter(), getX(), getY());
}
}
public void HealthKit()
{
Actor zombie;
zombie = getOneObjectAtOffset(0, 0, HealthKit.class);
if (zombie != null && (health < 41))
{
World world;
world = getWorld();
world.removeObject(zombie);
health = 60;
}
}
public void ZombieHit()
{
Actor zombie;
zombie = getOneObjectAtOffset(0, 0, Zombie.class);
if (zombie != null)
{
World world;
world = getWorld();
world.removeObject(zombie);
health = 0;
if(health.getValue()==0) Greenfoot.stop();
}
}
