Sabtu, 20 September 2008

MENGGUNAKAN JOYSTIK DI DELPHI

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;

Tidak ada komentar: