正在阅读:用Delphi + DirectX开发简单RPG游戏用Delphi + DirectX开发简单RPG游戏

2004-02-14 09:34 出处:电脑爱好者 作者:郭磊 责任编辑:linjixiong


  absX:=abs(Trunc(X)-MainForm.AnchorX);
  absY:=abs(Trunc(Y)-MainForm.AnchorY);

  if absX<4 then begin l:=false; r:=false; end;
  if absY<4 then begin u:=false; d:=false; end;
  {如果绝对距离已经小于四个象素,则认为已经到达目的地}

  if u and l and not d and not r then MoveTo(MoveCount,DrUpLeft);
  if u and r and not l and not d then MoveTo(MoveCount,DrUpRight);
  if d and l and not r and not u then MoveTo(MoveCount,DrDownLeft);
  if d and r and not u and not l then MoveTo(MoveCount,DrDownRight);
  if d and not l and not r and not u then MoveTo(MoveCount,DrDown);
  if u and not l and not r and not d then MoveTo(MoveCount,DrUp);
  if l and not u and not r and not d then MoveTo(MoveCount,DrLeft);
  if r and not l and not u and not d then MoveTo(MoveCount,DrRight);
  {根据目的地来判断运动的方向,从而播放相应方向运动的动画}

  Collision; {检测碰撞}
  Engine.X := -X+Engine.Width div 2 - Width div 2;
  Engine.Y := -Y+Engine.Height div 2 - Height div 2;
  {移动引擎,从而是游戏人物处于舞台的正中央}
  end;

  procedure TMainForm.DXTimerTimer(Sender: TObject; LagCount: Integer);
  begin
  if not DXDraw.CanDraw then exit;
  {检测DXDraw是否可以画,否则退出}
  DXInput.Update;
  {捕捉各类设备输入,这里我们用来检测鼠标的输入}

  LagCount := 1000 div 60;
  {用来控制整个游戏运行速度的参数}
  DXSpriteEngine.Move(LagCount);
  DXSpriteEngine.Dead;

  DXDraw.Surface.Fill(0);
  {将整个屏幕填充为黑色}
  DXSpriteEngine.Draw;

  with DXDraw.Surface.Canvas do
  begin
  brush.style:=bsclear;
  pen.style:=psclear;
  pen.color:=clwhite;
  Font.Color:=clWhite;
  Font.Size:=10;

  textout(10,10,'Press ESC to Quit');
  textout(100,100,'X: '+IntToStr(AnchorX)+'Y: '+IntToStr(AnchorY));

 

察看评论详细内容 我要发表评论
作者笔名简短内容 发表时间
:


键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品