MENGGUNAKAN JOYSTIK DI DELPHI

22.55
Anda pernah menggunakan joystik dalam game ? nah ini ada contoh untuk menggunakan joystik di DELPHI ....

Uses
MMSYSTEM;

var
MyJoy : TJoyInfo;
ErrorResult : MMRESULT;
begin
ErrorResult:= joyGetPos(joystickid1,@MyJoy);
if ErrorResult = JOYERR_NOERROR then
begin
TrackBar1.Position := MyJoy.wypos;
TrackBar2.Position := MyJoy.wxpos;
RadioButton1.Checked := (MyJoy.wbuttons and joy_button1) > 0;
RadioButton2.Checked := (MyJoy.wbuttons and joy_button2) > 0;
end else
case ErrorResult of
MMSYSERR_NODRIVER : ShowMessage('No Joystick driver present');
MMSYSERR_INVALPARAM : ShowMessage('Invalid Joystick Paramameters');
JOYERR_UNPLUGGED : ShowMessage('Joystick is Unplugged');
else ShowMessage('Unknown error with Joystick');
end;
end;

Artikel Terkait

Previous
Next Post »