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 / 2D movement help

Author
Message
HeavyAmp
17
Years of Service
User Offline
Joined: 25th Oct 2006
Location: Castle in the Sky!
Posted: 26th Oct 2006 21:28
Can someone point me towards a good example or show me how to get a sprite to move in the direction it is facing? Do i need to use trigonometry or is there a simpler way like a command in DBP? I know theres one for 3d objects but i cant find any for 2d ones.
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 26th Oct 2006 22:37
I'm not sure if there are any built in commands for that, but the trig is pretty straightforward.

X movement would be sin(angle)*distance.

Y movement would be cos(angle)*distance.

CHESS ENCOUNTER
Demo
WIP
HeavyAmp
17
Years of Service
User Offline
Joined: 25th Oct 2006
Location: Castle in the Sky!
Posted: 27th Oct 2006 00:05
It seems a lot harder than that. I remember doing this at high school ages ago (well two years ). I think weather or not you use sin() cos() or tan() depends on the angle the sprite is facing. I'm still going through it.
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 28th Oct 2006 16:56
but it's not. I threw this example together in DBP to prove it.



CHESS ENCOUNTER
Demo
WIP
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Oct 2006 20:02
You could just use "move sprite". That moves the sprite in the direction it's facing.

Or you could use the simple trig method. Remember those sin and cos functions, you'll need them in game programming.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
HeavyAmp
17
Years of Service
User Offline
Joined: 25th Oct 2006
Location: Castle in the Sky!
Posted: 31st Oct 2006 18:02
Thanks guys for your help. The tutorial is great. Yeah I was wrong about the trig .

Login to post a reply

Server time is: 2024-09-25 11:18:52
Your offset time is: 2024-09-25 11:18:52