title: Restart function in my python arcade game doesn´t work properly
body: <p>I´m currently working on a school project, which is a game with Python Arcade. It is my first coding experience so I´m still a beginner. Unfortunately the projekt is due in a few days, which is why I would really appreciate some help!</p>
  
  <p>The basic structure of the game (it´s a jump´n run) is already working and I just need to add a more platforms and enemys, but while trying to make a restart function, I have encountered a problem. After the game is won or over, it is supposed to restart. Resetting the player and enemys works, but the game is stuck then and it isn´t possible to move the player, nor are the enemys moving. I suppose that after restarting, the game doesn´t call the update function for some reason, but that is just my assumption and I honestly don´t know what the problem is.</p>
  
  <pre><code>import arcade
  
  WIN_WIDTH = 700
  WIN_HEIGHT = 400
  WIN_TITLE = "Jump and Run"
  PLAYER_SPEED = 8
  JUMP_SPEED = 17
  GRAVITY = 0.8
  ENEMY_SPEED = 2
  SPRITE_SCALING_PLAYER = 0.25
  SPRITE_SCALING_ENEMY = 0.7
  SPRITE_SCALING_PLATFORM_LONG = 0.5
  SPRITE_SCALING_PLATFORM_MIDDLE = 0.25
  SPRITE_SCALING_PLATFORM_SMALL = 0.25
  LEFT_MARGIN = 75
  RIGHT_MARGIN = 350
  
  INSTRUCTIONS_PAGE_0 = 0
  INSTRUCTIONS_PAGE_1 = 1
  GAME_RUNNING = 2
  GAME_OVER = 3
  
  class Game(arcade.Window):
  
      def __init__(self):
          super().__init__(WIN_WIDTH, WIN_HEIGHT, WIN_TITLE) 
          self.set_mouse_visible(False) 
  
          self.platform_list = None 
          self.enemy_list = None 
          self.player_list = None 
  
          self.player_sprite = None
  
          self.physics_engine = None
  
  
          self.view_bottom = None
          self.view_left = None
  
          self.background = None
          self.game_over = False
          self.game_won = False
  
          self.end_of_map_right = 5000
          self.end_of_map_left = 0
  
          self.current_state = INSTRUCTIONS_PAGE_0
  
          self.instructions = []
          texture = arcade.load_texture("images/title_screen.png")
          self.instructions.append(texture)
  
          texture = arcade.load_texture("images/title_screen.png")
          self.instructions.append(texture)
  
      def setup(self):
  
          self.platform_list = arcade.SpriteList()
          self.enemy_list = arcade.SpriteList()
          self.player_list = arcade.SpriteList()
  
          for x in range(0, 1):
              platform = arcade.Sprite("images/platform_long.png", SPRITE_SCALING_PLATFORM_LONG)
              platform.bottom = 0
              platform.left = x
              self.platform_list.append(platform)
  
          self.player_sprite = arcade.Sprite("images/player1.png", SPRITE_SCALING_PLAYER)
          self.player_list.append(self.player_sprite)
          self.player_sprite.center_x = 100
          self.player_sprite.center_y = 40
          self.physics_engine = arcade.PhysicsEnginePlatformer(self.player_sprite,
                                                               self.platform_list,
                                                               gravity_constant=GRAVITY)
  
          self.enemy_sprite = arcade.Sprite("images/enemy.png", SPRITE_SCALING_ENEMY)
          self.enemy_sprite.center_x = 200
          self.enemy_sprite.center_y = 75
          self.enemy_sprite.change_x = ENEMY_SPEED
          self.enemy_list.append(self.enemy_sprite)
          self.enemy_sprite.boundary_right = 200
          self.enemy_sprite.boundary_left = 50
  
          self.background = arcade.load_texture("images/background.png")
  
          self.view_left = 0
          self.view_bottom = 0
  
  
      def draw_instructions_page(self, page_number):
          page_texture = self.instructions[page_number]
          arcade.draw_texture_rectangle(WIN_WIDTH // 2, WIN_HEIGHT // 2,
                                        page_texture.width,
                                        page_texture.height, page_texture, 0)
  
  
      def draw_game_over(self):
          output = "Game Over"
          arcade.draw_text(output, 240, 400, arcade.color.WHITE, 54)
  
          output = "Click to restart"
          arcade.draw_text(output, 310, 300, arcade.color.WHITE, 24)
  
      def draw_game(self):
          arcade.draw_texture_rectangle(WIN_WIDTH // 2 + self.view_left, WIN_HEIGHT // 2, WIN_WIDTH, WIN_HEIGHT, self.background) #Hintergrund einzeichnen
          self.player_list.draw()
          self.platform_list.draw()
          self.enemy_list.draw() 
  
      def on_draw(self):
          arcade.start_render()
  
          if self.current_state == INSTRUCTIONS_PAGE_0:
              self.draw_instructions_page(0)
  
          elif self.current_state == INSTRUCTIONS_PAGE_1:
              self.draw_instructions_page(1)
  
          elif self.current_state == GAME_RUNNING:
              self.draw_game()
  
  
          elif self.current_state == GAME_OVER:
              self.draw_game()
  
      def on_mouse_press(self, x, y, button, modifiers):
          if self.current_state == INSTRUCTIONS_PAGE_0:
              self.current_state = INSTRUCTIONS_PAGE_1
          elif self.current_state == INSTRUCTIONS_PAGE_1:
              self.setup()
              self.current_state = GAME_RUNNING
          elif self.current_state == GAME_OVER:
              self.setup()
              self.current_state = GAME_RUNNING
  
      def on_key_press(self, key, modifiers):
  
          if key == arcade.key.SPACE: 
              if self.physics_engine.can_jump(): 
                  self.player_sprite.change_y = JUMP_SPEED 
          elif key == arcade.key.A: 
              self.player_sprite.change_x = -PLAYER_SPEED 
          elif key == arcade.key.D: 
              self.player_sprite.change_x = PLAYER_SPEED
  
  
      def on_key_release(self, key, modifiers):
  
          if key == arcade.key.A or key == arcade.key.D: 
              self.player_sprite.change_x = 0 
  
  
      def update(self, delta_time):
  
          if self.current_state == GAME_RUNNING:
  
              if  self.player_sprite.center_y &lt;= -100 or len(arcade.check_for_collision_with_list(self.player_sprite, self.enemy_list)) &gt; 0: 
                  self.game_over = True
  
              self.enemy_list.update() 
              self.physics_engine.update() 
              if self.player_sprite.right &gt;= self.end_of_map_right:
                  self.game_won = True
  
              for self.enemy_sprite in self.enemy_list:
                  if len(arcade.check_for_collision_with_list(self.enemy_sprite, self.player_list)) &gt; 0:
                      self.enemy_sprite.change_x *=-1
                  elif  self.enemy_sprite.boundary_right is not None and self.enemy_sprite.right &gt; self.enemy_sprite.boundary_right:
                      self.enemy_sprite.change_x = -ENEMY_SPEED
                  elif self.enemy_sprite.boundary_left is not None and self.enemy_sprite.left &lt; self.enemy_sprite.boundary_left:
                      self.enemy_sprite.change_x = ENEMY_SPEED
  
              scrolling = False
  
              left_boundary = self.view_left + LEFT_MARGIN
              if self.player_sprite.left &lt; left_boundary:
                  self.view_left -= left_boundary - self.player_sprite.left
                  scrolling = True 
  
              right_boundary = self.view_left + WIN_WIDTH - RIGHT_MARGIN 
              if self.player_sprite.right &gt; right_boundary: 
                  self.view_left += self.player_sprite.right - right_boundary 
                  scrolling = True
  
              if scrolling: 
                  self.view_left = int(self.view_left)
                  arcade.set_viewport(self.view_left, WIN_WIDTH + self.view_left, self.view_bottom, WIN_HEIGHT + self.view_bottom)
  
              if self.game_over or self.game_won:
                  self.current_state = GAME_OVER
                  self.set_mouse_visible(True)
  
  
  def main():
      window = Game()
      arcade.run()
  
  if __name__ == '__main__':
      main()
  </code></pre>