Package org.newdawn.slick

Examples of org.newdawn.slick.Input


    // set turret position to parent
    x = parent.x + parent.width / 2;
    y = parent.y + parent.height / 2;

    // calculate heading of turret
    Input input = container.getInput();
    float mx = input.getMouseX();
    float my = input.getMouseY();
    // TODO Going to add the offset here! HACK
    // mx -= 20;
    // my -= 15;
    angle = (int) calculateAngle(x, y, mx, my);
View Full Code Here


    // render status image on top left of parent image
    g.drawImage(image, entity.x - 10, entity.y - 10);
  }

  public void update(GameContainer container, int delta) {
    Input input = container.getInput();
    if (input.isKeyPressed(Input.KEY_SPACE)) {
      entity.stateManager.enter(IdleState.class);
    }
  }
View Full Code Here

    g.drawImage(image, entity.x - 10, entity.y - 10);
  }

  public void update(GameContainer container, int delta) {
    // move entity
    Input input = container.getInput();
    if (input.isKeyDown(Input.KEY_W)) {
      entity.y -= entity.speed.y;
    } else if (input.isKeyDown(Input.KEY_S)) {
      entity.y += entity.speed.y;
    } else if (input.isKeyDown(Input.KEY_D)) {
      entity.x += entity.speed.x;
    } else if (input.isKeyDown(Input.KEY_A)) {
      entity.x -= entity.speed.x;
    }
    if (input.isKeyPressed(Input.KEY_SPACE)) {
      entity.stateManager.enter(CombatState.class);
    }
  }
View Full Code Here

    g.drawImage(image, entity.x - 10, entity.y - 10);
  }

  public void update(GameContainer container, int delta) {
    // do nothing untile player try to move
    Input input = container.getInput();
    if (input.isKeyPressed(Input.KEY_SPACE)) {
      entity.stateManager.enter(MovingState.class);
    }
  }
View Full Code Here

  }

  @Override
  public void update(GameContainer container, int delta)
      throws SlickException {
    Input input = container.getInput();

    if(input.isKeyDown(Input.KEY_A)){
      planeX -= 3;
    }
    if(input.isKeyDown(Input.KEY_D)){
      planeX += 3;
    }
    if(input.isKeyDown(Input.KEY_W)){
      planeY -= 3;
    }
    if(input.isKeyDown(Input.KEY_S)){
      planeY += 3;
    }
  }
View Full Code Here

    public void render(GameContainer container, Graphics g) {
        g.draw(shape);
    }

    public void update(GameContainer container, int delta) {
        Input in = container.getInput();
        float mx = in.getMouseX();
        float my = in.getMouseY();
        if (!contains(mx, my)) {
            testForExit();
            return;
        }
View Full Code Here

    @Override
    public void update(GameContainer gc, int delta)
    throws SlickException
    {
        // Get data about the current input (keyboard state).
        Input input = gc.getInput();

        // Update the player's movement direction based on keyboard presses.
        double dir_x = 0;
        double dir_y = 0;
        if (input.isKeyDown(Input.KEY_DOWN))
            dir_y += 1;
        if (input.isKeyDown(Input.KEY_UP))
            dir_y -= 1;
        if (input.isKeyDown(Input.KEY_LEFT))
            dir_x -= 1;
        if (input.isKeyDown(Input.KEY_RIGHT))
            dir_x += 1;
        // Fire a missile based on keyboard presses
        if (input.isKeyDown(Input.KEY_SPACE))
          world.addMissile(delta);

        // Let World.update decide what to do with this data.
        world.update(dir_x, dir_y, delta);
    }
View Full Code Here

            ThemeManager theme = loadTheme(renderer);

            gui = new GUI(emptyRootWidget, renderer, null);
            gui.applyTheme(theme);

            Input input = getContainer().getInput();
            TWLInputForwarder inputForwarder = new TWLInputForwarder(gui, input);
            input.addPrimaryListener(inputForwarder);
        } catch (Throwable e) {
            throw new SlickException("Could not initialize TWL GUI", e);
        } finally {
            GL11.glPopAttrib();
        }
View Full Code Here

  public void update(GameContainer gc, StateBasedGame game,
      int timeSinceLastUpdate) throws SlickException {
    // Remove unused components
    safeRemove();

    final Input input = gc.getInput();
    // mx = input.getMouseX();
    // my = input.getMouseY();
    updateState(input, timeSinceLastUpdate);

    gameMenuWindow.update(input);
View Full Code Here

    if (!started || musicManager.getPlayingMusic() == null) {
      started = true;
      musicManager.playMusic(bgMusic);
    }

    Input input = container.getInput();
    for (TextButton tb : buttons) {
      tb.update(input);
    }
  }
View Full Code Here

TOP

Related Classes of org.newdawn.slick.Input

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.