Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
anyone interrested in LL
#21
cha0s: handling both is relatively easy. Here's how I handled it in Phantasm:

-The game is configured for one of three methods: keyboard, analog gamepad, or POV gamepad. This configuration is set with an external config app.
-The program itself has a special function designed to abstract input. This function handles input for whichever device is configured to be used (gamepad or keyboard) and returns a standard control code. It's hard for me to explain at almost 1 in the morning, but basically this function returns a value based on the state of your configured keys or your gamepad, and does so in a standard way...say you have it configured for keyboard and the Up key was pressed...it would return a CTRL_UP constant value...but having the gamepad configured, pressing Up on the analog stick or the POV (depending on which config is used) would also return a CTRL_UP, so the whole process would be abstracted by the function.
-Your other functions simply call this abstraction function and operate based on its result. Since no other function has to care which input method you're using, your code works the same no matter what it's being controlled with.

This was a bit tricky to pull off but when it was finished, it was an extremely cool thing to have working. Sorry if I'm not explaining it very clear but as I said, it's almost 1 in the morning. Big Grin

I could test it here, I have a POV gamepad, so no sweat. Big Grin

EDIT: Here's the abstraction function I used for Phantasm. It's not the best function (it needs recoding) but I think it gets the point across:

Code:
Function GetInput(Byval BlockingType As Byte = 0) As Byte
'this function returns the keying depending on the control scheme
Dim returnvalue As Byte, result As Integer, dumm As String
returnvalue = CTRL_NIL
Select Case GameCtrl
  Case 0
    'return values from the keyboard
    dumm = Inkey$
    If BlockingType = 1 Then
      If dumm = Chr$(38) Then 'up
        While Inkey$ <> "": Wend
        returnvalue = CTRL_UP
      End If
      If dumm = Chr$(40) Then 'down
        While Inkey$ <> "": Wend
        returnvalue = CTRL_DOWN
      End If
      If dumm = Chr$(37) Then 'left
        While Inkey$ <> "": Wend
        returnvalue = CTRL_LEFT
      End If
      If dumm = Chr$(39) Then 'right
        While Inkey$ <> "": Wend
        returnvalue = CTRL_RIGHT
      End If
    Else
      If GetKeyState(VK_LEFT) And &H80 Then returnvalue = CTRL_LEFT
      If GetKeyState(VK_UP) And &H80 Then returnvalue = CTRL_UP
      If GetKeyState(VK_RIGHT) And &H80 Then returnvalue = CTRL_RIGHT
      If GetKeyState(VK_DOWN) And &H80 Then returnvalue = CTRL_DOWN
    End If
    If dumm = Chr$(13) Then
      While Inkey$ <> "": Wend
      returnvalue = CTRL_OK
    End If
    If dumm = Chr$(32) Then
      While Inkey$ <> "": Wend
      returnvalue = CTRL_OK
    End If
    If dumm = Chr$(27) Then
      While Inkey$ <> "": Wend
      returnvalue = CTRL_CANCEL
    End If
  Case 1
    'if we're dealing with an analog control, get its axis values here
    result = joyGetPosEx(0, joystick)
    If joystick.dwXpos<30000 Then returnvalue = CTRL_LEFT
    If joystick.dwXpos>36000 Then returnvalue = CTRL_RIGHT
    If joystick.dwYpos<30000 Then returnvalue = CTRL_UP
    If joystick.dwYpos>36000 Then returnvalue = CTRL_DOWN
  Case 2
    'if we're dealing with a POV HAT, get its d-pad value here
    result = joyGetPosEx(0, joystick)
    If joystick.dwPOV = 0 Then returnvalue = CTRL_UP
    If joystick.dwPOV = 4500 Then returnvalue = CTRL_UP
    If joystick.dwPOV = 9000 Then returnvalue = CTRL_RIGHT
    If joystick.dwPOV = 13500 Then returnvalue = CTRL_RIGHT
    If joystick.dwPOV = 18000 Then returnvalue = CTRL_DOWN
    If joystick.dwPOV = 22500 Then returnvalue = CTRL_DOWN
    If joystick.dwPOV = 27000 Then returnvalue = CTRL_LEFT
    If joystick.dwPOV = 31500 Then returnvalue = CTRL_LEFT
End Select
'get buttons last so we can face and press at the same time and have the buttons register at a higher priority
If GameCtrl > 0 Then
  If joystick.dwButtons = 1 Then returnvalue = CTRL_OK
  If joystick.dwButtons = 2 Then returnvalue = CTRL_CANCEL
