Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / User definable controls

Author
Message
Cowboy
22
Years of Service
User Offline
Joined: 1st Oct 2003
Location: Sydney
Posted: 5th Nov 2003 05:17
I'm hoping this isn't a really obvious one...
Can anyone tell me how I'd incorporate a player wanting to change controls into my game.
eg. At the moment i can do something like if (downkey() ...
If they want to make the down arrow be the letter G instead (for example), how would I code that?
I can store their key of choice for down (for example) in a variable. How do I then say "if (variable_for_downkey() ..."

Thanks!
CattleRustler
Retired Moderator
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 5th Nov 2003 06:15
from dbp help:

KEYSTATE
This command will return an integer value of one if the key specified by the scancode is pressed, otherwise
zero will be returned. The scancode value is the raw value assigned to the key of the keyboard device and
very often is ordered sequentially from the top left of the keyboard to the bottom right.

SYNTAX
Return Integer=KEYSTATE(Scancode)

searcg for a scancode chart or write alil app that gives you the scancode values.

this should help

-RUST-
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Nov 2003 08:43
You can get all of the key values from CodeBase : http://developer.thegamecreators.com/?m=codebase_view&i=2bffc1480b8fde081b95012e1a81604e

and rather than use the keystate() function to scan all keys to see which is pressed, use the scancode() function and it will tell you
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 5th Nov 2003 10:08
I've got a DLL that allows the user to define what keys they want for what - however its rather complicated.


Avatar & Logo by Indi. Insert witty comment here...
Genesis Rage
22
Years of Service
User Offline
Joined: 5th Oct 2003
Location:
Posted: 5th Nov 2003 11:11
what i saw in someones source code for a game was simply looking for a variable... dont have the actual code... so here is some psuedo-code


they didnt have anything in the game to change the keys... but you could easily do that... when they select what they want to change... have it look for the scancode() number...



so this is actually fairly easy to do... if you need some code to write the file (in ini format) check in the codebase, i put some code in there that you can write to ini files... and you can add/change info without having to re-write the entire file over again... real easy to use... and has information on how to use it in the code

Cowboy
22
Years of Service
User Offline
Joined: 1st Oct 2003
Location: Sydney
Posted: 2nd Dec 2003 06:07
Thanks All. I'll have a play around!

Login to post a reply

Server time is: 2026-07-27 01:32:48
Your offset time is: 2026-07-27 01:32:48