public void update() { player.update(); player.checkAttack(enemies); finish.update(); finish.checkGrab(player); System.out.println(player.getx()); System.out.println(player.gety()); bg.setPosition(tileMap.getx(), tileMap.gety()); tileMap.setPosition(GamePanel.WIDTH / 2 - player.getx(), GamePanel.HEIGHT / 2 - player.gety()); if (player.isDead()) { player.setPosition(130, 2375); player.revive(); player.reset(); restart(); } // for(int i = 0; i < drinks.size(); i++){ // Alcohol a = drinks.get(i); // a.update(); // if(a.shouldRemove()){ // drinks.remove(i); // i--; // } // } // for (int i = 0; i < enemies.size(); i++) { Enemy e = enemies.get(i); e.update(); if (player.isDrunk()) { e.kill(); } if (e.isDead()) { enemies.remove(i); e.addScore(Level2State.score); i--; } } bg.setPosition(tileMap.getx(), tileMap.gety()); }
public void init() { tileMap = new TileMap(30); tileMap.loadTiles("/Tilesets/DaylightTiles.gif"); tileMap.loadMap("/Maps/1-3.map"); tileMap.setPosition(0, 0); tileMap.setTween(1); bg = new Background("/Backgrounds/VerticalSky.png", 0.0); finish = new Tombstone(50, 230, GameStateManager.CUTSCENE2, gsm, tileMap, true); player = new Player("/Sprites/JimmyRunning.gif", tileMap); player.setPosition(130, 2375); hud = new HUD(player); populateEnemies(); hud = new HUD(player); }