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 / Inkey$ and Arrays

Author
Message
Gir
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Crazy Taco
Posted: 13th Nov 2003 01:53
hey im trying to make a system for gun/weapon selection, so when player presses a button ie no. 2 my code accesses weapons array at 2 checks whether this is available and if so displays it.

my problem arises due to the fact that the inkey$ command works with strings and i dont know how to convert the data.

i know the second part of the IF is wrong but i aint got round to thinkin bout that yet.

Pete

I'm makin' a cake...
CattleRustler
Retired Moderator
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 13th Nov 2003 03:36
to get what key is pressed you may want to use KEYSTATE(scancode) function. There is a scancode chart floating in one of these posts. Keystate() will return one if the key is being pressed, 0 if not.

Or there are predefined key functions like:
UPKEY()
DOWNKEY() etc...

check the dbp help for INPUT commands

-RUST-
Minn_Coder
22
Years of Service
User Offline
Joined: 1st Nov 2003
Location:
Posted: 13th Nov 2003 03:54
You can also use INKEY$() such as:

REPEAT
I$ = INKEY$()
UNTIL I$ > ""

PRINT "I$ = "; I$
PRINT "The value of I$ = "; VAL(I$)
WAIT KEY

The VAL function returns the numeric value of the string.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Nov 2003 09:31
... but only if it's a number key.

You can use ASC() to get the character value of the key you press, but really, it's best to go with what CattelRustler told you

http://developer.thegamecreators.com/?m=forum_view&t=19885&b=1
Gir
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Crazy Taco
Posted: 13th Nov 2003 21:17 Edited at: 13th Nov 2003 21:19
@ Rust
Yeah i thought about that before, but i wanted the keystate or inkey to correspond directly to my array entry. But the key state for Number 1 key is 2 so it could correspond to the second slot in the array.

@Minn
I think that is what im looking for cheers.

Thanks for the help

Pete

I'm makin' a cake...

Login to post a reply

Server time is: 2026-07-26 12:33:01
Your offset time is: 2026-07-26 12:33:01