DXInput: TDXInput; ImageList: TDXImageList; procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure DXDrawFinalize(Sender: TObject); procedure DXDrawInitialize(Sender: TObject); procedure FormCreate(Sender: TObject); procedure DXTimerTimer(Sender: TObject; LagCount: Integer); procedure DXDrawMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure DXDrawMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure DXDrawMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormClose(Sender: TObject; var Action: TCloseAction); private AnchorX: Integer; AnchorY: Integer; {鼠标点击发生的位置} MouseX: Integer; MouseY: Integer; {鼠标当前位置} PlayerSprite: TPlayerSprite; {游戏中我们所用鼠标控制的人物} BackSprite: TBackGroundSprite; {游戏的背景图} end; const speed=5; {游戏人物向各个方向运动时的动画播放速度} var MainForm: TMainForm; Steps: Integer; {用于控制切换精灵动画图片的参数} implementation {$R *.DFM} procedure TPlayerSprite.DoCollision(Sprite: TSprite; var Done: Boolean); begin Done:=False; {已经侦测到碰撞,不再重复检测碰撞} {检测游戏人物是否与其它精灵发生了碰撞,此处可以扩展为对话等情节} end; procedure TPlayerSprite.DoMove(MoveCount: Integer); var l,r,d,u: Boolean; absX,absY: Integer; {游戏人物的当前位置与目的地的绝对距离} begin inherited DoMove(MoveCount); MoveCount:=Trunc(MoveCount*1.5); l:=false; r:=false; u:=false; d:=false; if (Trunc(X)-MainForm.AnchorX>0) then l:=true else r:=true; if (Trunc(Y)-MainForm.AnchorY>0) then u:=true else d:=true;
|
正在阅读:用Delphi + DirectX开发简单RPG游戏用Delphi + DirectX开发简单RPG游戏
2004-02-14 09:34
出处:电脑爱好者
责任编辑:linjixiong
键盘也能翻页,试试“← →”键