import greenfoot.*;_x000D_
import java.io.IOException;_x000D_
import java.util.List;_x000D_
import java.util.ArrayList;_x000D_
import javax.swing.*;_x000D_
_x000D_
public class HelicopterWorld extends World {_x000D_
    private Helicopter helicopter;_x000D_
    private Counter scoreCounter;_x000D_
    private MenuBar menuBar;_x000D_
    private Wall wall;_x000D_
    private Direction direction;_x000D_
    private HeliWater water;_x000D_
    private HP hp;_x000D_
    private HeliHealth health1;_x000D_
    private HeliHealth health2;_x000D_
    private HeliHealth health3;_x000D_
    private Health2 health4;_x000D_
    private Health2 health5;_x000D_
    private Health2 health6;_x000D_
    private int healthlost;_x000D_
    private int healthlostrope;_x000D_
    private Victim victim;_x000D_
    private House house;_x000D_
    private NeedsHelp needshelp;_x000D_
    GreenfootSound backgroundMusic = new GreenfootSound("background_music.mp3");_x000D_
    _x000D_
    public HelicopterWorld() {_x000D_
        super(80, 80, 10, false);_x000D_
        setBackground("bg.png");_x000D_
        backgroundMusic.playLoop();_x000D_
        for (int i = 1; i < 100; ++i) {_x000D_
            // Willekeurige huizen en slachtoffers worden in het spel geplaatst._x000D_
            Victim victim;_x000D_
            House house;_x000D_
            int yvictim = 58;_x000D_
            int yhouse = 65;_x000D_
            int x = i * 50 + (-5 + Greenfoot.getRandomNumber(30));_x000D_
            int randomhouse = (int)(Math.random() * ((9 - 0) + 1));_x000D_
            int randomvictim = 0 + (int)(Math.random() * ((7 - 0) + 1));_x000D_
            switch (randomhouse) {_x000D_
                case 0: house = new House1(); break;_x000D_
                case 1: house = new House2(); yvictim -= 4; yhouse -= 2; break;_x000D_
                case 2: house = new House3(); yvictim -= 2; yhouse -= 1; break;_x000D_
                case 3: house = new House4(); yvictim -= 37; yhouse -= 19; break;_x000D_
                case 4: house = new House5(); yvictim -= 32; yhouse -= 16; break;_x000D_
                case 5: house = new House6(); yvictim -= 26; yhouse -= 13; break;_x000D_
                case 6: house = new House7(); yvictim -= 8; yhouse -= 4; break;_x000D_
                case 7: house = new House8(); yvictim -= 10; yhouse -= 5; break;_x000D_
                case 8: house = new House9(); yvictim -= 22; yhouse -= 11; break;_x000D_
                case 9: house = new House10(); yvictim -= 22; yhouse -= 11; break;_x000D_
                _x000D_
                default:_x000D_
                    // Will never happen._x000D_
                    assert false;_x000D_
                    return;_x000D_
            }_x000D_
            addObject(house, x, yhouse);_x000D_
            _x000D_
            switch (randomvictim) {_x000D_
                case 0: victim = new Victim1(); break;_x000D_
                case 1: victim = new Victim2(); break;_x000D_
                case 2: victim = new Victim3(); break;_x000D_
                case 3: victim = new Victim4(); break;_x000D_
                case 4: victim = new Victim5(); break;_x000D_
                case 5: victim = new Victim6(); break;_x000D_
                case 6: victim = new Victim7(); break;_x000D_
                case 7: victim = new Victim8(); break;_x000D_
_x000D_
                default:_x000D_
                    // Will never happen._x000D_
                    assert false;_x000D_
                    return;_x000D_
            }_x000D_
            addObject(victim, x, yvictim);_x000D_
            _x000D_
            //Uitroeptekens boven de slachtoffers worden geplaatst._x000D_
            needshelp = new NeedsHelp();_x000D_
            addObject(needshelp, x, yvictim-4);_x000D_
                _x000D_
        }_x000D_
        _x000D_
        //Alle start objecten worden geplaatst._x000D_
        helicopter = new Helicopter();_x000D_
        addObject(helicopter, 40, 10);_x000D_
_x000D_
        direction = new Direction();_x000D_
        addObject(direction, 20, 68);_x000D_
_x000D_
        scoreCounter = new Counter("Score: ");_x000D_
        addObject(scoreCounter, 6, 73);_x000D_
_x000D_
        menuBar = new MenuBar();_x000D_
        addObject(menuBar, 39, 75);_x000D_
_x000D_
        wall = new Wall();_x000D_
        addObject(wall, -35, 40);_x000D_
_x000D_
        water = new HeliWater();_x000D_
        addObject(water, 40, 70);_x000D_
        _x000D_
        hp = new HP();_x000D_
        addObject(hp, 60, 64);_x000D_
        _x000D_
        health1 = new HeliHealth();_x000D_
        addObject(health1, 60, 73);_x000D_
        _x000D_
        health2 = new HeliHealth();_x000D_
        addObject(health2, 64, 73);_x000D_
        _x000D_
        health3 = new HeliHealth();_x000D_
        addObject(health3, 68, 73);_x000D_
        _x000D_
        health4 = new Health2();_x000D_
        addObject(health4, 60, 77);_x000D_
        _x000D_
        health5 = new Health2();_x000D_
        addObject(health5, 64, 77);_x000D_
        _x000D_
        health6 = new Health2();_x000D_
        addObject(health6, 68, 77);_x000D_
_x000D_
        setPaintOrder(Counter.class, HP.class, Health2.class, HeliHealth.class, Helicopter.class, MenuBar.class, Wall.class, HeliWater.class, Victim.class, MenuBar.class, House.class, SpeedPowerUp.class, RadiusPowerUp.class, NeedsHelp.class);_x000D_
    }_x000D_
_x000D_
    @Override_x000D_
    public void act() {_x000D_
        //Check actors_x000D_
        for (Actor actor : (List<Actor>)getObjects(null)) {_x000D_
            if (actor == helicopter) continue;_x000D_
            if (actor == scoreCounter) continue;_x000D_
_x000D_
            actor.setLocation(actor.getX() + 40 - helicopter.getX(), actor.getY());_x000D_
        }_x000D_
        _x000D_
        //PowerUp spawn_x000D_
        if (Math.random() < 0.003) {_x000D_
            Actor powerUp;_x000D_
            switch (Greenfoot.getRandomNumber(2)) {_x000D_
                case 0: powerUp = new SpeedPowerUp(); break;_x000D_
                case 1: powerUp = new RadiusPowerUp(); break;_x000D_
                default:_x000D_
                    // Will never happen._x000D_
                    assert false;_x000D_
                    return;_x000D_
            }_x000D_
            addObject(powerUp, -50 + Greenfoot.getRandomNumber(100), Greenfoot.getRandomNumber(40));_x000D_
        }_x000D_
        _x000D_
        //Zorg ervoor dat bepaalde objecten een vaste plaats op het scherm hebben._x000D_
        helicopter.setLocation(40, helicopter.getY());_x000D_
        scoreCounter.setLocation(6, 73);_x000D_
        menuBar.setLocation(39, 75);_x000D_
        health1.setLocation(60, 73);_x000D_
        health2.setLocation(64, 73);_x000D_
        health3.setLocation(68, 73);_x000D_
        health4.setLocation(60, 77);_x000D_
        health5.setLocation(64, 77);_x000D_
        health6.setLocation(68, 77);_x000D_
        hp.setLocation(60,64);_x000D_
    _x000D_
    }_x000D_
    _x000D_
    //Return water level_x000D_
    public int getWaterLevel() {_x000D_
        return water.getLevel();_x000D_
    }_x000D_
    _x000D_
    //Voegt score toe_x000D_
    public void addScore(int x) {_x000D_
        scoreCounter.add(x);_x000D_
    }_x000D_
    _x000D_
    //Proces bij het verliezen van een leven bij helikopter_x000D_
    public void lostLife() {_x000D_
        healthlost ++;_x000D_
        switch (healthlost) {_x000D_
            case 1: removeObject(health1); break;_x000D_
            case 2: removeObject(health2); break;_x000D_
            case 3:_x000D_
                removeObject(health3);_x000D_
                gameOver();_x000D_
                break;_x000D_
        }_x000D_
    }_x000D_
    _x000D_
    //Proces bij het verliezen van een leven bij ropeman_x000D_
    public void lostLifeRope() {_x000D_
        healthlostrope ++;_x000D_
        switch (healthlostrope) {_x000D_
            case 1: removeObject(health4); break;_x000D_
            case 2: removeObject(health5); break;_x000D_
            case 3:_x000D_
                removeObject(health6);_x000D_
                gameOver();_x000D_
                break;_x000D_
        }_x000D_
    }_x000D_
    _x000D_
    //Laad gameover scherm_x000D_
    private void gameOver() {_x000D_
        Greenfoot.setWorld(new GameOverWorld(Game.HELICOPTER_GAME, scoreCounter.getValue()));_x000D_
    }_x000D_
}_x000D_

