Wednesday, 13 July 2011

Key and Mouse Controls

Robot can now be controlled using keyboard or mouse, but only on the croquet application (not the "basic" platform). This could be added, but you will have to check in the code that the active robot can move/rotate/hit.

Keyboard :
Two set of keys can be used :
  • Traditional Arrows (Move/Rotate) + Space (Hit)
  • Numeric pad using 2,8 (Move), 4,8 (Rotate), 5 (Hit)
Depending on the direction you're moving (forward/backward), the "Direction" parameter of Move will automatically be changed to 1/-1.
Depending on the direction you're rotating (right/left), the "Angle" parameter of Rotate will automatically be changed to a positive/negative value.

The command is linked to the "Pressed Listener" of the keyboard : it means that the robot will move again and again as long as you keep on pressing the key.

Mouse :



  You can also control the command using the mouse.

However, commands will only be used once even if you keep on clicking. This is because there is no event in MouseListener class for such thing.
 ( But this could be added easily, for exemple with a boolean set to true when mouse button pressed, and to false when it is released  ).








For the moment, if you want to change parameters, you have to use the forms like before.
Sliders will be added later to supplement the control panel.

No comments:

Post a Comment