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 / More than one key at a time?

Author
Message
Pyro_guy
21
Years of Service
User Offline
Joined: 10th Oct 2003
Location: England
Posted: 2nd Jul 2004 21:03
I am building an FPS game and I have encountered a problem

It seems that, for some reason, after I move my mouse (to change the camera angle) I can no longer move forward and jump at the same time...

I have attatched my source, the keys to play are:

W = Forward
S = Backward
SPACE = Jump
Mouse = Look around

There shouldn't be any media needed

Screw the rules...what can i blow up?
Pyro_guy
21
Years of Service
User Offline
Joined: 10th Oct 2003
Location: England
Posted: 2nd Jul 2004 21:03
Darkbasic PRO by the way

Screw the rules...what can i blow up?
Physics coder
20
Years of Service
User Offline
Joined: 25th May 2004
Location: United States
Posted: 3rd Jul 2004 04:13 Edited at: 3rd Jul 2004 04:16
Hi,
Is this what you're trying to do?:

instead of just having one speed for the player, it has a forward speed(playerspeed.z), a strafe speed(playerspeed.x) and a vertical/jump speed(playerspeed.y).

-----------------------------------
To delete the bug, delete the code.
Specs: Sony VAIO Laptop, Windows XP, P4 2.8Ghz, 512MB RAM, ATI Radeon 64MB video memory, DBP Upgrade 5.3.
Pyro_guy
21
Years of Service
User Offline
Joined: 10th Oct 2003
Location: England
Posted: 4th Jul 2004 02:48
That seems like a better method

I still dont understand why my method doesnt work correctly, I've been through it a couple of times and I still cant figure it out

Thanks for the solution!

Screw the rules...what can i blow up?
Pyro_guy
21
Years of Service
User Offline
Joined: 10th Oct 2003
Location: England
Posted: 4th Jul 2004 03:24
Ok, looking more closely at your code, I can see it all works but could someone please explain why this line works?



Screw the rules...what can i blow up?
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 4th Jul 2004 05:27
heh-heh-heh, I can see your confusion...

It works because the keystate() commands return a zero or a one, which can be added or subtracted or even multipled by each other. In using that line it creates a zero, minus 1 or plus 1 depending on which keys being pressed, then multiples that against the movement amount of 0.1. It actually a clever way to go about the process, and one I'll have to remember as well...

S.

Any truly great code should be indisguishable from magic.

Login to post a reply

Server time is: 2024-11-26 23:25:39
Your offset time is: 2024-11-26 23:25:39