/*
   * 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();

      }
    }
  }
示例#2
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);
   }
 }
示例#3
0
  public void act() {

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

      Greenfoot.setWorld(new Q3());
    }
  }
 public void activate() {
   if (Greenfoot.mouseClicked(this)) {
     Player.resetHealth();
     space.setPause = false;
     Player.respawnIsPressed = true;
     Player.justDied = true;
     getWorld().removeObjects(getWorld().getObjects(RespawnMenu.class));
   }
 }
示例#5
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);
   }
 }
  /*
   * lee el boton que se selecciona en el menu
   */
  public void leeboton() {
    if (!sound2.isPlaying()) {
      sound2.playLoop();
    }
    if (Greenfoot.mouseClicked(bot1)) {
      opcion = 1;
      eliminaObjetos();
      setBackground("fondo2.png");
      creanivel();
    }

    if (Greenfoot.mouseClicked(bot2)) {
      opcion = 2;
      eliminaObjetos();
      setBackground("ayuda.png");
      addObject(new Mensaje("ATRAS"), 710, 27);
      bot5 = new boton();
      addObject(bot5, 716, 31);
    }

    if (Greenfoot.mouseClicked(bot3)) {
      opcion = 2;
      eliminaObjetos();
      setBackground("creditos.png");
      addObject(new Mensaje("ATRAS"), 710, 27);
      bot5 = new boton();
      addObject(bot5, 716, 31);
    }

    if (Greenfoot.mouseClicked(bot4)) {
      opcion = 2;
      eliminaObjetos();
      setBackground("record.png");
      addObject(new Mensaje("ATRAS"), 710, 27);
      bot5 = new boton();
      addObject(bot5, 716, 31);
      records();

      // addObject(new Mensaje(user1.getUserName()),151,124);

    }
  }
 /**
  * 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;
   }
 }
示例#8
0
  public void act() {
    if (Greenfoot.mouseClicked(this)) {
      soundOn = !soundOn;
      ((Screen) getWorld()).soundSet(soundOn);

      if (soundOn) setImage(new GreenfootImage("SoundOn.png"));
      else setImage(new GreenfootImage("SoundOff.png"));
    }

    if (fade) {
      if (getImage().getTransparency() - 10 <= 0) {
        getWorld().removeObject(this);
      } else {
        getImage().setTransparency(getImage().getTransparency() - 10);
      }
    }
  }
示例#9
0
  /**
   * Act - do whatever the Sound wants to do. This method is called whenever the 'Act' or 'Run'
   * button gets pressed in the environment.
   */
  public void act() {
    if (Greenfoot.mouseClicked(this)) {
      if (isPlaying) {
        Haven haven = (Haven) getWorld();
        haven.backgroundSound.stop();
        haven.vrachtwagen.containerSound.setVolume(0);
        setPlaying(false);
        this.setImage("mute.png");

      } else {
        Haven haven = (Haven) getWorld();
        haven.vrachtwagen.containerSound.setVolume(20);
        haven.backgroundSound.play();
        setPlaying(true);
        this.setImage("play.png");
      }
    }
  }
示例#10
0
 public void click() {
   if (Greenfoot.mouseClicked(this)) {
     getClickSound().play(); // quando é carregado neste botão é produzido um som de click
     getWorld()
         .addObject(
             help,
             getWorld().getWidth() / 2,
             getWorld().getHeight()
                 / 2); // adicionamos num objeto da Classe help, este objeto tem a função de ser um
                       // popup que poderá ser fechado pelo utilizador
     getWorld()
         .addObject(
             new Exit(help),
             help.getX() - help.getImage().getWidth() / 2,
             help.getY()
                 - help.getImage().getHeight()
                     / 2); // botão que fecha o popup, adiciona um objeto da classe Exit que recebe
                           // como o objeto o Actor que quer remover, neste caso o objeto
                           // adicionado acima deste
   }
 }
示例#11
0
  /**
   * Act - do whatever the Answer 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.

    if (Greenfoot.mouseClicked(this)) {
      if (isCorrect) {
        getWorld().addObject(cm, 325, 100);
        // Easy.moveKayakEasy();
        // getWorld().moveKayakEasy();
        // getWorld(Easy).moveKayakEasy();
        Medium med = (Medium) getWorld();
        med.moveKayakMedium();
        // Each of these three give a different error message and I have no
        // idea how to fix it.
      } else {
        getWorld().addObject(m, 325, 100);
      }
      // This could also be put in the message method, after the message is displayed
      // and disappears. Which makes more sense?
      ((Medium) getWorld()).loadQMedium(); // curLine maintained in Blackboard
    }
  }
示例#12
0
  public void animalEffect(String soundEffect) {

    if (Greenfoot.mouseClicked(this)) {
      Greenfoot.playSound(soundEffect);
    }
  }
示例#13
0
 public void act() {
   if (Greenfoot.mouseClicked(this)) ban = 1;
   else ban = 0;
 }
示例#14
0
 /** click on this button to start the game */
 public void click() {
   newButtonCommand.executeCommand();
   if (Greenfoot.mouseClicked(this)) {
     clickSound.play();
   }
 }
示例#15
0
文件: Mouse.java 项目: Sheeo/dIntProg
  /**
   * Update the lastState property. Should ideally be called on each World.act(), or at least before
   * getState() in a frame where mouse info is wanted.
   */
  public void act() {
    MouseInfo mouseinfo = Greenfoot.getMouseInfo();

    /* To-be properties of MouseState */
    boolean held = lastState.held;
    boolean down = false;
    boolean up = false;
    boolean moved;
    Vector position;

    if (mouseinfo != null) {
      /* Get the new mouse position */
      position = new Vector(mouseinfo.getX(), mouseinfo.getY());
      /* We have moved if there is a difference between this mouse position and
       * the previous mouse position. */
      moved = lastState.position == null || position.subtract(lastState.position).length() > 0.5;

    } else {
      /* mouseinfo == null */

      /* Use the previous mouse position */
      position = lastState.position;
      /* We haven't moved the mouse pointer. */
      moved = false;
    }

    if (lastState.held) {
      /* Figure out if the mouse has been released. This has to be done
       * differently on Mac OS X, as MouseInfo contains different info in case
       * of mouse release on that platform. */
      if (System.getProperty("os.name").equals("Mac OS X")) {
        if (Greenfoot.mouseClicked(null)
            || mouseinfo != null
                && (mouseinfo.getActor() != concerning || mouseinfo.getButton() != 1)) {
          up = true;
          held = false;
        }
      } else {
        /* TODO: Check if this behaves correctly in Windows */
        if (Greenfoot.mouseClicked(concerning)
            || mouseinfo != null
                && (mouseinfo.getActor() != concerning || mouseinfo.getButton() != 0)) {
          up = true;
          held = false;
        }
      }

    } else {
      /* !lastState.held */

      /* Figure out if mouse has been pressed. This is thankfully
       * cross-platform consistent. */
      if (Greenfoot.mousePressed(concerning)) {
        down = true;
        held = true;
      }
    }

    /* Store the state in the lastState property. */
    lastState = new MouseState(held, down, up, moved, position);
  }