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 draw(Graphics2D g) { bg.draw(g); tileMap.draw(g); finish.draw(g); player.draw(g); for (int i = 0; i < enemies.size(); i++) { enemies.get(i).draw(g); } hud.draw(g); }