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.

Dark GDK / Using the Keyboard W,A,D,A,X keys

Author
Message
3dmasters
15
Years of Service
User Offline
Joined: 3rd Nov 2009
Location:
Posted: 3rd Nov 2009 17:57
Hello All,
Does anyone have a sample code of using the keyboard
keys W=Up X=down A= move left, D= move right.

Thank you all,

Here i am!!!
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 3rd Nov 2009 19:13 Edited at: 3rd Nov 2009 19:14


Sorry if there are some syntax mistakes, i just wrote it here

Mulderman
20
Years of Service
User Offline
Joined: 8th Jan 2004
Location: C:\\
Posted: 3rd Nov 2009 20:57
One thing i don't understand why is everyone using keys like WASD and such for their games?


It's alot easier to play with arrow keys instead with the "tight" buttons WASD on the keyboard.

New GTA2 Map Editor :: http://www.gta2madness.co.cc
Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 3rd Nov 2009 21:27
The reason, I believe, most games/gamers use WASD as their movement keys is because of a couple reasons: (a) The general game controller has the directional buttons on the left side, (b) The general gamer(there are exceptions of course) is right-handed, so they control the view with the mouse with the mouse, and movement with the keyboard, so it is much more comfortable for the hand to be near the natural typing position than to move to the other side of the keyboard to control the movement.

as for the topic at hand: I would use the keystate(int ScanCode)(returns 1 if the key is down, and 0 if it's up) command inside an if statement after finding out what scan code the keys have(done with int scancode() command), or you can use the dinput.h header(like Hassan put) to get nice and easy to read directional scan codes.

Eg:

That should give you a box that moves around depending on which key you press.

puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 4th Nov 2009 00:09
Quote: "It's alot easier to play with arrow keys instead with the "tight" buttons WASD on the keyboard.
"


I disagree, the arrow keys are to far from other keys to reach a key for jumping/crouching/switching weapons/reloading IMO.
3dmasters
15
Years of Service
User Offline
Joined: 3rd Nov 2009
Location:
Posted: 4th Nov 2009 01:29
Hello,
Why does the camera not start at 0,0,0?



dbSyncOn();
dbSyncRate ( 60 );
dbAutoCamOff();
dbSetCameraRange ( 1, 5000 );
dbMakeMatrix ( 1, 200 ,200 5, 5 );
dbPositionCamera ( 250,10, 250 );
while ( LoopGDK() )

Here i am!!!
3dmasters
15
Years of Service
User Offline
Joined: 3rd Nov 2009
Location:
Posted: 4th Nov 2009 05:09
Hello All,
Thank you for all the input,, This code worked.
I made a little mistake i need W = forword and S = Backwords.

Could you help me out with a code example.

Here i am!!!
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 4th Nov 2009 13:44 Edited at: 8th Nov 2009 15:27
the camera doesn't start at 0,0,0, at least that's what i know, since when i load objects and position them at 0,0,0 i can still see them, it's like 0,0,-200


Diru
15
Years of Service
User Offline
Joined: 25th Jan 2009
Location: England
Posted: 8th Nov 2009 15:15
The camera doesn't start at 0,0,0 because you are positioning it at:

dbPositionCamera ( 250,10, 250 );
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 8th Nov 2009 15:27
generally, if you don't use dbAutoCamOff(), loading any object will move the camera from 0,0,0.
not sure about the matrix, but positioning it is better to be safe

Login to post a reply

Server time is: 2024-11-20 11:31:38
Your offset time is: 2024-11-20 11:31:38