Package org.newdawn.slick

Examples of org.newdawn.slick.Input$NullOutputStream


      util_state_paused_iter++;
      if (util_state_paused_iter == util_state_paused_iter_max)
        util_state_paused_iter = 0;
    }
   
    Input input = Game.app.getInput();
    if ((input.isKeyDown(Input.KEY_ESCAPE) || input.isKeyDown(Input.KEY_P)) && util_state_paused_iter == 0 && !GameplayState.scene_handler.is_playing)
    {
      state = 0;
      util_state_paused = !util_state_paused;
      util_state_paused_iter++;
      input.clearKeyPressedRecord();
    }
  }
View Full Code Here


    }
    if (knife)
      knifeUpdate();
    if (GameplayState.monster_controller.getState() == WS.BREAK)
    {
      Input inp = Game.app.getInput();
      if ((inp.isKeyPressed(Input.KEY_DOWN) || inp.isKeyPressed(Input.KEY_S)) && GameplayState.player.pl_center.getX() > 590 &&  GameplayState.player.pl_center.getX() < 640)
        GameplayState.scene_handler.activateScene(SCENE.SHOP);
    }
  }
View Full Code Here

  }

  @Override
  public void update(int delta) {
    super.update(delta);
    Input p = screen.getInput();
    int mx = p.getMouseX();
    int my = p.getMouseY();
    if (mx >= 780) {
      v.move(5, 0);
    }
    if (mx < 10) {
      v.move(-5, 0);
View Full Code Here

  }

  @Override
  public void update(int delta) {
    super.update(delta);
    Input p = screen.getInput();
    int mx = p.getMouseX();
    int my = p.getMouseY();
    if (mx >= 780) {
      v.move(5, 0);
    }
    if (mx < 10) {
      v.move(-5, 0);
View Full Code Here

    mouseDownImage = image;

    currentColor = normalColor;

    state = NORMAL;
    Input input = container.getInput();
    over = area.contains(input.getMouseX(), input.getMouseY());
    mouseDown = input.isMouseButtonDown(0);
    updateImage();
  }
View Full Code Here

      if (motionHandler.isEnded())
        motionHandler = null;
    }
   
    Input input = gc.getInput();
   
    if (input.isMousePressed(0)) {
      int mouseX = input.getMouseX();
      int mouseY = input.getMouseY();
     
      motionHandler = new PlayerMotionHandler(1, playerAvatar.getAvatar(), new Vector2f(mouseX, mouseY), 0);
      motionHandler.isActivating(playerAvatar.getPosition(), delta);
    }
  }
View Full Code Here

      g.setColor(Color.white);
      g.drawString("Play Game", (gc.getWidth()/2)-30, gc.getHeight()/2);
    }
 
    public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
      Input input = gc.getInput();
      int mousex = input.getMouseX();
        int mousey = input.getMouseY();
        if(mousex > (gc.getWidth()/2)-38 && mousex < ((gc.getWidth()/2)-38) + 100 &&
            mousey > gc.getHeight()/2 && mousey < (gc.getHeight()/2) + 20){
        if ( input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) ){
          sbg.enterState(BlockBreaker.GAMEPLAYSTATE);
        }
        }
    }
