Exemple #1
0
 public void keyReleased(KeyEvent e) {
   // #if (mov_0)
   int key = e.getKeyCode();
   if (key == KeyEvent.VK_LEFT) {
     current_Player.setLeft(false);
   }
   if (key == KeyEvent.VK_RIGHT) {
     current_Player.setRight(false);
   }
   if (key == KeyEvent.VK_DOWN) current_Player.setDown(false);
   if (key == KeyEvent.VK_UP) current_Player.setUp(false);
   if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(2);
   // #endif
   // #if (mov_1)
   // @            int key = e.getKeyCode();
   // @            if (key == KeyEvent.VK_SPACE && current_Player.getLoad()==1)
   // current_Player.setLoad(2);
   // @            if (key == KeyEvent.VK_LEFT) current_Player.setLeft(false);
   // @            if (key == KeyEvent.VK_RIGHT) current_Player.setRight(false);
   // @            if (key == KeyEvent.VK_DOWN) current_Player.setDown(false);
   // @            if (key == KeyEvent.VK_UP) current_Player.setUp(false);
   // @            if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(2);
   // #endif
   // #if (mov_2)
   // @            int key = e.getKeyCode();
   // @            if (key == KeyEvent.VK_LEFT) current_Player.setLeft(false);
   // @            if (key == KeyEvent.VK_RIGHT) current_Player.setRight(false);
   // @            if (key == KeyEvent.VK_DOWN) current_Player.setDown(false);
   // @            if (key == KeyEvent.VK_UP) current_Player.setUp(false);
   // @            if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(2);
   // #endif
   // #if (mov_3)
   // @            int key = e.getKeyCode();
   // @            if (key == KeyEvent.VK_SPACE &&
   // current_Player.getLoad()==1){current_Player.setLoad(2);}
   // @            if (key == KeyEvent.VK_LEFT) current_Player.setLeft(false);
   // @            if (key == KeyEvent.VK_RIGHT) current_Player.setRight(false);
   // @            if (key == KeyEvent.VK_DOWN) current_Player.setDown(false);
   // @            if (key == KeyEvent.VK_UP) current_Player.setUp(false);
   // @            if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(2);
   // #endif
   // #if (mov_4)
   // @            int key = e.getKeyCode();
   // @            if (key == KeyEvent.VK_SPACE && current_Player.getLoad()==1)
   // current_Player.setLoad(2);
   // @            if (key == KeyEvent.VK_LEFT) current_Player.setLeft(false);
   // @            if (key == KeyEvent.VK_RIGHT) current_Player.setRight(false);
   // @            if (key == KeyEvent.VK_DOWN) current_Player.setDown(false);
   // @            if (key == KeyEvent.VK_UP) current_Player.setUp(false);
   // @            if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(2);
   // #endif
 }
 // takes keyboard input to move player around, and to different rooms
 public void keyTyped(KeyEvent e) {
   c = e.getKeyChar();
   repaint();
   g = this.getGraphics();
   Environment Layout = new Environment();
   if (Layout.isWall(x, y, c, wallLayout)) {
   } else {
     if (c == 'a') {
       x = x - 3;
     } else if (c == 'w') {
       y = y - 3;
     } else if (c == 's') {
       y = y + 3;
     } else if (c == 'd') {
       x = x + 3;
     } else if (c == 'e') {
       getItem = !getItem;
     }
     int yDoor = Layout.isDoor(x, y, c, 'y', wallLayout);
     int xDoor = Layout.isDoor(x, y, c, 'x', wallLayout);
     if (xDoor != 0 || yDoor != 0) {
       mapY = mapY + yDoor;
       mapX = mapX + xDoor;
       wallLayout = Layout.walls(mapX, mapY);
       Layout.drawRoom(mapX, mapY, g);
       if (xDoor == -1) {
         x = 760;
       } else if (xDoor == 1) {
         x = 40;
       } else if (yDoor == -1) {
         y = 460;
       } else if (yDoor == 1) {
         y = 40;
       }
     }
   }
 }
