public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException { if (this.isHit == false && !gc.isPaused()) { this.move(hip, this.ship.getRotation()); this.ship.draw(this.x, this.y); } else if (System.currentTimeMillis() <= this.explosionTime + 300) { MultiplayerGame.explosion.draw(this.x - 15, this.y - 10); } if (shotFired && !Menu.multi) { if (currentShotSP.shotVisible && !currentShotSP.hit) { currentShotSP.updateShot(); g.fillOval(currentShotSP.x, currentShotSP.y, 8, 8); } else if (currentShotSP.timeFired + 800 < System.currentTimeMillis()) { currentShotSP.hit = false; currentShotSP.shotVisible = false; } } else if (shotFired && Menu.multi) { if (currentShotMP.shotVisible && !currentShotMP.hit) { currentShotMP.updateShot(); g.fillOval(currentShotMP.x, currentShotMP.y, 8, 8); } else if (currentShotMP.timeFired + 800 < System.currentTimeMillis()) { currentShotMP.hit = false; currentShotMP.shotVisible = false; } } }
public void isSPCollision() { for (Ship current : SingleplayerGame.ships) { if ((this.getClass() == AISP.class && current.getClass() == AISP.class) || (this.getClass() == OtherPlayer.class && current.getClass() == OtherPlayer.class)) { // Split up to be more legible continue; } if (this.currentShotSP != null && this != current) { if (this.currentShotSP.x < current.x + current.ship.getWidth() && this.currentShotSP.x > current.x && this.currentShotSP.y < current.y + current.ship.getHeight() && this.currentShotSP.y > current.y && !current.isHit && currentShotSP.shotVisible) { // Split up to be more legible System.out.println("HIT " + current.getShipName() + "!!"); current.isHit = true; currentShotSP.hit = true; SingleplayerGame.ships.remove(current); if (current.getClass() == AISP.class) { SingleplayerGame.count--; SingleplayerGame.killCount++; SingleplayerGame.aiShips.remove(current); } else { SingleplayerGame.deathCount++; } if (SingleplayerGame.aiShips.isEmpty()) { SingleplayerGame.respawnTimer = System.currentTimeMillis(); } this.currentShotSP.hit = true; this.explosionTime = System.currentTimeMillis(); } } } }