old QB Defender game - anyone want to try to bring this up to speed?
#20
(04-02-2023, 11:53 PM)madscijr Wrote:
(04-02-2023, 09:52 PM)mnrvovrfc Wrote:
(03-23-2023, 04:52 PM)mnrvovrfc Wrote: Now if only I still had that cheap Nintendo-SuperNES-like controller around or a joystick, because "nobody" likes the keystroke combinations in this program...

I cannot play this game with a keyboard when the best experience was meant for a joystick. This is a mental block on my side. The original Defender on SuperNES was difficult enough and I could deal even less with Defender 2 on the same cartridge. Giving me a computer keyboard to control things is like torture LOL.

I hear you. We could always add joystick/gamepad support, want to give it a try? (I have code for that, but it's ugly.)

Hi MadSciJr
here a function routine to manage joystick/gamepad builded up for Defender

I have tested it by using an USB joystick like that of PS3  (12 buttons and 4 axis and no wheel)
 with the ANALOGIC button not activated (the light on the Joystick is not on).
Code: (Select All)
I = _Devices
If I < 3 Then
    Print " No joystick or gamepad detected"
    End
Else
    LB = _LastButton(3): ReDim LBu(1 To LB) As Integer
    LA = _LastAxis(3): ReDim LAx(1 To LA) As Integer
    LW = _LastWheel(3): ReDim LWh(1 To LW) As Integer
End If

Do
    Locate 1, 1
    If LBu(1) <> 0 Then Print "Button 1 " Else Print Space$(25)
    If LBu(2) <> 0 Then Print "Button 2 " Else Print Space$(25)
    If LBu(3) <> 0 Then Print "Button 3 Boost" Else Print Space$(25)
    If LBu(4) <> 0 Then Print "Button 4 exiting": End Else Print Space$(25)
    If LAx(1) = 1 Then Print "Boost " Else Print Space$(25)
    If LAx(2) = -1 Then Print "UP-UP" Else If LAx(2) = 1 Then Print "DOWN-Down" Else Print Space$(25)
    I = InputJoy(LB, LA, LW, LBu(), LAx(), LWh())
Loop
End

Function InputJoy (LB, LA, LW, lbu() As Integer, lax() As Integer, lwh() As Integer)
    InputJoy = 0
    x& = _DeviceInput 'determines which device is currently being used
    If x& = 3 Then
        For b = 1 To LB
            lbu(b) = _Button(b)
        Next
        For a = 1 To LA
            lax(a) = _Axis(a)
        Next
        For w = 1 To LW
            lwh(w) = _Wheel(w)
        Next
    End If
    InputJoy = -1
End Function

Later I try to put this my function into QB64 Defender for playing the game by Joystick.
Reply


Messages In This Thread
RE: old QB Defender game - anyone want to try to bring this up to speed? - by TempodiBasic - 04-03-2023, 05:02 PM



Users browsing this thread: 17 Guest(s)