Quote:
Originally Posted by kingcj
Ok Thanks, the circle works fine, but I can't seem to getangle() to show the angle of said circle. I am unsure of how to get the angle of the circle.
Sorry I could also use a little help with delta x and delta y (Like if the mouse is in front of the player and the player is following it) I have tried getdir() but it only works for Right and Down.
|
getangle and getdir are quite simple after you understand it. You pass it the delta (final position minus the initial position) values between two points and it'll give you the angle/direction towards the final position.
PHP Code:
//#CLIENTSIDE
function onCreated() setTimer(0.05);
function onTimeout() {
temp.delta_x = mousex - player.x;
temp.delta_y = mousey - player.y;
temp.ang = getangle(temp.delta_x, temp.delta_y);
temp.ndir = getdir(temp.delta_x, temp.delta_y);
with (findimg(200)) {
x = player.x + 1 + cos(temp.ang) * 5;
y = player.y + 1 - sin(temp.ang) * 5;
image = "block.png";
}
with (findimg(201)) {
x = mousex;
y = mousey - 0.5;
text = temp.ang SPC radtodeg(temp.ang);
textshadow = true;
}
player.dir = temp.ndir;
setTimer(0.05);
}