Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rocket seing more than 1 possible target #1

Open
akapkotel opened this issue May 28, 2019 · 0 comments
Open

Rocket seing more than 1 possible target #1

akapkotel opened this issue May 28, 2019 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@akapkotel
Copy link
Owner

Rockets launched by the player can detect only the one - closest to the player - hostile ship from game.hostiles SpriteList. If 2 or more rockets are launched, each would target the same enemy, if it is still the closest hostile, since there is no method of excluding targetted Sprites from being targetted.

This is how rockets targetting algorithm looks like:

    def rocket_autoaim(self):
        """
        Method used only by 'rockets'. They make turns towards enemies.
        """
        # acquire target if has any and there are possible targets
        if not self.target and len(game.hostiles) > 0:
            if self.angle == UPWARD:  # if rocket fired by player
                # TODO: rockets ignoring targets already acquired by other
                #  rockets and take next one [ ][ ], test it [ ]
                # closest enemy ship:
                self.target = arcade.get_closest_sprite(self, game.hostiles)[0]
            else:
                self.target = game.player

The problem is, that method get_closest_sprite() of arcade.SpriteList accepts only the SpriteList, and not the list as the second argument. Creating another SpriteList for that purpose would be an
overkill.

@akapkotel akapkotel added the bug Something isn't working label May 28, 2019
@akapkotel akapkotel self-assigned this May 28, 2019
@akapkotel akapkotel pinned this issue May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant