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..
void MovePlayer(float PMANGLE)
{
if (dbKeyState(17)==1)
dbMoveSprite(1,+PM_MoveSpeed);
if (dbKeyState(31) == 1)
dbMoveSprite(1,-PM_MoveSpeed/1.5);
if (dbKeyState(32) == 1)
if (PM_Angle <=90 && PM_Angle >= 0 || PM_Angle >= -90 && PM_Angle <= 0)
dbSprite(1,dbSpriteX(1)+1,dbSpriteY(1),1);
else
dbSprite(1,dbSpriteX(1),dbSpriteY(1)+1,1);
if (dbKeyState(30) == 1)
dbSprite(1,dbSpriteX(1)-1,dbSpriteY(1),1);
//}
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:
void CheckCollision()
{
PM_Collision_Dist = 15;
FreeMove= true;
for (int i = 1000; i < 1144; i++)
{
BlockImage = dbSpriteImage(i);
if (BlockImage == 3)
{
BlockPositionX = dbSpriteX(i);
BlockPositionY = dbSpriteY(i);
Xspace = PM_PositionX - BlockPositionX;
Yspace = PM_PositionY - BlockPositionY ;
if (Xspace <= PM_Collision_Dist*4 && Xspace >= 0 || Xspace >= -PM_Collision_Dist && Xspace <= 0)
if (Yspace <= PM_Collision_Dist*4 && Yspace >= 0 || Yspace >= -PM_Collision_Dist && Yspace <= 0)
{
//Debug = if Collision then write on Block Collision
dbText(dbSpriteX(i),dbSpriteY(i)+22,"Collision");
FreeMove = false;
} // end X/Yspace if
}// End BlockImage if
} //end For
}// End checkCollision
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