Posts: 6,236
Threads: 310
Joined: Jan 2011
Reputation:
0
Would also be interested in knowing this. I should really learn trig - it's fucking baffling to me though.
Posts: 2,938
Threads: 162
Joined: May 2010
Quote:
Originally Posted by MP2
Would also be interested in knowing this. I should really learn trig - it's fucking baffling to me though.
|
baffling? I thought it was taught in secondary education. I <3 Maths.
pawn Код:
new Float:x, Float:y, Float:z, Float:angle;
GetPlayerPos(playerid, x, y, z);
#pragma unused z
GetPlayerFacingAngle(playerid, angle);
GetXYInFrontOfPoint( x, y, angle, 1.0 );
GetXYInRightOfPoint( x, y, angle, 1.0 );
stock GetXYInFrontOfPoint( &Float: x, &Float: y, Float: angle, Float: distance ) {
x += ( distance * floatsin( -angle, degrees ) );
y += ( distance * floatcos( -angle, degrees ) );
}
stock GetXYInRightOfPoint( &Float: x, &Float: y, Float: angle, Float: distance ) {
Angle -= 90.0;
x += floatmul(floatsin(-angle, degrees), distance);
y += floatmul(floatcos(-angle, degrees), distance);
}
Note: I didn't used 'Player' functions because it would get the angle twice which means less performance.. (lol.. I know it's not much)
Posts: 930
Threads: 7
Joined: Jul 2010
Reputation:
0
Exactly, it really isn't that hard if you learn with it.
The only thing I don't understand, is what does -= and += stand for/do?
Posts: 2,938
Threads: 162
Joined: May 2010
Quote:
Originally Posted by clarencecuzz
Exactly, it really isn't that hard if you learn with it.
The only thing I don't understand, is what does -= and += stand for/do?
|
minus / plus equal operators
e.g
new var = 0;
var = 1 + 2; // var = 3 + 0;
var equals 1 plus 2
var = 0;
var += 3;
var plus 3 and is now equals to 3;
var = 3;
var += 3;
var plus 3 and is now equals to 6;