Code Snippet

private void MovePlayer(int rot, float speedmodify)

{

Vector3 temppos;

bool canx = false;

bool cany = false;

float extradist = 0.3f;

temppos = new Vector3(GetXYZ(PlayerPos, rot, PlayerSpeed * speedmodify).X,PlayerPos.Y,0);

if (temppos.X - extradist > 0 && temppos.X + extradist < mapheight - 0.1f && temppos.Y - extradist > 0 && temppos.Y + extradist < mapwidth - 0.1f)

{

if (tilemap[(int)(temppos.X - extradist), (int)temppos.Y] > 0 && tilemap[(int)(temppos.X + extradist), (int)temppos.Y] > 0 && tilemap[(int)temppos.X, (int)(temppos.Y - extradist)] > 0 && tilemap[(int)temppos.X, (int)(temppos.Y + extradist)] > 0)

{

if (tiletypes[tilemap[(int)temppos.X, (int)temppos.Y] - 1].passable == true)

{

canx = true;

}

}

}

temppos = new Vector3(PlayerPos.X, GetXYZ(PlayerPos, rot, PlayerSpeed * speedmodify).Y, 0);

if (temppos.X - extradist > 0 && temppos.X + extradist < mapheight - 0.1f && temppos.Y - extradist > 0 && temppos.Y + extradist < mapwidth - 0.1f)

{

if (tilemap[(int)(temppos.X - extradist), (int)temppos.Y] > 0 && tilemap[(int)(temppos.X + extradist), (int)temppos.Y] > 0 && tilemap[(int)temppos.X, (int)(temppos.Y - extradist)] > 0 && tilemap[(int)temppos.X, (int)(temppos.Y + extradist)] > 0)

{

if (tiletypes[tilemap[(int)temppos.X, (int)temppos.Y] - 1].passable == true)

{

cany = true;

}

}

}

temppos = GetXYZ(PlayerPos, rot, PlayerSpeed * speedmodify);

if (canx)

{

PlayerPos.X = temppos.X;

}

if (cany)

{

PlayerPos.Y = temppos.Y;

}

}