Exemplo n.º 1
0
 private synchronized void initLevel() {
   if (level == null) return;
   // level.init();
   players[0] =
       new Player(
           synchedKeys[0],
           synchedMouseButtons[0],
           level.width * Tile.WIDTH / 2 - 16,
           (level.height - 5 - 1) * Tile.HEIGHT - 16,
           Team.Team1,
           localTeam);
   players[0].setFacing(4);
   level.addEntity(players[0]);
   level.addEntity(new Base(34 * Tile.WIDTH, 7 * Tile.WIDTH, Team.Team1, localTeam));
   if (isMultiplayer) {
     players[1] =
         new Player(
             synchedKeys[1],
             synchedMouseButtons[1],
             level.width * Tile.WIDTH / 2 - 16,
             7 * Tile.HEIGHT - 16,
             Team.Team2,
             localTeam);
     players[1].setLocalTeam(localTeam);
     level.addEntity(players[1]);
     level.addEntity(new Base(32 * Tile.WIDTH - 20, 32 * Tile.WIDTH - 20, Team.Team2, localTeam));
   }
   player = players[localId];
   player.setCanSee(true);
 }
Exemplo n.º 2
0
  private synchronized void createLevel(String levelFile) {
    try {
      level = Level.fromFile(levelFile);
    } catch (Exception ex) {
      throw new RuntimeException("Unable to load level", ex);
    }

    level.init();

    players[0] =
        new Player(
            synchedKeys[0],
            mouseButtons,
            level.width * Tile.WIDTH / 2 - 16,
            (level.height - 5 - 1) * Tile.HEIGHT - 16,
            Team.Team1);
    players[0].setFacing(4);
    level.addEntity(players[0]);
    level.addEntity(new Base(34 * Tile.WIDTH, 7 * Tile.WIDTH, Team.Team1));
    if (isMultiplayer) {
      players[1] =
          new Player(
              synchedKeys[1],
              mouseButtons,
              level.width * Tile.WIDTH / 2 - 16,
              7 * Tile.HEIGHT - 16,
              Team.Team2);
      // players[1] = new Player(synchedKeys[1], 10, 10);
      level.addEntity(players[1]);
      level.addEntity(new Base(32 * Tile.WIDTH - 20, 32 * Tile.WIDTH - 20, Team.Team2));
    }
    player = players[localId];
    player.setCanSee(true);
  }