i want three things, the first being that i want trump to shoot left when i press left on my keyboard and then space to shoot and same thing for shooting to the right. second i want the score to go up 1 with every mexican i hit but it wont work for some reason, even though i did everything exacly as the youtubers do and their game works. the third is the gameover screen, i want it to appear when trump is either dead or i have reached score=20, i only need help with trump dying and the game stopping but my actor has multiple lives so im stuck.
if anyone can help with atleast one of these i would be greatful
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Trump here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Trump extends Actor
{int vSpeed;
int acceleration=1;
private int health = 3;
Rocket rocket = new Rocket();
private boolean spaceDown;
/**
* Act - do whatever the Trump wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
bestuur();
checkFall();
spring();
fire();
Shot();
}
public void Shot()
{
Actor Kogel = getOneObjectAtOffset(0, 0, Kogel.class);
if(Kogel != null)
{
getWorld().removeObject(Kogel);
health--;
if (health == 0) getWorld().removeObject(this);
return;
}
Actor Bom = getOneObjectAtOffset(0, 0, Bom.class);
if (Bom != null)
{
getWorld().removeObject(Bom);
health--;
if (health == 0) getWorld().removeObject(this);
return;
}
}
public void spring()
{
if(Greenfoot.isKeyDown("up") && onGround())
{
vSpeed=-15;
setLocation (getX(), getY() + vSpeed);
}
Object above = getOneObjectAtOffset(0, -getImage().getHeight()/2 - 2, Steen.class);
if (Greenfoot.isKeyDown("space") && above!=null) // Deze code zorgt ervoor dat je niet van onder door de bricks kan.
{
vSpeed=0;
}
}
public boolean onGround()
{
Object under = getOneObjectAtOffset(0, getImage().getHeight()/2 + 2, Steen.class);
return under != null;
}
public void checkFall()
{
if (onGround()) {
vSpeed = 0;
}
else {
fall();
}
}
public void fall()
{
setLocation (getX(), getY() + vSpeed);
if(vSpeed<10)
{
vSpeed += acceleration;
}
}
public void bestuur()
{
if (Greenfoot.isKeyDown("left"))
{
move(-3);
}
if (Greenfoot.isKeyDown("right"))
{
move(3);
}
}
public void fire()
{
if (!spaceDown && Greenfoot.isKeyDown("space"))
{
for (int i = 0; i<2;i++)
{
Rocket rocket = new Rocket();
getWorld().addObject(rocket,getX(), getY());
if(Greenfoot.isKeyDown("right" )){
rocket.setRotation(0*i);
rocket.move(10);
}
else if(Greenfoot.isKeyDown("left" )){
rocket.setRotation(180*i);
rocket.move(-10);
}
}
spaceDown=true;
}
if (spaceDown && !Greenfoot.isKeyDown("space"))
{
spaceDown = false;
}
}
}

