def METHOD_NAME(self, delta_time):
    """Movement and game logic"""
    if self.player_sprite.right >= self.end_of_map:
        if self.level < self.max_level:
            self.level += 1
            self.load_level(self.level)
            self.player_sprite.center_x = 128
            self.player_sprite.center_y = 64
            self.player_sprite.change_x = 0
            self.player_sprite.change_y = 0
        else:
            self.game_over = True
    # Call update on all sprites (The sprites don't do much in this
    # example though.)
    if not self.game_over:
        self.physics_engine.update()
    # --- Manage Scrolling ---
    # Track if we need to change the view port
    changed = False
    # Scroll left
    left_bndry = self.view_left + VIEWPORT_LEFT_MARGIN
    if self.player_sprite.left < left_bndry:
        self.view_left -= left_bndry - self.player_sprite.left
        changed = True
    # Scroll right
    right_bndry = self.view_left + SCREEN_WIDTH - VIEWPORT_RIGHT_MARGIN
    if self.player_sprite.right > right_bndry:
        self.view_left += self.player_sprite.right - right_bndry
        changed = True
    # Scroll up
    top_bndry = self.view_bottom + SCREEN_HEIGHT - VIEWPORT_MARGIN_TOP
    if self.player_sprite.top > top_bndry:
        self.view_bottom += self.player_sprite.top - top_bndry
        changed = True
    # Scroll down
    bottom_bndry = self.view_bottom + VIEWPORT_MARGIN_BOTTOM
    if self.player_sprite.bottom < bottom_bndry:
        self.view_bottom -= bottom_bndry - self.player_sprite.bottom
        changed = True
    # If we need to scroll, go ahead and do it.
    if changed:
        self.view_left = int(self.view_left)
        self.view_bottom = int(self.view_bottom)
        arcade.set_viewport(
            self.view_left,
            SCREEN_WIDTH + self.view_left,
            self.view_bottom,
            SCREEN_HEIGHT + self.view_bottom,
        )