End If
GetInput = returnvalue
End Function
This exact code is useless for an action game (since only one value can ever be returned) but the basic idea is there.
\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
Reply
#22
Yes, it works here now. Although it's not fullscreen?

I've found a bug. Although it's not a big deal, but if I was to yank out the tree before reaching the bushes, I cannot rip the bushes, hence leaving me stuck.

Suggestions, other than going to the bushes each time first?
Screwing with your reality since 1998.
Reply
#23
@nek that's basically what i'm doing now, everything is at a very high level of abstraction. i have recoded overnight a configuration proggy, and hopefully fixed the bug that was plaguing me.

@anarky: full screen can be gotten by hitting the icon in the upper right of the window (next to the x) or by hitting "alt-enter"

http://prdownloads.sourceforge.net/lynn/...p?download
http://prdownloads.sourceforge.net/lynn/...r?download

http://prdownloads.sourceforge.net/lynn/...p?download
http://prdownloads.sourceforge.net/lynn/...r?download



heres a piece of the control setup in the beginning of ll, to show how easy it would be to plug in more values. this uses a function i also coded last night, which allows you to access the data in an xml through a certain notation, that is "tag->tag2->tag3" to get the value out of tag3, which would be in tag2, which would be in tag1 ;p pretty simple with recursion. anyways:


Code:
llg( atk_key )         = init_bin_obj( Val( xml_TagValue( last_controls, "key_map->attack" ) ), @atk_key_in_sub        , @atk_key_out_sub         )  
    llg( act_key )         = init_bin_obj( Val( xml_TagValue( last_controls, "key_map->item"   ) ), @act_key_in_sub        , @act_key_out_sub         )  
    llg( conf_key )        = init_bin_obj( Val( xml_TagValue( last_controls, "key_map->action" ) ), @conf_key_in_sub       , @conf_key_out_sub        )  
    
    llg( item_l_key )      = init_bin_obj( sc_comma  , @item_l_key_in_sub     , @item_l_key_out_sub      )  
    llg( item_r_key )      = init_bin_obj( sc_period , @item_r_key_in_sub     , @item_r_key_out_sub      )  
    
    llg( weap_switch_key ) = init_bin_obj( sc_m      , @weap_switch_key_in_sub, @weap_switch_key_out_sub )  
    
    llg( u_key.code ) = Val( xml_TagValue( last_controls, "key_map->move_up"    ) )
    llg( r_key.code ) = Val( xml_TagValue( last_controls, "key_map->move_right" ) )
    llg( d_key.code ) = Val( xml_TagValue( last_controls, "key_map->move_down"  ) )
    llg( l_key.code ) = Val( xml_TagValue( last_controls, "key_map->move_left"  ) )

the function pointers( thats what the opinters are ) point to functions that get called when the key is pressed. its a nice little system i came up with. i call them binary objects, for lack of a better term.
Reply
#24
Funny, it wasn't active before...
Screwing with your reality since 1998.
Reply
#25
wow...I just finished the demo...and wow....

That was amazing...

I WANT MORE!!!
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply
#26
thanks, you'll get more, don't worry... ;p *does magic spells to create more game*
Reply
#27
Well it didnt crash in the first area with my home computer and all was going fine but when I was in the area 1 down and one left from the first area I attacked an enemy and the game froze =(
url=http://www.smithcosoft.com]SmithcoSoft Creations[/url]
"If you make it idiot proof, someone will make a better idiot" - Murphy's Law
Reply
#28
Quote:Well it didnt crash in the first area with my home computer and all was going fine but when I was in the area 1 down and one left from the first area I attacked an enemy and the game froze =(
Again, the goblins wearing hardhats are not enemies... XD
But nah. I think cha0s knows about that one.
Reply
#29
the latest version doesnt even have the enemies there with the yellow hats. please get the latest version..
Reply
#30
Loved the first demo and I still love LL 8) Well done guys! I'll continue to play all of your demos until LL has reached version 1.0

The only thing that irritates me is that the game ends if you press esc...it's frustrating if you press esc by misstake and doesn't get a chance to undo...perhaps use the key Q or have a little box pup up with "are you sure you wanna quit?"...just a suggestion... Big Grin
[Image: jocke.gif]
Website: http://jocke.phatcode.net
"Some men get the world, other men get ex hookers and a trip to Arizona."
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)