Exemple #3
0
  public void keyPressed(KeyEvent e) {
    // #if (mov_0)
    int key = e.getKeyCode();
    if (key == KeyEvent.VK_LEFT) {
      current_Player.setLeft(true);
    }
    if (key == KeyEvent.VK_RIGHT) {
      current_Player.setRight(true);
    }
    if (key == KeyEvent.VK_DOWN) current_Player.setDown(true);
    if (key == KeyEvent.VK_UP) current_Player.setUp(true);
    if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(3);
    if (key == KeyEvent.VK_ENTER) if (current_Player.getSch().isIsActive() == false) changepl();
    if (key == KeyEvent.VK_F1) ls.createNewPlayer();
    // #if(tar)
    // @            if (key == KeyEvent.VK_Q){
    // @               // current_Player.setRocket(true);
    // @               // sch = new Schuss((int)current_Player.getX(),(int)current_Player.getY());
    // @               // current_Player.setBp(0);
    // @            }
    // #endif
    // #elif (mov_1)
    // @            int key = e.getKeyCode();
    // @            if (key == KeyEvent.VK_LEFT){
    // @                current_Player.setLeft(true);
    // @            }
    // @            if (key == KeyEvent.VK_RIGHT){
    // @                current_Player.setRight(true);
    // @            }
    // @            if (key == KeyEvent.VK_SPACE && current_Player.getLoad() < 2){
    // @                current_Player.setBp(current_Player.getBp()+5);
    // @                current_Player.setLoad(1);
    // @            }
    // @            if (key == KeyEvent.VK_DOWN) current_Player.setDown(true);
    // @            if (key == KeyEvent.VK_UP) current_Player.setUp(true);
    // @            if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(3);
    // @            if (key == KeyEvent.VK_ENTER) if (current_Player.getSch().isIsActive()==false)
    // changepl();
    // @            if (key == KeyEvent.VK_F1) ls.createNewPlayer();
    // #elif (mov_2)
    // @            int key = e.getKeyCode();
    // @            if (key == KeyEvent.VK_LEFT) current_Player.setLeft(true);
    // @            if (key == KeyEvent.VK_RIGHT) current_Player.setRight(true);
    // @            if (key == KeyEvent.VK_DOWN) current_Player.setDown(true);
    // @            if (key == KeyEvent.VK_UP) current_Player.setUp(true);
    // @            if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(3);
    // @            if (key == KeyEvent.VK_ENTER) if (current_Player.getSch().isIsActive()==false)
    // changepl();
    // @            if (key == KeyEvent.VK_F1) ls.createNewPlayer();
    // #elif (mov_3)
    // @            int key = e.getKeyCode();
    // @            if (key == KeyEvent.VK_LEFT){
    // @                current_Player.setLeft(true);
    // @            }
    // @            if (key == KeyEvent.VK_RIGHT){
    // @                current_Player.setRight(true);
    // @            }
    // @            if (key == KeyEvent.VK_SPACE){
    // @            	current_Player.setBp(current_Player.getBp()+5);
    // @            	current_Player.setLoad(1);
    // @                //current_Player.setSpeed(5);
    // @            }
    // @            if (key == KeyEvent.VK_DOWN) current_Player.setDown(true);
    // @            if (key == KeyEvent.VK_UP) current_Player.setUp(true);
    // @            if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(3);
    // @            if (key == KeyEvent.VK_ENTER) if (current_Player.getSch().isIsActive()==false)
    // changepl();
    // @            if (key == KeyEvent.VK_F1) ls.createNewPlayer();
    // #elif (mov_4)
    // @            int key = e.getKeyCode();
    // @            if (key == KeyEvent.VK_LEFT){
    // @                current_Player.setLeft(true);
    // @            }
    // @            if (key == KeyEvent.VK_RIGHT){
    // @                current_Player.setRight(true);
    // @            }
    // @            if (key == KeyEvent.VK_SPACE && current_Player.getLoad() < 2){
    // @                current_Player.setBp(current_Player.getBp()+5);
    // @                current_Player.setLoad(1);
    // @            }
    // @            if (key == KeyEvent.VK_DOWN) current_Player.setDown(true);
    // @            if (key == KeyEvent.VK_UP) current_Player.setUp(true);
    // @            if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(3);
    // @            if (key == KeyEvent.VK_ENTER) if (current_Player.getSch().isIsActive()==false)
    // changepl();
    // @            if (key == KeyEvent.VK_F1) ls.createNewPlayer();
    // #endif

    // neu beginn
    if (key == KeyEvent.VK_Q) {
      // #if (tar)
      // @            	current_Player.setRocket(true);
      // @            	sch = new Schuss((int)current_Player.getX(),(int)current_Player.getY());
      // @            	current_Player.setBp(0);
      // #endif
    }
    // neu ende
  }