unit gameplay;

interface
uses
  objet,
  System.Drawing,
  System.Windows.Forms,
  Microsoft.DirectX,
  Microsoft.DirectX.DirectInput,
  Microsoft.DirectX.Direct3D;

type

  TGameP = class
    private

    public
      keyboard : Microsoft.DirectX.DirectInput.Device;
      constructor Create;
//      procedure initilize;
      procedure GetEnter (var move : TMove);
  end;

implementation

constructor TGameP.Create;
begin
  inherited;
end;

//procedure TGameP.initilize;
//begin
//    Self.keyboard := Microsoft.DirectX.DirectInput.Device.Create(SystemGuid.keyboard);
//    Self.keyboard.SetCooperativeLevel(Self, (CooperativeLevelFlags.Background
//                                       or CooperativeLevelFlags.NonExclusive));
//    Self.keyboard.SetDataFormat(DeviceDataFormat.Keyboard);
//    Self.keyboard.Acquire;
//end;

procedure TGameP.GetEnter (var move : TMove);
var
  keys: KeyboardState;                          
begin
  keys := Keyboard.GetCurrentKeyboardState;

  if  ((move.x >= -11) and (move.x <= 11)) and ((move.z >= -11) and (move.z <= 11)) then
  begin
    if keys[Key.Right] then
    begin
      move.x := move.x+0.1;
    end;

    if keys[Key.left] then
    begin
      move.x := move.x-0.1;
    end;

    if keys[Key.up] then
    begin
      move.z := move.z+0.1;
    end;

    if keys[Key.down] then
    begin
      move.z := move.z-0.1;
    end;
  end
  else
    move.y := move.y-0.2;

  if keys[Key.R] then
  begin
    move.x := 0;
    move.y := 0;
    move.z := 0;
  end;

end;

end.
