Ejemplo n.º 1
0
  void inputListener() {
    if (keyboard.keyDown(KeyEvent.VK_W)) player.moveDir[1] = -1;
    else if (keyboard.keyDown(KeyEvent.VK_S)) player.moveDir[1] = 1;
    else player.moveDir[1] = 0;

    if (keyboard.keyDown(KeyEvent.VK_A)) player.moveDir[0] = -1;
    else if (keyboard.keyDown(KeyEvent.VK_D)) player.moveDir[0] = 1;
    else player.moveDir[0] = 0;

    if (keyboard.keyDown(KeyEvent.VK_1)) player.SetWeapon(1);
    if (keyboard.keyDown(KeyEvent.VK_2)) player.SetWeapon(2);
    if (keyboard.keyDown(KeyEvent.VK_3)) player.SetWeapon(3);
    if (keyboard.keyDown(KeyEvent.VK_4)) player.SetWeapon(4);
    if (keyboard.keyDown(KeyEvent.VK_5)) player.SetWeapon(5);
    if (keyboard.keyDown(KeyEvent.VK_6)) player.SetWeapon(6);
    if (keyboard.keyDown(KeyEvent.VK_7)) player.SetWeapon(7);
    if (keyboard.keyDown(KeyEvent.VK_8)) player.SetWeapon(8);
    if (keyboard.keyDown(KeyEvent.VK_9)) player.SetWeapon(9);

    if (keyboard.keyDownOnce(KeyEvent.VK_Z)) {
      if (showDebug) showDebug = false;
      else showDebug = true;
    }
    if (keyboard.keyDownOnce(KeyEvent.VK_F9)) {
      cheated = true;
      player.health = 1000000;
    }
    if (keyboard.keyDownOnce(KeyEvent.VK_F10)) {
      cheated = true;
      player.unlockWeapon(2, true);
      player.unlockWeapon(3, true);
      player.unlockWeapon(4, true);
    }
    if (keyboard.keyDownOnce(KeyEvent.VK_F11)) {
      cheated = true;
      player.upgradeWeapon(1, 1);
      player.upgradeWeapon(2, 1);
      player.upgradeWeapon(3, 1);
      player.upgradeWeapon(4, 1);
    }
    if (keyboard.keyDown(KeyEvent.VK_F12)) {
      cheated = true;
      player.score = (int) (player.score + 1 / delta);
    }

    if (keyboard.keyDownOnce(KeyEvent.VK_MINUS)) if (difficulty < 19) difficulty = difficulty + 1;
    if (keyboard.keyDownOnce(KeyEvent.VK_BACK_SLASH))
      if (difficulty > 1) difficulty = difficulty - 1;
    if (keyboard.keyDownOnce(KeyEvent.VK_ESCAPE)) paused = true;
    if (keyboard.keyDownOnce(KeyEvent.VK_M))
      if (removeMode) removeMode = false;
      else removeMode = true;

    if (mouse.buttonDown(1))
      player.Shoot(mouse.getPosition().getX() - xOffset, mouse.getPosition().getY() - yOffset);
  }
Ejemplo n.º 2
0
 void renderUI(Graphics2D g2d) {
   g2d.setFont(new Font("Courier New", Font.PLAIN, 12));
   g2d.setColor(Color.white);
   if (removeMode) g2d.setColor(Color.black);
   if (player.health < 0) player.health = 0;
   g2d.drawString(String.format("Helath: %s", player.health), 10, 20);
   g2d.drawString(String.format("Kills: %s", player.score), 10, 40);
   int WLevel = (Integer) player.weapon[player.currentWeapon][10];
   if (WLevel == 5)
     g2d.drawString(String.format("Current Weapon: %s:Max", player.currentWeapon), 10, 60);
   else
     g2d.drawString(String.format("Current Weapon: %s:%s", player.currentWeapon, WLevel), 10, 60);
   g2d.setColor(Color.gray);
   g2d.drawString(String.format("Level: %s", difficulty), 10, 80);
   g2d.setColor(Color.black);
   if (showDebug) g2d.drawString(String.format("FPS: %s", fps), 10, 100);
   if (cheated) g2d.drawString("You cheated, no highscore will be saved", 200, height - 15);
 }