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.

Newcomers DBPro Corner / Movement With WASD

Author
Message
Shadow000
14
Years of Service
User Offline
Joined: 31st Jul 2010
Location:
Posted: 31st Dec 2010 16:49
Hi everyone. I know I've been gone for a long time (those that knew me) and I've been catching up on some programming the "live" way. Anyways, I have a question. How can I make an entity move with WASD? I've tried a number of ways but failed to find out. Would someone be kind enough to tell me? Thanks!



Kezzla
16
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 1st Jan 2011 07:19
if keystate(17) = 1
move object objectnumber, speed
end if

eg
move object 1, .5


keystates are
17 = w
30 = a
31 = s
32 = d

Sometimes I like to use words out of contents
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 1st Jan 2011 11:11
Hi, just use the keystate command. DBPro's new IDE has a keystate helper under the tools menu. Just check for the keystate being pressed and perform the necessary actions.

Little example


Hope this helps

A clever person solves a problem, a wise person avoids it - Albert Einstein
Shadow000
14
Years of Service
User Offline
Joined: 31st Jul 2010
Location:
Posted: 1st Jan 2011 14:09
Thanks a lot guys! I'll also take a look at that keystate helper, I haven't noticed it before.
luskos
17
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 2nd Jan 2011 20:53
It depends when you point with "before".Long time ago there was no keystate helper. Also correct me if i'm wrong(recently i left coding behind,so i'm little rusty), but move object command is gonna move the object by global axis, and if/when you rotate by some degree it still goes in the same direction, while you may expect other.If this satisfy you, then there is no problem, but i think you should know.You can dig some snippet in the forums for better WASD systems, probably there is.I cannot provide one myself.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
Eminent
14
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 4th Jan 2011 03:49
ORRRRR Lazyman way:



Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 4th Jan 2011 04:39 Edited at: 4th Jan 2011 04:43
I like bitwise operators. Although I'm not aware of any pro's or con's regarding this method.



To understand what's happening in the above code, you'll need to do some research on binary, bytes & bitwise operators.

Login to post a reply

Server time is: 2024-11-24 09:02:34
Your offset time is: 2024-11-24 09:02:34