All pastes #363409 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-02-19 11:38 UTC
rendered paste body
const
  TURN  = 0.005 ;
  SPEED = 0.08  ;
  DIST = -10;

type
  coord = record
    X : Integer ;
    Y : Integer ;
    Z : Integer ;
  end;

procedure updateVaisseau;
function pmodulo (angle : real) : real ;
function myInputRot : Coord ;


implementation

function pmodulo (angle : real) : real ;
  begin
    if angle >= 2*pi then
      result := angle - 2*pi
    else
      result := angle ;
  end ;

function myInputRot : coord ;
  begin
    myGame.myInput.Keybupdate ;
    result.X := 0 ;
    result.Y := 0 ;
    result.Z := 0 ;
    if myGame.myInput._KeyboardState[Key.Left]  then
      result.X := -1 ;
    if myGame.myInput._KeyboardState[Key.Right] then
      result.X :=  1 ;
    if myGame.myInput._KeyboardState[Key.Down]  then
      result.Y := -1 ;
    if myGame.myInput._KeyboardState[Key.UP]    then
      result.Y :=  1 ;
    if myGame.myInput._KeyboardState[Key.W]     then
      result.Z :=  1 ;
    if myGame.myInput._KeyboardState[Key.S]     then
      result.Z := -1 ;
  end ;

procedure updateVaisseau;
  var
    New, Old  : Ourmesh ;
    Translate : Vector3 ;
    View      : Matrix ;
    InputRot  : Coord ;
begin
  New := ourmesh(mygame.myData.m_HTourMesh['Zfighter']);
  Old := ourmesh(mygame.myData.m_HTourMesh['Zfighter']);
  myGame.myData.m_HTourMesh.Remove('Zfighter');
  InputRot := myInputRot ;
  New._direction.X := pmodulo(Old._direction.X + TURN * InputRot.X) ;
  New._direction.Y := pmodulo(Old._direction.Y + TURN * InputRot.Y) ;
  New._position.Z  := New._position.Z + SPEED * InputRot.Z ;
  New._matrice := Matrix.Translation(new._position) *
             Matrix.RotationYawPitchRoll(New._direction.X,New._direction.Y,New._direction.Z);
  View := Matrix.Invert(New._matrice);
  mygame.myEngine._D3DDevice.Transform.View := View;
  myGame.myData.m_HTourMesh.Add('Zfighter',New);
end ;