Пример #1
0
  public void checkDrag() {
    Land land = (Land) getWorld();
    if (Greenfoot.mouseDragged(this)) {
      MouseInfo mouse = Greenfoot.getMouseInfo();
      if (cost <= land.getMoneyAmount()) {
        if (hasTurret == false) {
          land.removeObjects(land.getObjects(Radius.class));

          machineGun = new MachineGun_Turret();
          getWorld().addObject(machineGun, mouse.getX(), mouse.getY());
          hasTurret = true;
          land.setMoneyCounter(-cost);
        }
      }
      if (hasTurret == true) machineGun.setLocation(mouse.getX(), mouse.getY());
    }
    if ((Greenfoot.mouseDragEnded(null)) && (machineGun != null)) {
      grid();
      if (machineGun.checkLocation()) {
        machineGun.placed = true;
        hasTurret = false;
        machineGun = null;
      } else {
        land.removeObject(machineGun);
        machineGun = null;
        land.setMoneyCounter(cost);
        hasTurret = false;
      }
    }
  }
Пример #2
0
 @Override
 public void act() {
   if (Greenfoot.isKeyDown("enter")) {
     Greenfoot.setWorld(new SkyscraperWorld());
     return;
   }
 }
Пример #3
0
 /**
  * Herado de la clase abstracta Boton si se presiono el objecto con el cursor cambia el mundo
  * donde se encuentra
  *
  * @param m musica actual
  * @param w mundo actual
  */
 public void cambiaMundo(GreenfootSound m, World w) {
   if (Greenfoot.mouseClicked(this)) {
     Greenfoot.playSound("Click.mp3");
     w = new AyudaFondo(m);
     Greenfoot.setWorld(w);
   }
 }
Пример #4
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++;
  }
Пример #5
0
 public void salir() {
   if (Greenfoot.mousePressed(this))
   /** Cuando se hace click en la imagen aparece una imagen con los Creditose */
   {
     Greenfoot.setWorld(new Creditos());
   }
 }
Пример #6
0
 /**
  * heredado de la clase abstracta Boton indica si el cursor est sobre el y manda una respuesta
  * visual
  *
  * @param w mundo actual
  */
 public void mouseSobreObjecto(World w) {
   if (Greenfoot.mouseMoved(this)) {
     setImage("ICO4.2.png");
   } else if (Greenfoot.mouseMoved(w)) {
     setImage("ICO4.png");
   }
 }
Пример #7
0
  private void movement() {

    int x = getX(), y = getY(), dir = getRotation();

    if (Greenfoot.isKeyDown("left") && x > 10) {

      setLocation(x - 7, y);
      setRotation(Math.max(dir - 2, 247));
      starsDir();

    } else if (Greenfoot.isKeyDown("right") && x < 794) {

      setLocation(x + 7, y);
      setRotation(Math.min(dir + 2, 293));
      starsDir();

    } else {

      setRotation((int) Math.round(-(dir - 270) / 1.8) + dir);
      starsDir();
    }

    x = getX();

    if (Greenfoot.isKeyDown("up") && y > 70) {
      setLocation(x, y - 7);

    } else if (Greenfoot.isKeyDown("down") && y < 660) {

      setLocation(x, y + 7);
    }
  }
Пример #8
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);
   }
 }
Пример #9
0
 public void Mover() {
   if (Greenfoot.isKeyDown("right")) {
     move(1);
   }
   if (Greenfoot.isKeyDown("left")) {
     move(-1);
   }
 }
Пример #10
0
  public void act() {

    // if (Greenfoot.isKeyDown("left"))
    if (Greenfoot.mouseClicked(null)) {

      Greenfoot.setWorld(new Q3());
    }
  }
Пример #11
0
 /** Checks for mouse movement and changes the background colour of the button accordingly */
 public void act() {
   Color buttonFill = new Color(242, 206, 27); // yellow fill colour
   if (Greenfoot.mouseMoved(this)) {
     update(Color.RED);
   }
   if (Greenfoot.mouseMoved(getWorld())) {
     update(buttonFill);
   }
 }
Пример #12
0
 public void fireMissle() {
   if (Greenfoot.getRandomNumber(1000) < 30) {
     getWorld()
         .addObject(
             new Missile(Greenfoot.getRandomNumber(1000), Greenfoot.getRandomNumber(150) + 390),
             getX(),
             getY());
   }
 }
