Class KeyLogic

java.lang.Object
net.regsirius06.engine.control.KeyLogic

@Deprecated public class KeyLogic extends Object
Deprecated.
This class is deprecated. Consider using an alternative event handling system.
Handles the logic for interpreting key inputs and performing actions based on key bindings. This class is responsible for analyzing key events related to player movement and interaction with the labyrinth. It processes key presses to move the player, rotate the player, and toggle the minimap display.

The class uses a KeyDefinition instance to map actions to specific key codes and interprets key events accordingly.

  • Constructor Details

    • KeyLogic

      public KeyLogic(KeyDefinition definition)
      Deprecated.
      Constructs a new KeyLogic instance with the given key definition. This constructor initializes the key logic with a set of key bindings that will be used to handle player movements and other actions.
      Parameters:
      definition - the KeyDefinition containing the key bindings for various actions, such as movement and minimap toggle
  • Method Details

    • keyMoveAnalysis

      public void keyMoveAnalysis(@NotNull @NotNull KeyEvent e, Player player, Labyrinth2D labyrinth)
      Deprecated.
      Analyzes a key press event and processes the corresponding movement or rotation of the player. Based on the key event, this method modifies the player's position and orientation within the labyrinth.

      If the key press corresponds to a movement action, the player's position is updated accordingly. If the key press corresponds to a rotation action, the player's orientation is updated. The method also ensures that the player does not move through walls by checking for collisions within the labyrinth.

      Parameters:
      e - the KeyEvent representing the key press event
      player - the Player object whose position and direction are updated
      labyrinth - the Labyrinth2D object used to check for collisions with walls
    • keyMapAnalysis

      @Nullable public @Nullable Boolean keyMapAnalysis(@NotNull @NotNull KeyEvent e, boolean currentState)
      Deprecated.
      Analyzes a key press event to toggle the minimap display. This method checks if the key press corresponds to the minimap toggle action and returns the updated state. The minimap state is toggled from visible to hidden or vice versa based on the key press.
      Parameters:
      e - the KeyEvent representing the key press event
      currentState - the current state of the minimap (true for visible, false for hidden)
      Returns:
      the new state of the minimap (true if it should be shown, false if hidden), or null if the key press does not correspond to the minimap toggle