unit MP;

interface

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

type
  TSurface = record
    hd, bd, hg, bg : char;
  end;

  TV_vitesse = record
    angle, norme : real;
  end;
  TMP = class
    private
      surface : TSurface;
      i : real;
    public
      vv : TV_vitesse;
      constructor create;
      procedure new_coordonee(  var move : TMove ;  var Touches:TTouches ; vecteur: array of string);
      procedure get_surface ( move : TMove ; vecteur: array of string);

  end;

implementation

constructor TMP.create;
begin
  inherited;
end;

procedure TMP.new_coordonee(var  move : TMove ; var Touches:TTouches ; vecteur: array of string );
begin
  if (move.x < 0) or (move.x > 10 ) or (move.z < 0) or (move.z > 10) then
        move.y := move.y-0.2
  else
  begin

  get_surface(move , vecteur);
  if move.saut or touches.saut then
  begin
     move.saut := true;
     move.x := move.x + 0.1*cos(move.angle);
     move.z := move.z + 0.1*sin(move.angle);
     move.y := 3*sin(i);
     i:= i+0.1;
     if move.y < 0 then
     begin
      move.saut := false;
      move.y := 0;
      self.i := 0;
     end;

  end

  else
  if  (surface.hd <= '1') or (surface.bd <= '1') or (surface.hg <= '1') or (surface.bg <= '1') then
  begin
    if Touches.Dr then
    begin
      move.angle := move.angle - 0.1



    end;

    if Touches.Ga then
    begin
      move.angle := move.angle + 0.1;
    end;

    if Touches.Ha then
    begin

      move.x := move.x + 0.1*cos(move.angle);
      move.z := move.z + 0.1*sin(move.angle);

    end;

    if Touches.Ba then
    begin
      move.x := move.x - 0.1*cos(move.angle);
      move.z := move.z - 0.1*sin(move.angle);
    end;
  end
  else
    move.y := move.y-0.2;
  end;

  if Touches.R then
  begin
    move.angle := 1.57;
    move.x := 3;
    move.y := 0;
    move.z := 3;
    move.saut := false;
  end;

end;

procedure TMP.get_surface ( move : TMove ; vecteur: array of string);
begin
  surface.hd := vecteur[trunc(move.x+0.5)][trunc(1+move.z+0.5)];
  surface.bd := vecteur[trunc(move.x+0.5)][trunc(1+move.z-0.5)];
  surface.hg := vecteur[trunc(move.x-0.5)][trunc(1+move.z+0.5)];
  surface.bg := vecteur[trunc(move.x-0.5)][trunc(1+move.z-0.5)];
end;




end.
