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 Discussion / i got a problem whit the inkey command!

Author
Message
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 17th Aug 2004 22:59
Hi!
okay here is the code but DONT LOOK AT IT BEFORE YOU HAVE READ THE FOLLOWING TEXT AND PLEASE DONT STEAL IT!


okay HERE is the problem:
okay when the commands go to the NEXTNEXT
and you have read all the text and information it at the end go to
PRINT "now choose a for red cable. s for green cable. and d for blue cable"

and UNDER that the "BLUECABLE" come so i want it so if you ETC press the b then it will go to start and start the game over.. BUT when i hit the B button it go to bluecable and write "YOU WIN"
when you should have lost! how do i fix this problem?


The NErd

i make games, i play games... But the fun thing is that i like to make them more than play them....
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 18th Aug 2004 00:29
please help!

i make games, i play games... But the fun thing is that i like to make them more than play them....
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 18th Aug 2004 08:58 Edited at: 18th Aug 2004 11:01
Okay...

First off, the inkey$() command has a problem that it returns the ascii value of the key pressed, meaning that "A" is 65 while "a" is 97. All of your if statements only test one version of the result, so you need to do both tests IF THE UPPER AND LOWER mean different things in your program. For most programs, this is not usually the case so we decide on which value we want to test and use the string case commands to change input;

upper$(inkey$()) = only give me upper case values
lower$(inkey$()) = only give me lower case values

--OR-- We use the scancode() operation. The scancode() operation returns the keyboard value of any key pressed, for which there is a graphic that shows what values are returned. (See link below)

Now, the secod problem you have is; the WAIT KEY just does that, it waits for a key. It doesn't test that key against anything. So you need another loop like you did at the label of LOOP: to wait for an A, S or B key to be pressed, then a series of tests that jump back in the program if the B key is not pressed. (Just like in the loop.) Again, use the upper$() or lower$() to make sure you test both capital B and lowercase b for being pressed.

loop2:
if lower$(inkey$())="b" then goto bluecable
if inkey$()="" then goto loop2
goto nextnext

good luck!
S.

[Edit] Here that link to the scancode() graphic;
http://forum.thegamecreators.com/?m=forum_view&t=33640&b=7
When you use it, it looks like;
if scancode()=48 then goto bluecable
as above for the "B" key.

Any truly great code should be indisguishable from magic.
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 20th Aug 2004 21:50
thanks

i make games, i play games... But the fun thing is that i like to make them more than play them....

Login to post a reply

Server time is: 2025-05-25 13:22:21
Your offset time is: 2025-05-25 13:22:21