def update(self, td):
        # Pause the game if the player presses the pause button
        if inputs.getPausePress():
            statemgr.switch("pause")

        self.scene.update(td)
        self.energy_bar.update()
    def update(self, td):
        """Update the UI"""
        v = inputs.getVerticalPress()

        if v < -0.01:
            # Go to previous interactive widget
            self.selected = (self.selected - 1) % len(self.widgets)
            while not self.widgets[self.selected].interactive:
                self.selected = (self.selected - 1) % len(self.widgets)

        if v > 0.01:
            # Go to next interactive widget
            self.selected = (self.selected + 1) % len(self.widgets)
            while not self.widgets[self.selected].interactive:
                self.selected = (self.selected + 1) % len(self.widgets)

        # If the player presses a button, interact with the current widget
        if inputs.getFirePress() or inputs.getJumpPress() or inputs.getPausePress():
            self.widgets[self.selected].interact()

        # Update widgets
        for widget in self.widgets:
            widget.update(td)
 def update(self, td):
     """If the player presses the pause button, unpause the game."""
     if inputs.getPausePress():
         statemgr.switch(self.old_state_name)