Пример #13
0
  public void act() {
    int mouseX, mouseY;

    if (Greenfoot.mouseDragged(this)) {
      MouseInfo mouse = Greenfoot.getMouseInfo();
      mouseX = mouse.getX();
      mouseY = mouse.getY();
      setLocation(mouseX, mouseY);
    }
  }
Пример #14
0
  public void moveAndTurn() {
    move(3);

    if (Greenfoot.isKeyDown("a")) {
      turn(-5);
    }
    if (Greenfoot.isKeyDown("d")) {
      turn(5);
    }
  }
Пример #15
0
 /**
  * Method which allows for the Reset button on the Death Screen to be clicked. When the button is
  * clicked the game will restart with a new Flappy Bird.
  */
 public void act() {
   FlappyWorld startWorld =
       new FlappyWorld(); // This creates a new FlappyWorld object with a new FlappyBird and all
   // parts involved in FlappyWorld class.
   if (Greenfoot.mouseClicked(this)
       == true) { // This makes it so when the OK reset button is pressed the world will restart,
     // and be set to a new FlappyWorld.
     Greenfoot.setWorld(startWorld);
   }
 }
Пример #16
0
 public void createPlatforms(int n) {
   int random = Greenfoot.getRandomNumber(100);
   for (int i = 1; i <= n; i++) {
     if (random < 85)
       addObject(
           new SimplePlatform(),
           Greenfoot.getRandomNumber(WORLD_WIDTH),
           Greenfoot.getRandomNumber(40) - 20);
     else if (random < 90)
       addObject(
           new SpringPlatform(),
           Greenfoot.getRandomNumber(WORLD_WIDTH),
           Greenfoot.getRandomNumber(40) - 20);
     else if (random < 95)
       addObject(
           new BrittlePlatform(),
           Greenfoot.getRandomNumber(WORLD_WIDTH),
           Greenfoot.getRandomNumber(40) - 20);
     else
       addObject(
           new MovingPlatform(),
           Greenfoot.getRandomNumber(WORLD_WIDTH),
           Greenfoot.getRandomNumber(40) - 20);
   }
 }
Пример #17
0
 /** Do the action for this key. */
 public void act() {
   if (!isDown && Greenfoot.isKeyDown(key)) {
     setImage("white-key-down.png");
     isDown = true;
     play();
   }
   if (isDown && !Greenfoot.isKeyDown(key)) {
     setImage("white-key.png");
     isDown = false;
   }
 }
  /*
   * espera que se precione un boton, controla el juego; las barras objetos, dificultado y
   * el game over
   */
  public void act() {
    if (opcion == 0) {
      leeboton();
    }

    if (opcion == 1) {
      tiempo();
      agregaBarra();
      agregaObjetos();

      cambioDific();
      muestraColor.cambia(orbPj.getColAct());

      if (orbPj.getGameOver() == 1) {
        opcion = 2;
        sound.stop();
        record = tiempoActual;
        eliminaObjetos();
        setBackground("gameover.png");
        addObject(new Mensaje("ATRAS"), 710, 27);
        bot5 = new boton();
        addObject(bot5, 716, 31);

        addObject(new Mensaje("PUNTUACION"), 400, 458);
        total = new Counter();
        addObject(total, 401, 502);
        total.setValue(record);

        actualizaRecord();
      }

      // System.out.println(orbPj.getGameOver());
    }

    if (opcion == 2) {
      if (Greenfoot.mouseClicked(bot5)) {
        eliminaObjetos();
        opcion = 0;
        sound2.playLoop();
        menu();
      }
    }

    if (opcion == 3) {

      if (Greenfoot.mouseClicked(bot5)) {

        opcion = 2;
        // menu();

      }
    }
  }
  public void act() {
    // System.out.print("Score:" + score);
    setImage(new GreenfootImage("Health: 3, Score: " + score, 20, Color.GREEN, Color.BLACK));

    // creating next level

    if (score == level2) {
      setImage(new GreenfootImage("Level 2 Complete", 18, Color.YELLOW, Color.BLACK));
      Greenfoot.delay(200); // timer tampilan
      // getWorld().removeObject(this);
      Greenfoot.setWorld(new Level3()); // masuk ke Level3();
    }
  }
Пример #20
0
  private void equipment() {

    if (Greenfoot.isKeyDown("q") && amIntv > 20) {

      ammoChange(playerAmmunition.get(nextIndex(playerAmmunition, playerAmmo, -1)));
      amIntv = 0;

    } else if (Greenfoot.isKeyDown("e") && amIntv > 20) {

      ammoChange(playerAmmunition.get(nextIndex(playerAmmunition, playerAmmo, 1)));
      amIntv = 0;
    }

    amIntv++;
  }
