public void update() {
        Stack<Projectile> removalStack = new Stack<Projectile>();
        Stack<Ship> removalStack2 = new Stack<Ship>();
        //update ships
        for (Ship ship : ships) {
            ship.update();
            if(!ship.isAlive()){
                removalStack2.add(ship);
            }
        }
        //check ship collisions
        checkShipCollisions();
        
        //update projectiles
        for (Projectile p : projectiles) {
            p.update();
            if(!p.isAlive()){
                removalStack.push(p);
            }
        }
        //check projectile collisions
        checkProjectileCollisions();
        
        //remove destroyed projectiles    
        for (Projectile p : removalStack) {
            p.destroyed();
            projectiles.remove(p);
        } 
        
        //remove destroyed ships
        for (Ship ship : removalStack2) {
            ship.destroyed();
            ships.remove(ship);
        }
    }