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 / Keyboard commands

Author
Message
Azeral
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location:
Posted: 20th Mar 2003 02:28
hi im new to dark basic i really much more enjoy this then codeing with C++ and i was wondering i tried to set it up so i can move it with more then just the up and down and left and right keys, so i tried to attach it to like the a key for example but i get an error when i compile it saying variable a keydoesnt exist in this program, heres my code:

Rem Setup sync
Sync On
Sync Rate 30

Rem Create 5 cubes and place randomly
For x = 1 to 5
Make object cube x,100
Position object x,Rnd(2000),0,Rnd(2000)
Next x

Rem Main loop

Do

Rem Store camera angle

caY#= Camera angle Y()
caX#= Camera angle X()

Rem Control input for camera movement
If Upkey()=1 then Move camera 10
If Leftkey()=1 then Yrotate Camera Wrapvalue(caY#-5)
If Rightkey()=1 then Yrotate Camera Wrapvalue(caY#+5)
if Downkey()=1 then Xrotate Camera Wrapvalue(caX#+5)
if aKey()=1 then Xrotate Camera Wrapvalue(caX#-5)

Rem Refresh Screen
Sync
Loop

For x = 1 to 5
Make object cube x,100
Position object x,Rnd(2000),0,Rnd(2000)
Next x


how do i do the a key thing to work?
Magefire
23
Years of Service
User Offline
Joined: 20th Feb 2003
Location:
Posted: 20th Mar 2003 03:01
Where the aKey() is (line 25), you should replace this with inkey$() and you will be able to get a string with the letter pressed. If you don't know all the keycodes for the keys, you might want to try the following code:



also to try and make it easier on you, you might want to replace lines 22-24 with the code:



or you can just use:
Control camera using arrowkeys Camera Number, MoveSpeed, TurnSpeed

If you give a man some fire, he will be warm for a day. If you set a man on fire, he will be warm for the rest of his life.
Shady Simpson
23
Years of Service
User Offline
Joined: 15th Mar 2003
Location: United Kingdom
Posted: 20th Mar 2003 18:34
replace akey() with keystate(30)

Terabyte
23
Years of Service
User Offline
Joined: 28th Dec 2002
Location: UK
Posted: 20th Mar 2003 23:46
it realy depends on what you want akey() to be. if it is ment to be any key then id replace that line with
if upkey()=0 and downkey()=0 and leftkey()=0 and rightkey()=0 and scancode()>0 then......
otherwise i cant help you unless you tell me what akey is supposed to detect for
[img][/img]

I have a word of advice...
..don't piss on an electric fence!

Login to post a reply

Server time is: 2026-07-11 08:46:24
Your offset time is: 2026-07-11 08:46:24