Пример #21
0
  protected void animateMario() {
    SWorld sWorld = (SWorld) getWorld();
    mLeft = sWorld.minionL;
    if (mLeft == true && Greenfoot.isKeyDown("left")) {
      if (getImage() == imageL && imageDelayCount >= imageTime) {
        setImage(imageML);
        imageDelayCount = 0;
      }

      if (getImage() == imageML && imageDelayCount >= imageTime) {
        setImage(imageL);
        imageDelayCount = 0;
      }
      if (getImage() == imageR) {
        setImage(imageL);
        imageDelayCount = 0;
      }
      if (getImage() == imageMR) {
        setImage(imageL);
        imageDelayCount = 0;
      }
    }
    if (mLeft == true && Greenfoot.isKeyDown("left") == false) {
      setImage(imageL);
    }

    if (mLeft == false && Greenfoot.isKeyDown("right")) {
      if (getImage() == imageR && imageDelayCount >= imageTime) {
        setImage(imageMR);
        imageDelayCount = 0;
      }
      if (getImage() == imageMR && imageDelayCount >= imageTime) {
        setImage(imageR);
        imageDelayCount = 0;
      }
      if (getImage() == imageL) {
        setImage(imageR);
        imageDelayCount = 0;
      }
      if (getImage() == imageML) {
        setImage(imageR);
        imageDelayCount = 0;
      }
    }
    if (mLeft == false && Greenfoot.isKeyDown("right") == false) {
      setImage(imageR);
    }
  }
Пример #22
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));
   }
 }
Пример #23
0
 public Flame(boolean s, boolean o, boolean z) {
   initialiseImages();
   small = s;
   burnOil = o;
   burnZombie = z;
   lastImage = (60 - Greenfoot.getRandomNumber(10));
 }
Пример #24
0
  public void updateScoreForTankKill() {
    score.changeScore(+1);
    if (score.getScore() == 5) {
      for (int b = 0; b < 10; b++) {
        int x = 100;
        addObject(new Enemy(), x, y);
        y = y + 50;
      }
    } else if (score.getScore() == 15) {
      addObject(new Plane(), getWidth() / 8, getHeight() / 2);
    } else if (score.getScore() == 16) {
      for (int h = 0; h < 2; h++) {
        int x = Greenfoot.getRandomNumber(100);
        addObject(new Plane(), x, y);
        y = y + 300;
      }
    } else if (score.getScore() == 18) {
      addObject(new Plane(), getWidth() / 8, getHeight() / 2 - 100);
      addObject(new Plane(), getWidth() / 8, getHeight() / 2 + 200);
      for (int b = 0; b < 5; b++) {
        int x = 100;
        addObject(new Enemy(), x, y);
        y = y + 150;
      }
    } else if (score.getScore() == 25) {

    }
  }
Пример #25
0
 public void act() {
   Mover();
   darPosicao();
   if (Greenfoot.isKeyDown("space")) {
     Atirar();
   }
 }
Пример #26
0
  /**
   * entfernt die Mine und erzeugt 8 Splitter die in alle Richtungen fliegen soll später zusätzlich
   * sound abspielen und explosion darstellen
   */
  public void detonate() {
    int shrapnelnumber = 0;
    // erstellt 8 Splitter die nach der Detonation in alle Richtungen fliegen;
    while (shrapnelnumber != 8) {
      int shrapnelarc = shrapnelnumber * 45;

      Shrapnel name = new Shrapnel(shrapnelarc, shrapnelspeed);
      getWorld().addObject(name, this.getX(), this.getY());

      shrapnelnumber++;
    }
    this.setImage("explosion.gif");
    Greenfoot.playSound("explosion.wav");
    Greenfoot.delay(3);
    getWorld().removeObject(this);
  }
Пример #27
0
  private void Special() {

    if (Greenfoot.isKeyDown("r") && specialShotInt > 120 && Spammo > 0) {

      addObjectAtOffset(new ChargeBeam(this), getX(), getY(), 80, getRotation());
      w.addObject(new CoolDown(ACT2SEC(120)), 845, 640);
      Greenfoot.playSound("Laser_Cannon.mp3");
      // !--------------!\\
      specialShotInt = 0;
      shotInterval = -78;
      Spammo--;
      SpammoUI.addPoints(-1);
    }

    specialShotInt++;
  }
Пример #28
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;
   }
 }
Пример #30
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));
 }