Package hoverball

Class Human

java.lang.Object

public class Human
extends Unit
The Human unit is a particular Java unit. It transforms key events into actions which are instantly sent to the Simulator... - in short: you can play Hoverball yourself thanks to the Human unit!

For this purpose, you need a key controls that can be defined by the class Human.Controls.

The key input is enabled if the main panel of the human hovlet or the Controller's screen is active. (Of course, the latter works only if the Human unit and the Controller are running on the same Java instance.)


The class Human can also be executed as an application:

java hoverball.Human [team [name [color] [host][:port][#hash] ]]

  • (without) - Opens a Human unit.
  • name - Opens a Human unit with the indicated player name.
  • team name - Opens a Human unit with the indicated team and player name.
  • ... color - color, e.g FFC800 for orange.
  • ... host:port#hash - network address to be connected to.
    • Field Details

      • listener

        public static final java.awt.event.KeyListener listener
        KeyListener object for all Human units
    • Constructor Details

      • Human

        public Human()
        Opens a Human unit with CRSR controls.
      • Human

        public Human​(java.lang.String name)
        Opens a Human unit with CRSR controls.
        Parameters:
        name - unit name
      • Human

        public Human​(java.lang.String team, java.lang.String name)
        Opens a Human unit with CRSR controls.
        Parameters:
        team - team name
        name - unit name
      • Human

        public Human​(java.lang.String name, int color)
        Opens a Human unit with CRSR controls.
        Parameters:
        name - unit name
        color - color
      • Human

        public Human​(java.lang.String team, java.lang.String name, int color)
        Opens a Human unit with CRSR controls.
        Parameters:
        team - team name
        name - unit name
        color - color
      • Human

        public Human​(java.lang.String team, java.lang.String name, int color, Human.Controls controls)
        Opens a Human unit with indicated controls.
        Parameters:
        team - team name
        name - unit name
        color - color
        controls - controls
    • Method Details

      • main

        public static void main​(java.lang.String[] args)
        Executes a Human unit (application!).
      • assign

        public static final void assign​(Unit unit, Human.Controls controls)
        Assigns a controls to a unit.

        The assignment makes the unit send corresponding actions on keypress. By this method, Human units automatically assign their controls on call.

        If controls equals null, the assignment for this unit is canceled.

        Parameters:
        unit - unit
        controls - controls
      • untype

        public static final void untype()
        Imitates the release of all keys.

        This method should be called if an AWT component, on which the human KeyListener is enabled, loses its focus.

      • loop

        protected void loop()
        Empty.
        Specified by:
        loop in class Unit