-2

I'm working on a simple platformer game in Arcade with a player and an enemy.

If the player collides with the enemy, I would like the game to start over from scratch.

However, with my current code, I call setup() and the game resets, but I am unable to move my player and the enemy doesn't move either. Please help!

        if len(arcade.check_for_collision_with_list(self.zombie, self.enemies)) > 0:
        self.game_over = True

    if self.game_over:
        self.score = 0
        self.setup()
        self.update()
  • This isn't really answerable as a general question, at least not within the scope of Stack Overflow. How you solve the problem depends on how the rest of the code is structured. If you want ideas for good ways to structure games so that they're "restartable", you should look for a tutorial - Stack Overflow is not the place to help you. – Karl Knechtel Jul 28 '20 at 09:32
  • Check out in the official documentation if you can find some useful examples. This question as Karl Knechtel said is not really answerable. https://arcade.academy/examples/index.html – Stefano Jul 28 '20 at 09:34

2 Answers2

1

Did you remember to set self.game_over = False after restarting?

jaleksi
  • 71
  • 1
  • Like the Zen of Python says: `In the face of ambiguity, refuse the temptation to guess.` If someone asking a question didn't provide enough information, you should post a comment to point that out, and vote to close as appropriate (usually, community specific -> needs debugging information). – Karl Knechtel Jul 28 '20 at 09:30
  • I would've posted this as a comment, but I don't have enough reputation. – jaleksi Jul 28 '20 at 09:32
  • 1
    Oof. Yeah, I'm not a fan of the bootstrapping involved with the reputation system here. The best I can advise is to just stick to the clear questions for now. – Karl Knechtel Jul 28 '20 at 09:33
  • 1
    @KarlKnechtel , I apologise. I am new to Stack Overflow and will make more effort to write clearer questions in the future. – katsunobutsu Aug 02 '20 at 06:40
0

You didn't provide enough information, but the problem should be that some variables didn't reset when you called setup(). So that's what you need to do

  • Like the Zen of Python says: `In the face of ambiguity, refuse the temptation to guess.` If someone asking a question didn't provide enough information, you should post a comment to point that out, and vote to close as appropriate (usually, community specific -> needs debugging information). – Karl Knechtel Jul 28 '20 at 09:30
  • I cant post comments with 1 reputation. I would –  Jul 28 '20 at 09:37