View Full Code Here

      }
    }
   
    for (int i = 0; i < Constants.UPDATES; i++) {

      Input input = gc.getInput();
     
      if (input.isKeyPressed(Input.KEY_C)) {
        worldCenterX = gc.getWidth()/2 - (currentBeaverBody.getX()*scale);
        worldCenterY = gc.getHeight()/2 - (currentBeaverBody.getY()*-scale);
      }
     
      if (input.isKeyDown(Input.KEY_Z)) { 
        if (scale > 0.001f) {
          scale = scale - 0.001f;
          worldCenterX = gc.getWidth()/2 - (currentBeaverBody.getX()*scale);
          worldCenterY = gc.getHeight()/2 - (currentBeaverBody.getY()*-scale);
        }
      }
     
      if (input.isKeyDown(Input.KEY_X)) {
        scale = scale + 0.001f;
        worldCenterX = gc.getWidth()/2 - (currentBeaverBody.getX()*scale);
        worldCenterY = gc.getHeight()/2 - (currentBeaverBody.getY()*-scale);
      }
     
      if (input.isKeyDown(Input.KEY_W)) {
        worldCenterY += 0.2f;// /updates;
      }
     
      if (input.isKeyDown(Input.KEY_S)) {
        worldCenterY -= 0.2f;// /updates;
      }
     
      if(input.isKeyPressed(Input.KEY_R)){
        System.out.println(crosshairAngle);
        crosshairAngle = 45;
      }

      if(input.isKeyPressed(Input.KEY_Q)){
        currentPlayer.getCurrentBeaver().cycleWeapon();
      }

      if (input.isKeyDown(Input.KEY_A)) {
        worldCenterX += 0.2f;// /updates;
      }
     
      if (input.isKeyPressed(Input.KEY_O)) {
        endTurn(gc);
      }
     
      if (input.isKeyDown(Input.KEY_D)) {
        worldCenterX -= 0.2f;// /updates;
      }
     
      if (input.isKeyDown(Input.KEY_RIGHT)) {
        if(endTurn>0){
          continue;
        }

        if (crosshairAngle > 180) crosshairAngle = 180-(crosshairAngle-180);
        team1MovingR.update(delta*100);
        team2MovingR.update(delta*100);
        currentPlayer.getCurrentBeaver().setFacingR(true);
        if (currentBeaverBody.getAngularVelocity() > -1.5)
          currentBeaverBody.setAngularVelocity(currentBeaverBody
              .getAngularVelocity() - 0.05f);
        currentBeaverBody.setAngularVelocity(-1.5f);
      }
     
      if (input.isKeyDown(Input.KEY_LEFT)) {
        if(endTurn>0){
          continue;
        }
        if (crosshairAngle < 180) crosshairAngle = 180+(180-crosshairAngle);
        team1Moving.update(delta*100);
        team2Moving.update(delta*100);
        currentPlayer.getCurrentBeaver().setFacingR(false);
        if (currentBeaverBody.getAngularVelocity() < 1.5)
          currentBeaverBody.setAngularVelocity(currentBeaverBody.getAngularVelocity() + 0.05f);
        currentBeaverBody.setAngularVelocity(1.5f);
      }
     
      if (input.isKeyDown(Input.KEY_UP)){
        if(endTurn>0){
          continue;
        }
        if (crosshairAngle < 180 && crosshairAngle > 0) crosshairAngle -= 0.1f;
        else if (crosshairAngle > 180 && crosshairAngle < 360) crosshairAngle += 0.1f;
      }
     
      if (input.isKeyDown(Input.KEY_DOWN)){
        if(endTurn>0){
          continue;
        }
        if (crosshairAngle < 180 && crosshairAngle > 0) crosshairAngle += 0.1f;
        else if (crosshairAngle > 180 && crosshairAngle < 360) crosshairAngle -= 0.1f;
      }
     
      if (input.isKeyPressed(Input.KEY_ENTER)) {
        if(endTurn>0){
          continue;
        }
        if(currentPlayer.getCurrentBeaver().getCurrentWeapon().getAmmo()>0){
          currentPlayer.getCurrentBeaver().useWeapon();
          if (!powerSeqEngaged) {
            power = 1;
            powerSeqEngaged = true;
          }
          else {
            powerSeqEngaged = false;
            currentBeaverBody.setActive(false);
            bullet = new DynamicBody(new Circle(5),currentBeaverBody.getX(),currentBeaverBody.getY());
            bullet.setBullet(true);
            bullet.setRestitution(0);
            float x = (float) (Math.sin(Math.toRadians(crosshairAngle)));
            float y = (float) (Math.cos(Math.toRadians(crosshairAngle)));
            float xForce = (power/50)*(x)*10000000f;
            float yForce = (power/50)*(y)*10000000f;
            //System.out.println("x is "+x+", y is "+y+", angle at"+crosshairAngle);
            world.add(bullet);
            world.addBodyListener(bullet, this);
            bullet.applyForce(xForce, yForce);
            //Shot is fired, turn is over
            cameraOnBullet = true;
          }
        }

      }
     
      if (input.isKeyPressed(Input.KEY_SPACE)) {
        if (currentBeaverBody.getYVelocity() < 0.7 && currentBeaver.getFacingR()) {
          currentBeaverBody.applyForce(0, 1500000f);// /updates);
        }
        if (currentBeaverBody.getYVelocity() > -0.7 && !currentBeaver.getFacingR()) {
          currentBeaverBody.applyForce(0, 1500000f);// /updates);
        }
      }
     
      if (input.isKeyPressed(Input.KEY_ESCAPE)){
        sbg.enterState(BeaversGame.MAINMENUSTATE);
      }
     
      if (drawCircle) {
        addExplosionToTerrain((int) collisionX, (int) collisionY, this.radius);
View Full Code Here

    }

    for (int i = 0; i < Constants.UPDATES; i++) {
      boolean keypress = false;

      Input input = gc.getInput();
      if(currentPlayer == p1){
        if (input.isKeyPressed(Input.KEY_C)) {
          worldCenterX = gc.getWidth()/2 - (currentBeaverBody.getX()*scale);
          worldCenterY = gc.getHeight()/2 - (currentBeaverBody.getY()*-scale);
         
        }

        if (input.isKeyDown(Input.KEY_Z)) { 
          if (scale > 0.001f) scale = scale - 0.001f;// /updates;
        }

        if (input.isKeyDown(Input.KEY_X)) {
          scale = scale + 0.001f;// /updates;
        }

        if (input.isKeyDown(Input.KEY_W)) {
          worldCenterY -= 0.1f;// /updates;
        }

        if (input.isKeyDown(Input.KEY_S)) {
          worldCenterY += 0.1f;// /updates;
        }

        if(input.isKeyPressed(Input.KEY_R)){
          p1Moves.add("r");
          System.out.println(crosshairAngle);
          crosshairAngle = 45;
          keypress = true;
        }

        if(input.isKeyPressed(Input.KEY_Q)){
          p1Moves.add("q");
          currentPlayer.getCurrentBeaver().cycleWeapon();
          keypress = true;
         
        }

        if (input.isKeyDown(Input.KEY_A)) {
          worldCenterX -= 0.1f;// /updates;
         
        }

        if (input.isKeyPressed(Input.KEY_O)) {
          p1Moves.add("o");
          keypress = true;
          endTurn(gc);
        }

        if (input.isKeyDown(Input.KEY_D)) {
          worldCenterX += 0.1f;// /updates;
        }

        if (input.isKeyDown(Input.KEY_RIGHT)) {
          p1Moves.add("right");
          if(endTurn>0){
            continue;
          }

          if (crosshairAngle > 180) crosshairAngle = 180-(crosshairAngle-180);
          team1MovingR.update(delta*100);
          team2MovingR.update(delta*100);
          currentPlayer.getCurrentBeaver().setFacingR(true);
          if (currentBeaverBody.getAngularVelocity() > -1.5)
            currentBeaverBody.setAngularVelocity(currentBeaverBody
                .getAngularVelocity() - 0.05f);
          currentBeaverBody.setAngularVelocity(-1.5f);
          keypress=true;
        }

        if (input.isKeyDown(Input.KEY_LEFT)) {
          p1Moves.add("left");
          if(endTurn>0){
            continue;
          }
          if (crosshairAngle < 180) crosshairAngle = 180+(180-crosshairAngle);
          team1Moving.update(delta*100);
          team2Moving.update(delta*100);
          currentPlayer.getCurrentBeaver().setFacingR(false);
          if (currentBeaverBody.getAngularVelocity() < 1.5)
            currentBeaverBody.setAngularVelocity(currentBeaverBody.getAngularVelocity() + 0.05f);
          currentBeaverBody.setAngularVelocity(1.5f);
          keypress = true;
        }

        if (input.isKeyDown(Input.KEY_UP)){
          p1Moves.add("up");
          if(endTurn>0){
            continue;
          }
          if (crosshairAngle < 180 && crosshairAngle > 0) crosshairAngle -= 0.1f;
          else if (crosshairAngle > 180 && crosshairAngle < 360) crosshairAngle += 0.1f;
          keypress = true;
        }

        if (input.isKeyDown(Input.KEY_DOWN)){
          p1Moves.add("down");
          if(endTurn>0){
            continue;
          }
          if (crosshairAngle < 180 && crosshairAngle > 0) crosshairAngle += 0.1f;
          else if (crosshairAngle > 180 && crosshairAngle < 360) crosshairAngle -= 0.1f;
          keypress = true;
        }

        if (input.isKeyPressed(Input.KEY_ENTER)) {
          p1Moves.add("enter");
          if(endTurn>0){
            continue;
          }
          if(currentPlayer.getCurrentBeaver().getCurrentWeapon().getAmmo()>0){
            currentPlayer.getCurrentBeaver().useWeapon();
            if (!powerSeqEngaged) {
              power = 1;
              powerSeqEngaged = true;
            }
            else {
              powerSeqEngaged = false;
              currentBeaverBody.setActive(false);
              bullet = new DynamicBody(new Circle(5),currentBeaverBody.getX(),currentBeaverBody.getY());
              bullet.setBullet(true);
              bullet.setRestitution(0);
              float x = (float) (Math.sin(Math.toRadians(crosshairAngle)));
              float y = (float) (Math.cos(Math.toRadians(crosshairAngle)));
              float xForce = (power/50)*(x)*10000000f;
              float yForce = (power/50)*(y)*10000000f;
              //System.out.println("x is "+x+", y is "+y+", angle at"+crosshairAngle);
              world.add(bullet);
              world.addBodyListener(bullet, this);
              bullet.applyForce(xForce, yForce);
              //Shot is fired, turn is over
              cameraOnBullet = true;
            }
          }
          keypress = true;
        }

        if (input.isKeyPressed(Input.KEY_SPACE)) {
          p1Moves.add("space");
          if (currentBeaverBody.getYVelocity() < 0.7 && currentBeaver.getFacingR()) {
            currentBeaverBody.applyForce(0, 1500000f);// /updates);
          }
          if (currentBeaverBody.getYVelocity() > -0.7 && !currentBeaver.getFacingR()) {
            currentBeaverBody.applyForce(0, 1500000f);// /updates);
          }
          keypress = true;
        }

        if (input.isKeyPressed(Input.KEY_ESCAPE)){
          sbg.enterState(BeaversGame.MAINMENUSTATE);
        }
       
        if(!keypress){
          p1Moves.add(" ");
View Full Code Here

     options.draw(optionsX, menuTopAlign + spacing, optionsScale);
     exit.draw(exitX, menuTopAlign + (2*spacing), exitScale);
  }
 
  public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
    Input input = gc.getInput();
   
    int mouseX = input.getMouseX();
    int mouseY = input.getMouseY();
   
    boolean insideStart = false;
    boolean insideOptions = false;
    boolean insideExit = false;
   
    /* Handle case where the user hovers over the "Start Game" button */
    if( (mouseX >= startX && mouseX <= startX + startWidth) &&
      (mouseY >= menuTopAlign && mouseY <= menuTopAlign + startHeight) )
        insideStart = true;
   
    if(insideStart) {
      // scale up by 5%
      if(startScale < 1.05f)
        startScale += scaleStep * delta;
      // make button clickable
      if ( input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) ){
          sbg.enterState(BeaversGame.GAMEPLAYSTATE);
        }
    }
    else {
      // once we move out of the "Start Game" box, scale back down to original size
      if(startScale > 1.0f)
        startScale -= scaleStep * delta;
    }
   
    /* Handle case where the user hovers over the "Options" button */
    if( (mouseX >= optionsX && mouseX <= optionsX + optionsWidth) &&
        (mouseY >= menuTopAlign+spacing && mouseY <= menuTopAlign+spacing + optionsHeight) )
      insideOptions = true;

    if(insideOptions) {
      // scale up by 5%
      if(optionsScale < 1.05f)
        optionsScale += scaleStep * delta;
      if ( input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) ){
        //If we click on "Network", then popup a "Is Host?" dialog
        int isHost = JOptionPane.showConfirmDialog(null,
            "Will you be hosting this game?",
            "Choose one", JOptionPane.YES_NO_OPTION);
        System.out.println(isHost);
        boolean host = false;
        if (isHost == 0) host = true;
        System.out.println(host);
        String ip = "localhost";
       
        if(!host){
          //Not host, no need for server
          ip = (String)JOptionPane.showInputDialog(
              "Enter IP address");
        }
        else{
          // Start server
          Runnable serv = new Runnable(){
            public void run(){
              GameServer s = new GameServer();
              s.run();
            }
          };
         
          new Thread(serv).start();
         
          // Sleep current thread for a while, while server boots up
          try {
            Thread.sleep(5000);
          }
          catch (InterruptedException ie) {}
         
          /*Thread t = new Thread(){
            public void run(){
              GameServer s = new GameServer();
              s.run();
            }
          };*/
          //t.start();
        }
       
        try{
          sbg.addState(new ClientState(BeaversGame.CLIENTSTATE,ip));
          sbg.getState(BeaversGame.CLIENTSTATE).init(gc, sbg);
          sbg.enterState(BeaversGame.CLIENTSTATE);
        }catch(Exception e){
          JOptionPane.showMessageDialog(null,"An Error occured while establishing a connection");
          sbg.enterState(BeaversGame.MAINMENUSTATE);
        }
        }
    }
    else {
      // once we move out of the "Options" box, scale back down to original size
      if(optionsScale > 1.0f)
        optionsScale -= scaleStep * delta;
    }
   
    /* Handle case where the user hovers over the "Exit" button */
    if( (mouseX >= exitX && mouseX <= exitX + exitWidth) &&
        (mouseY >= menuTopAlign+2*spacing && mouseY <= menuTopAlign+2*spacing + exitHeight) )
      insideExit = true;

    if(insideExit) {
      // scale up by 5%
      if(exitScale < 1.05f)
        exitScale += scaleStep * delta;
      // make button clickable
      if ( input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) ){
          gc.exit();
        }
    }
    else {
      // once we move out of the "Options" box, scale back down to original size
View Full Code Here

TOP

Related Classes of org.newdawn.slick.Input$NullOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.