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 / Move character in facing direction

Author
Message
Tav
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location:
Posted: 27th Aug 2008 18:52 Edited at: 27th Aug 2008 18:52
Is there a way to move your character forward in the facing direction? I need to be able to turn my character and then when I click up my character needs to go forward in the angle his facing.
Here is what I have right now.
Main.cpp

Player.h


Thanks
elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 28th Aug 2008 00:30
set up a member variable of your character's class to keep track of the direction he's facing. then write a member function to animate and move the character based on the direction variable via a switch statement.

~you can call me lantz~
Carlos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 28th Aug 2008 06:51
You should use dbMoveObject ( int iObject, float fSpeed ) to move your object in its facing direction.
Tav
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location:
Posted: 28th Aug 2008 11:20 Edited at: 28th Aug 2008 11:23
Thanks for the replies.
Quote: "set up a member variable of your character's class to keep track of the direction he's facing. then write a member function to animate and move the character based on the direction variable via a switch statement.
"

Don't I have to make 360 switch statements then? plus how do I actually move the character in that direction, a vector? or do you mean 4 variables (left, right, forward, backward)?

Quote: "You should use dbMoveObject ( int iObject, float fSpeed ) to move your object in its facing direction. "
I tried that, unfortunaly this moves my character up(Z) instead of forward.

But thanks for trying .
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 28th Aug 2008 13:45 Edited at: 28th Aug 2008 13:45
But in GDK, D3D, OGL etc, Y is up! Have you not heard the term 'along the corridor, up the stairs', which is in reference to the 2D X and Y, Z is depth, though I believe CAD software brainwashes people into thinking otherwise, or people are just old fashioned and think they are looking at height maps.

Anyway, did you look at the move functions? You have 'dbMoveObjectUp/Down()' aka local Y axis movement.

Tav
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location:
Posted: 28th Aug 2008 13:58 Edited at: 28th Aug 2008 13:58
I will soon, not at my computer atm. And your right about the Y axis :p.

Thanks for replying.
Tav
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location:
Posted: 28th Aug 2008 14:43
Carlos and dark coder were right. It is dbObjectMove. Sorry.
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 29th Aug 2008 14:29
@dark coder: I was always told it was "along the steet, up to the girl"

Niels Henriksen
www.tales-of-the-realms.com
if Microsoft can sell software with bugs, so can I.
Bishop
21
Years of Service
User Offline
Joined: 18th Dec 2002
Location: In my favorite chair...
Posted: 29th Aug 2008 23:21
Disclaimer: I am not on my home computer, so I cannot really test these particular snippits. I have used this method MANY times in the past, so the theory is sound.

Use the 'NewValue' commands for this. It will generate a new position based on the old position, and angle, and a step value. For instance;

dbNewXValue( oldxvalue, yangle, stepvalue )
dbNewZValue( oldzvalue, yangle, stepvalue )

These two commands, when used to position the object, will create the effect you're looking for. Here is a simple example;



This is a smooth method to control your player without relying on those nasty constrictive 'move' commands. Another note, if you are going for a sidestepping control, like in a standard WASD fps control system, simply modify the Y angle of the player object. For instance, to sidestep left, modify the angle by -90 degrees. +90 for the right.

Play with the commands, I guarentee they will work when you get the hang of them.

-Bishop


Tux is my guildmaster.
elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 30th Aug 2008 00:25
Quote: "Don't I have to make 360 switch statements then? plus how do I actually move the character in that direction, a vector? or do you mean 4 variables (left, right, forward, backward)?"


sorry, i should have taken your usage of Z as meaning that this was a 3D program.

~you can call me lantz~

Login to post a reply

Server time is: 2024-09-30 05:35:10
Your offset time is: 2024-09-30 05:35:10