Esempio n. 1
1
  public void collided() {
    /*
     * Reduce 30% of current bar everytime
     */

    if (lives != 0) lives -= 0.2 * 100;
    else {
      Greenfoot.stop();
      add(new ScoreBoard(), 300, 300);
    }
  }
Esempio n. 2
0
  public void act() // sean
      {

    if (!played) {
      burningSteppes.playLoop();
      played = !played;
    }
    // makeSmokeFireball();
    counterDelay++;
    if (Greenfoot.isKeyDown("h") && delay > 10) {
      clickSound.play();
      Menu menu = new Menu(getThisWorld());
      Greenfoot.setWorld(menu);
      delay = 0;
    }
    if (getObjects(Ninja.class).size() != 0 && counterDelay >= 10) {
      healthCounter.setValue(ninja.getNINJAHP());
      shurikenCounter.setValue(ninja.getSHURIKENNUMBER());
      powerCounter.setValue(ninja.getPOWERBAR());
      checkDoor();
      counterDelay -= 10;
      /**/
      // TEMPORAY FUNCTIONS FOR HAYDEN TO CHANGE LEVELS TO MAKE THEM /**/

      /**/
      // TEMPORAY FUNCTIONS FOR HAYDEN TO CHANGE LEVELS TO MAKE THEM /**/
    }
    delay++;
    fireballDelay++;
  }
Esempio n. 3
0
 public void chanceToBackground() {
   if (Greenfoot.getRandomNumber(50) < 1) {
     add(new Background(), Greenfoot.getRandomNumber(150), 0);
   }
   if (Greenfoot.getRandomNumber(50) < 1) {
     add(new Background(), Greenfoot.getRandomNumber(150) + 450, 0);
   }
 }
Esempio n. 4
0
 public Flame(boolean s, boolean o, boolean z) {
   initialiseImages();
   small = s;
   burnOil = o;
   burnZombie = z;
   lastImage = (60 - Greenfoot.getRandomNumber(10));
 }
Esempio n. 5
0
 /*
 public void makeSmokeFireball()
 {
     if (delay > 100)
     {
         int randomNumber = Greenfoot.getRandomNumber(1000);
         if (randomNumber < 50)
         {
             SmokeFireball smokeFireball = new SmokeFireball();
             addObject(smokeFireball, 500, 475);
             delay = 0;
         }
         if (randomNumber >= 50 && randomNumber < 100)
         {
             SmokeFireball smokeFireball = new SmokeFireball();
             addObject(smokeFireball, 95, 661);
             delay = 0;
         }
         if (randomNumber >= 100 && randomNumber < 150)
         {
             SmokeFireball smokeFireball = new SmokeFireball();
             addObject(smokeFireball, 160, 493);
             delay = 0;
         }
         if (randomNumber >= 150 && randomNumber < 200)
         {
             SmokeFireball smokeFireball = new SmokeFireball();
             addObject(smokeFireball, 637, 423);
             delay = 0;
         }
         if (randomNumber >= 200 && randomNumber < 250)
         {
             SmokeFireball smokeFireball = new SmokeFireball();
             addObject(smokeFireball, 422, 285);
             delay = 0;
         }
     }
 }
 */
 public void checkDoor() // sean
     {
   if (ninja.checkInfernoDoor() == true) {
     burningSteppes.stop();
     Greenfoot.setWorld(new Inferno2(ninja));
   }
 }
