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 / DarkGdk : Strafe Moving Question Plus Collision with Zone Idea

Author
Message
haliop
User Banned
Posted: 21st Jan 2009 17:17 Edited at: 21st Jan 2009 17:19
hello all again.
to be shirt..
Building a 2D Top Down Shooter .
my problem is , Strafe Moving like in FPS when you move from side to side but not forward or backward just to sides..

the obvious is , using the Angles to calculate for when i move the Y and when the X according to the Angle of player.

little example from my code , i tried to work with it but did nothing..


i tried as you can see, but with no luck.

and one more thing i found a way to calculate Collision data
if using a Zone method , where all of the Sprites in that Zone are proccesed and calced once going in to that zone..
for now my game is in its beginnig so its not much of a zone just the entire map .. take a look at this:


the "For" loop is when the player is in a Zone.. in my game the zone is the entire screen 800X600 , i'm just a begginer but if this work for you guys , well , enjoy this

ty for your time.
nadav
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 21st Jan 2009 23:56


This code has some general problems:
-The argument PMANGLE is not in the function (you have used PM_Angle )
-After an "if" statement you should use curlybraces{} if there is more than one statement that needs to be executed in the "if".
-You have commented out the final curlybrace //}.

As for moving sideways, it is something I am going to implement in my game in next couple of days, I have a million things to do and as I seen this thread I have put it next on my list.
Im pretty sure I'll need trig(sin, cos etc..).
Hopefully someone will step in with the math and show us both, but if not keep checking the forum and I'll let you know how I get on.
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 23rd Jan 2009 23:05 Edited at: 25th Jan 2009 14:29
Here is a few of functions which provide sideways movement(strafe) in 3D:




Here is a differnt approach for 2D:





Then in your loop:



I have included 3D version for people doing searches in the future,
I have had to change little details from my code so let me know if there are errors, thanks.
p.s you can also use move() for forwards and backwards too.


EDIT 3D version does not work as well for 2D as dbSprite() only excepts integers.
haliop
User Banned
Posted: 24th Jan 2009 10:51
ok it works
strafe is working
just one little fix


in the Y position there should be a Minus instead of a Plus
cause the Y axis go from up 0 to down ### , it works good.

ty for that matty halewood

Login to post a reply

Server time is: 2024-11-25 13:31:00
Your offset time is: 2024-11-25 13:31:00