Ejemplo n.º 1
0
 public void moveLayerThree(Graphics g) {
   backy += (int) (player1.getVelocity() * 0.1);
   midy += (int) (player1.getVelocity() * 0.5);
   drawEnemy(g);
   drawCoin(g);
   drawBox(g);
   drawPoof(g);
   drawStar(g);
   drawJumper(g);
   drawSpike(g);
   drawPup(g);
   if (backy <= dieHeight) {
     // System.out.println(die);
     g.drawImage(player1.move(2), player1.getX(), player1.getY(), this);
     if (player1.animationComplete()) {
       die = true;
     }
   } else {
     if (backy <= dieHeight) {
       player1.resetCounter();
     }
     if (keys[KeyEvent.VK_RIGHT]) {
       g.drawImage(player1.move(1), player1.getX(), player1.getY(), this);
     } else if (keys[KeyEvent.VK_LEFT]) {
       g.drawImage(player1.move(-1), player1.getX(), player1.getY(), this);
     } else {
       g.drawImage(player1.move(0), player1.getX(), player1.getY(), this);
     }
   }
 }
Ejemplo n.º 2
0
 private void movePlayers() {
   onePlayerAlive = false;
   Iterator i = players.iterator();
   while (i.hasNext()) {
     Player p = (Player) i.next();
     if (p.getLives() == 0) {
       p.setActive(false);
     }
     if (p.isActive()) {
       onePlayerAlive = true;
       p.move();
     }
   }
 }
Ejemplo n.º 3
0
  private void parseCommand(String message) throws IOException {
    if (message.length() == 0) return;

    // Get the command (first word)
    String comm;
    String arguments = null;

    if (message.indexOf(' ') != -1) {
      comm = message.substring(0, message.indexOf(' '));
      arguments = message.substring(message.indexOf(' ') + 1);
    } else {
      comm = message;
    }

    switch (comm.toLowerCase()) {
      case "say":
        say(arguments);
        break;

      case "tell":
        tell(arguments);
        break;

      case "north":
      case "n":
        player.move(Direction.N);
        break;

      case "northeast":
      case "ne":
        player.move(Direction.NE);
        break;

      case "east":
      case "e":
        player.move(Direction.E);
        break;

      case "southeast":
      case "se":
        player.move(Direction.SE);
        break;

      case "south":
      case "s":
        player.move(Direction.S);
        break;

      case "southwest":
      case "sw":
        player.move(Direction.SW);
        break;

      case "west":
      case "w":
        player.move(Direction.W);
        break;

      case "northwest":
      case "nw":
        player.move(Direction.NW);
        break;

      case "in":
        player.move(Direction.IN);
        break;

      case "out":
        player.move(Direction.OUT);
        break;

      case "look":
      case "l":
        player.look();
        break;

      default:
        Telnet.writeLine(cs, "Your meaning is unclear\n");
    }
  }