Esempio n. 6
0
  public void
      checkTPress() // this method whether T key is being pressed o not and move the object
                    // according do following.
      {
    if (alive) // check if the ship alive
    {
      DeepSpace myDeepSpace = (DeepSpace) getWorld(); // get referance to the DeepSpace class
      FuelTank myFuelTank =
          myDeepSpace
              .myFuelTank(); // use myFuelTank method that return reference of FuelTank class. So
                             // you can call method of Fueltank class.

      if (Greenfoot.isKeyDown("t")
          && !myFuelTank
              .empty()) // if "t" key is being pressed by user and if i have enough fuel, do
                        // following.
      {

        move(3); // move forward direction of object
        setImage("rocket.png"); // set the image rocket that seems like burning fuel.
        myFuelTank
            .burn(); // call the Fueltank class method in order to decrese level of fuel on screen
      } else
        setImage("rocket_noThrust.png"); // if no key is being press than set the regular picture.
    }
  }
 /**
  * Act - do whatever the Desicion wants to do. This method is called whenever the 'Act' or 'Run'
  * button gets pressed in the environment.
  */
 public void act() {
   MouseInfo mouse = Greenfoot.getMouseInfo();
   if (Greenfoot.mouseClicked(this)) {
     if (mouse.getButton() == 3) // right-click
     {
       construyeDialogo();
     } else {
       if (((WActividades) getWorld()).mousePresionado) {
         ((WActividades) getWorld()).agregaPunto(getX(), getY(), true);
         ((WActividades) getWorld()).mousePresionado = false;
       }
     }
   } else if (Greenfoot.mousePressed(this)) {
     ((WActividades) getWorld()).agregaPunto(getX(), getY(), false);
     ((WActividades) getWorld()).mousePresionado = true;
   }
 }
Esempio n. 8
0
 public Flame(int r, int d, boolean s, boolean o) {
   initialiseImages();
   small = s;
   burnOil = o;
   setRotation(r);
   addForce(new Vector(r, d));
   lastImage = (60 - Greenfoot.getRandomNumber(10));
 }
Esempio n. 9
0
 public Flame(int r, double d, boolean s, boolean o, boolean z, boolean p, int damage) {
   initialiseImages();
   small = s;
   burnOil = o;
   burnZombie = z;
   burnPlayer = p;
   setRotation(r);
   addForce(new Vector(r, d));
   lastImage = (60 - Greenfoot.getRandomNumber(10));
   this.damage = damage;
 }
Esempio n. 10
0
 public Flame(boolean s) {
   initialiseImages();
   small = s;
   burnOil = false;
   lastImage = (60 - Greenfoot.getRandomNumber(10));
 }
Esempio n. 11
0
  /** Constructor for objects of class CarWorld. */
  public CarWorld() {
    super(600, 600, 1);
    setPaintOrder(
        Start.class,
        Help.class,
        Pause.class,
        Information.class,
        ScoreBoard.class,
        Dot.class,
        Path.class,
        Car.class,
        Bomb.class,
        Vehicle.class,
        Person.class,
        PedestrianCrossing.class,
        EndLine.class,
        Line.class,
        Counter.class,
        Lives.class,
        Background.class);
    // Greenfoot.playSound("minion_theme_01.mp3");

    // Setting background sound resources
    setBackgroundSounds();

    lives = 100;
    score = 0;
    pause = true;
    // changes by Manthan start
    car = new Car();
    car.attachObserver(new CarController(car));
    // Changes by manthan end
    leafs = new ArrayList<Component>();
    add(car, 305, 550);
    add(new Counter("Score: "), 95, 550);
    /*add(new Lives(),50,50);
    add(new Lives(),100,50);
    add(new Lives(),150,50);
    */
    add(new Dot(), 25, 395);
    add(new Path(), 25, 250);

    // Banana score visualization
    add(new BananaScore("Banana Score: "), 150, 580);
    // Weapon Power visualization
    bar.setShowTextualUnits(false);
    addObject(bar, 500, 50);

    // Life visualization
    lifeBar.setShowTextualUnits(false);
    addObject(lifeBar, 70, 50);
    lifeBar.setValue(100);

    /*add(new Line(),300,0);
    add(new Line(),300,90);
    add(new Line(),300,180);
    add(new Line(),300,270);
    add(new Line(),300,360);
    add(new Line(),300,450);
    add(new Line(),300,540);*/
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    //         add(new Information(),300,300);
    add(new Start(), 480, 550);
    add(new Help(), 550, 550);
  }