// Willekeurige huizen en slachtoffers worden in het spel geplaatst._x000D_
import greenfoot.*;_x000D_
import java.io.IOException;_x000D_
import java.util.List;_x000D_
import java.util.ArrayList;_x000D_
import javax.swing.*;_x000D_
_x000D_
public class HelicopterWorld extends World {_x000D_
    private Helicopter helicopter;_x000D_
    private Counter scoreCounter;_x000D_
    private MenuBar menuBar;_x000D_
    private Wall wall;_x000D_
    private Direction direction;_x000D_
    private HeliWater water;_x000D_
    private HP hp;_x000D_
    private HeliHealth health1;_x000D_
    private HeliHealth health2;_x000D_
    private HeliHealth health3;_x000D_
    private Health2 health4;_x000D_
    private Health2 health5;_x000D_
    private Health2 health6;_x000D_
    private int healthlost;_x000D_
    private int healthlostrope;_x000D_
    private Victim victim;_x000D_
    private House house;_x000D_
    private NeedsHelp needshelp;_x000D_
    GreenfootSound backgroundMusic = new GreenfootSound("background_music.mp3");_x000D_
    _x000D_
    public HelicopterWorld() {_x000D_
        super(80, 80, 10, false);_x000D_
        setBackground("bg.png");_x000D_
        backgroundMusic.playLoop();_x000D_
        for (int i = 1; i < 100; ++i) {_x000D_
            // Willekeurige huizen<SUF>
            Victim victim;_x000D_
            House house;_x000D_
            int yvictim = 58;_x000D_
            int yhouse = 65;_x000D_
            int x = i * 50 + (-5 + Greenfoot.getRandomNumber(30));_x000D_
            int randomhouse = (int)(Math.random() * ((9 - 0) + 1));_x000D_
            int randomvictim = 0 + (int)(Math.random() * ((7 - 0) + 1));_x000D_
            switch (randomhouse) {_x000D_
                case 0: house = new House1(); break;_x000D_
                case 1: house = new House2(); yvictim -= 4; yhouse -= 2; break;_x000D_
                case 2: house = new House3(); yvictim -= 2; yhouse -= 1; break;_x000D_
                case 3: house = new House4(); yvictim -= 37; yhouse -= 19; break;_x000D_
                case 4: house = new House5(); yvictim -= 32; yhouse -= 16; break;_x000D_
                case 5: house = new House6(); yvictim -= 26; yhouse -= 13; break;_x000D_
                case 6: house = new House7(); yvictim -= 8; yhouse -= 4; break;_x000D_
                case 7: house = new House8(); yvictim -= 10; yhouse -= 5; break;_x000D_
                case 8: house = new House9(); yvictim -= 22; yhouse -= 11; break;_x000D_
                case 9: house = new House10(); yvictim -= 22; yhouse -= 11; break;_x000D_
                _x000D_
                default:_x000D_
                    // Will never happen._x000D_
                    assert false;_x000D_
                    return;_x000D_
            }_x000D_
            addObject(house, x, yhouse);_x000D_
            _x000D_
            switch (randomvictim) {_x000D_
                case 0: victim = new Victim1(); break;_x000D_
                case 1: victim = new Victim2(); break;_x000D_
                case 2: victim = new Victim3(); break;_x000D_
                case 3: victim = new Victim4(); break;_x000D_
                case 4: victim = new Victim5(); break;_x000D_
                case 5: victim = new Victim6(); break;_x000D_
                case 6: victim = new Victim7(); break;_x000D_
                case 7: victim = new Victim8(); break;_x000D_
_x000D_
                default:_x000D_
                    // Will never happen._x000D_
                    assert false;_x000D_
                    return;_x000D_
            }_x000D_
            addObject(victim, x, yvictim);_x000D_
            _x000D_
            //Uitroeptekens boven de slachtoffers worden geplaatst._x000D_
            needshelp = new NeedsHelp();_x000D_
            addObject(needshelp, x, yvictim-4);_x000D_
                _x000D_
        }_x000D_
        _x000D_
        //Alle start objecten worden geplaatst._x000D_
        helicopter = new Helicopter();_x000D_
        addObject(helicopter, 40, 10);_x000D_
_x000D_
        direction = new Direction();_x000D_
        addObject(direction, 20, 68);_x000D_
_x000D_
        scoreCounter = new Counter("Score: ");_x000D_
        addObject(scoreCounter, 6, 73);_x000D_
_x000D_
        menuBar = new MenuBar();_x000D_
        addObject(menuBar, 39, 75);_x000D_
_x000D_
        wall = new Wall();_x000D_
        addObject(wall, -35, 40);_x000D_
_x000D_
        water = new HeliWater();_x000D_
        addObject(water, 40, 70);_x000D_
        _x000D_
        hp = new HP();_x000D_
        addObject(hp, 60, 64);_x000D_
        _x000D_
        health1 = new HeliHealth();_x000D_
        addObject(health1, 60, 73);_x000D_
        _x000D_
        health2 = new HeliHealth();_x000D_
        addObject(health2, 64, 73);_x000D_
        _x000D_
        health3 = new HeliHealth();_x000D_
        addObject(health3, 68, 73);_x000D_
        _x000D_
        health4 = new Health2();_x000D_
        addObject(health4, 60, 77);_x000D_
        _x000D_
        health5 = new Health2();_x000D_
        addObject(health5, 64, 77);_x000D_
        _x000D_
        health6 = new Health2();_x000D_
        addObject(health6, 68, 77);_x000D_
_x000D_
        setPaintOrder(Counter.class, HP.class, Health2.class, HeliHealth.class, Helicopter.class, MenuBar.class, Wall.class, HeliWater.class, Victim.class, MenuBar.class, House.class, SpeedPowerUp.class, RadiusPowerUp.class, NeedsHelp.class);_x000D_
    }_x000D_
_x000D_
    @Override_x000D_
    public void act() {_x000D_
        //Check actors_x000D_
        for (Actor actor : (List<Actor>)getObjects(null)) {_x000D_
            if (actor == helicopter) continue;_x000D_
            if (actor == scoreCounter) continue;_x000D_
_x000D_
            actor.setLocation(actor.getX() + 40 - helicopter.getX(), actor.getY());_x000D_
        }_x000D_
        _x000D_
        //PowerUp spawn_x000D_
        if (Math.random() < 0.003) {_x000D_
            Actor powerUp;_x000D_
            switch (Greenfoot.getRandomNumber(2)) {_x000D_
                case 0: powerUp = new SpeedPowerUp(); break;_x000D_
                case 1: powerUp = new RadiusPowerUp(); break;_x000D_
                default:_x000D_
                    // Will never happen._x000D_
                    assert false;_x000D_
                    return;_x000D_
            }_x000D_
            addObject(powerUp, -50 + Greenfoot.getRandomNumber(100), Greenfoot.getRandomNumber(40));_x000D_
        }_x000D_
        _x000D_
        //Zorg ervoor dat bepaalde objecten een vaste plaats op het scherm hebben._x000D_
        helicopter.setLocation(40, helicopter.getY());_x000D_
        scoreCounter.setLocation(6, 73);_x000D_
        menuBar.setLocation(39, 75);_x000D_
        health1.setLocation(60, 73);_x000D_
        health2.setLocation(64, 73);_x000D_
        health3.setLocation(68, 73);_x000D_
        health4.setLocation(60, 77);_x000D_
        health5.setLocation(64, 77);_x000D_
        health6.setLocation(68, 77);_x000D_
        hp.setLocation(60,64);_x000D_
    _x000D_
    }_x000D_
    _x000D_
    //Return water level_x000D_
    public int getWaterLevel() {_x000D_
        return water.getLevel();_x000D_
    }_x000D_
    _x000D_
    //Voegt score toe_x000D_
    public void addScore(int x) {_x000D_
        scoreCounter.add(x);_x000D_
    }_x000D_
    _x000D_
    //Proces bij het verliezen van een leven bij helikopter_x000D_
    public void lostLife() {_x000D_
        healthlost ++;_x000D_
        switch (healthlost) {_x000D_
            case 1: removeObject(health1); break;_x000D_
            case 2: removeObject(health2); break;_x000D_
            case 3:_x000D_
                removeObject(health3);_x000D_
                gameOver();_x000D_
                break;_x000D_
        }_x000D_
    }_x000D_
    _x000D_
    //Proces bij het verliezen van een leven bij ropeman_x000D_
    public void lostLifeRope() {_x000D_
        healthlostrope ++;_x000D_
        switch (healthlostrope) {_x000D_
            case 1: removeObject(health4); break;_x000D_
            case 2: removeObject(health5); break;_x000D_
            case 3:_x000D_
                removeObject(health6);_x000D_
                gameOver();_x000D_
                break;_x000D_
        }_x000D_
    }_x000D_
    _x000D_
    //Laad gameover scherm_x000D_
    private void gameOver() {_x000D_
        Greenfoot.setWorld(new GameOverWorld(Game.HELICOPTER_GAME, scoreCounter.getValue()));_x000D_
    }_x000D_
}_x000D_
