Distance
#3

Well, that function indeed can be optimized a bit

pawn Код:
forward Float:GetPlayerDistanceToPoint(playerid,Float:x,Float:y);
public Float:GetPlayerDistanceToPoint(playerid,Float:x,Float:y)     // Make it return a Float safes a flaotround and a variable
// Well, depends on if you can use it like that or if you need it as int
{
    new Float:x1,Float:y1,Float:z1;
    GetPlayerPos(playerid,x1,y1,z1);
    return floatsqroot(floatsub(x,x1) * floatsub(x,x1)) + floatsub(y,y1) * floatsub(y,y1)); // You dont need floatabs, as squared numbers are always positive
    // Also do not use floatpower, but just *, because floatpower is extremely slow
}
Should be at least 100% faster now
Reply


Messages In This Thread
Distance - by GiS - 17.03.2011, 13:24
Re: Distance - by Mike Garber - 17.03.2011, 13:35
Re: Distance - by Mauzen - 17.03.2011, 13:44
Re: Distance - by AH.1990 - 17.03.2011, 14:10
Re: Distance - by ricardo178 - 17.03.2011, 14:13
Re: Distance - by AH.1990 - 17.03.2011, 14:15

Forum Jump:


Users browsing this thread: 1 Guest(s)