Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[HELP] joystick vs loadsound
#11
(07-18-2025, 06:24 AM)johnno56 Wrote: After reading the posts about joystick/sound issues, I finally found and dusted off my old Logitech joystick, to see if I could at least replicate the problem. I ran both joystick test programs via N7, with and without loading the sound, and both programs functioned just fine. All programmed buttons displayed correctly when activated... my only issue was, the first time I ran them, the stick was not detected... turned out to be poor USB contacts after a long time of no use.... Do you need an N6 test done?

Thanks for testing! No need for an n6 test, as I do both joystick input and audio output differently there Smile
Reply
#12
No problemo... Wink
Logic is the beginning of wisdom.
Reply
#13
(07-16-2025, 11:47 AM)1micha.elok Wrote: Hi Marcus, 

Quick question — when I use sword = loadsound("sounds/sword.wav")
joyx(), joyy(), and joybutton() don’t seem to work anymore. Any idea why?
I’m not sure — maybe I made a mistake in the code or left something out.
Would really appreciate any help — thanks a lot!

Code:
set window "The Shadow Master",400,400,false
set redraw off

'sound effect
sword           = loadsound("sounds/sword.wav")

'-----------
' MAIN LOOP
'-----------
while not keydown(KEY_ESCAPE,true)
    set color 0,0,0
    cls
    set color 255,255,255
   
    set caret 10,10

    wln "joyx   : " + joyx() '1 = right,  -1 = left
    wln "joyy   : " + joyy() '1 = bottom, -1 = up
    wln
    wln "button : " + joybutton(0) '1 = true, 0 = false
    if joybutton(1) or keydown(KEY_SPACE,true) then play sound sword, 20
   
    fwait 60
    redraw
wend

Most likely the problem hasn't been solved, but could you give the latest version of n7 a try? I made a small change to the joystick code.
Reply
#14
(08-30-2025, 07:42 AM)Marcus Wrote: ...

Most likely the problem hasn't been solved, but could you give the latest version of n7 a try? I made a small change to the joystick code.

Thank you for the latest version of N7
This one is working :

Code:
'sound effect put before set window
sword = loadsound("sounds/sword.mp3")

#win32
set window "The Shadow Master",400,400,false
set redraw off
...
Reply
#15
Oh. Whilst on the subject of Joysticks... Is there a command that tests for the presence or connection of the joystick? ie: If the joystick is not connected then, by default, the game will use the keyboard...
Logic is the beginning of wisdom.
Reply
#16
(08-31-2025, 07:18 AM)johnno56 Wrote: Oh. Whilst on the subject of Joysticks... Is there a command that tests for the presence or connection of the joystick? ie: If the joystick is not connected then, by default, the game will use the keyboard...

Ah ... nope Smile I usually just implement both input methods:

Code:
' move.
if keydown(KEY_LEFT) or joyx() < 0
   ...
endif
...
' attack.
if keydown(KEY_SPACE, true) or joybutton(0, true)
   ...
endif
Reply
#17
No problemo... I can work with that... Smile
Logic is the beginning of wisdom.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)