Esempio n. 12
0
 public void chanceToBanana() {
   if (Greenfoot.getRandomNumber(100) < 1) {
     add(new Banana(), Greenfoot.getRandomNumber(185) + 215, 0);
   }
 }
Esempio n. 13
0
 public void chanceToRocket() {
   if (Greenfoot.getRandomNumber(1000) < 1) {
     add(new Rocket(), Greenfoot.getRandomNumber(185) + 215, 0);
   }
 }
Esempio n. 14
0
 public void chanceToVehicle() {
   if (Greenfoot.getRandomNumber(100) < 1) {
     add(new Vehicle(), Greenfoot.getRandomNumber(185) + 215, 0);
   }
 }
Esempio n. 15
0
 public void gameover() { // Hayden
   ninja.setHP(ninja.getArmor());
   burningSteppes.stop();
   Greenfoot.setWorld(new Inferno1(ninja));
 }
    /**
     * Act - do whatever the GameLogicVracht wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        float dt = 1.0f / 60.0f;
                     
        //Deze code spawnt de containers en checkt of er collision is tussen containers en trucks met bijbehorende kleuren. Zo ja, dan worden er acties uitgevoerd.
        //Gele truck
        for(int i = 0; i < AantalContainersGeel; i++)
        {
            if(EpicVrachtOverslaan.Vector2.Distance(truckGeelPosition, containerGeelPosition.get(i)) <= 50.0)
            {
                //Als de container de vrachtwagen aangeraakt heeft, is er collision. Dan doen we:
                collisiongeel = 1;
            }

            if(collisiongeel == 1)
            {
            //Eerst veranderen we de sprite naar de volle versie.    
            truckGeelAppearance = new EpicVrachtOverslaan.Texture2D("Truck Geel Vol.png");
            //Dan rijdt de truck weg.
            truckGeelPosition = truckGeelPosition.sub(EpicVrachtOverslaan.Vector2.UnitX.mul(dt).mul(300.0f));
            //eventueel kunnen we later nog toevoegen dat de trucks elkaars plaats innemen.
                     
            }
        }
            
            
        //Blauwe truck
        for(int i = 0; i <  AantalContainersBlauw; i++)
        {
            if(EpicVrachtOverslaan.Vector2.Distance(truckBlauwPosition, containerBlauwPosition.get(i)) <= 50.0)
            {
                //Als de container de vrachtwagen aangeraakt heeft, is er collision. Dan doen we:
                collisionblauw = 1;
            }
         
            if(1 == 1)
            {
            //Eerst veranderen we de sprite naar de volle versie.    
            truckBlauwAppearance = new EpicVrachtOverslaan.Texture2D("Truck Blauw Vol.png");
            //Dan rijdt de truck weg.
            truckBlauwPosition = truckBlauwPosition.sub(EpicVrachtOverslaan.Vector2.UnitX.mul(dt).mul(28.0f));
            //eventueel kunnen we later nog toevoegen dat de trucks elkaars plaats innemen.
            }
        }
            
        //Groene truck
        for(int i = 0; i <  AantalContainersGroen; i++)
        {
            if(EpicVrachtOverslaan.Vector2.Distance(truckGroenPosition, containerGroenPosition.get(i)) <= 50.0)
            {
                //Als de container de vrachtwagen aangeraakt heeft, is er collision. Dan doen we:
                collisiongroen = 1;
            }
         
            if(collisiongroen == 1)
            {
            //Eerst veranderen we de sprite naar de volle versie.    
            truckGroenAppearance = new EpicVrachtOverslaan.Texture2D("Truck Groen Vol.png");
            //Dan rijdt de truck weg.            
            truckGeelPosition = truckGeelPosition.sub(EpicVrachtOverslaan.Vector2.UnitX.mul(dt).mul(300.0f));
            //eventueel kunnen we later nog toevoegen dat de trucks elkaars plaats innemen.
            }
        }
        
        
        //Rood
        for(int i = 0; i <  AantalContainersRood; i++)
        {
          
            if(EpicVrachtOverslaan.Vector2.Distance(truckRoodPosition, containerRoodPosition.get(i)) <= 50.0)
            {
            //Als de container de vrachtwagen aangeraakt heeft, is er collision. Dan doen we:

            collisionrood = 1;
            }
         
            if(collisionrood == 1)
            {
            //Eerst veranderen we de sprite naar de volle versie.    
            truckRoodAppearance = new EpicVrachtOverslaan.Texture2D("Truck Rood Vol.png");
            //Dan rijdt de truck weg.
            truckRoodPosition = truckRoodPosition.sub(EpicVrachtOverslaan.Vector2.UnitX.mul(dt).mul(300.0f));   
            }
        }
        
        for(int i = 0; i <  AantalContainersRood; i++)
        {
            if(EpicVrachtOverslaan.Vector2.Distance(grijperPosition, containerRoodPosition.get(i)) <=50.0 && Greenfoot.isKeyDown(" "))
            {
                JOptionPane.showMessageDialog(new JInternalFrame(), "Message content","Message title", JOptionPane.INFORMATION_MESSAGE);  
                
                containerRoodPosition[i];
            }
        }
        
        
        
        
       
        //Met deze code word het bewegen v.d. grijper met de w-a-s-d toetsen geregeld.
        if (Greenfoot.isKeyDown("A"))
          grijperPosition = grijperPosition.sub(EpicVrachtOverslaan.Vector2.UnitX.mul(dt).mul(300.0f));
        if (Greenfoot.isKeyDown("D"))
          grijperPosition = grijperPosition.add(EpicVrachtOverslaan.Vector2.UnitX.mul(dt).mul(300));
        if (Greenfoot.isKeyDown("W"))
          grijperPosition = grijperPosition.sub(EpicVrachtOverslaan.Vector2.UnitY.mul(dt).mul(300.0f));
        if (Greenfoot.isKeyDown("S"))
          grijperPosition = grijperPosition.add(EpicVrachtOverslaan.Vector2.UnitY.mul(dt).mul(300.0f));
        
        
        //Alle code hieronder doet het daadwerkelijke "plaatsen" v.d. objecten onder de door ons hierboven gegeven voorwaarden.
        EpicVrachtOverslaan.DrawingContext drawingContext = EpicVrachtOverslaan.DrawingContext;
        drawingContext.BeginDraw();
        EpicVrachtOverslaan.DrawingContext.Draw(truckGeelAppearance, truckGeelPosition);
        EpicVrachtOverslaan.DrawingContext.Draw(truckRoodAppearance, truckRoodPosition);
        EpicVrachtOverslaan.DrawingContext.Draw(truckGroenAppearance, truckGroenPosition);
        EpicVrachtOverslaan.DrawingContext.Draw(truckBlauwAppearance, truckBlauwPosition);
       
        for(EpicVrachtOverslaan.Vector2 a : containerGeelPosition)
        {
            drawingContext.Draw(containerGeelAppearance, a);
        }
        
        for(EpicVrachtOverslaan.Vector2 a : containerRoodPosition)
        {
            drawingContext.Draw(containerRoodAppearance, a);
        }
        
        for(EpicVrachtOverslaan.Vector2 a : containerGroenPosition)
        {
            drawingContext.Draw(containerGroenAppearance, a);
        }
        
        for(EpicVrachtOverslaan.Vector2 a : containerBlauwPosition)
        {
            drawingContext.Draw(containerBlauwAppearance, a);
        }
              
        EpicVrachtOverslaan.DrawingContext.Draw(grijperAppearance, grijperPosition);
        
        EpicVrachtOverslaan.DrawingContext.Draw(voortgansbalkAppearance, voortangsbalkPosition);
        EpicVrachtOverslaan.DrawingContext.Draw(indicatiebalkAppearance, indicatiebalkPosition);
        
        
        

    }