Legacy GM checking if an object has rotated around itself

J

julkibr

Guest
So I want to add an effect where you have to rotate the gun around itself to reload the weapon


Code:
step event
image_angle = point_direction(x, y, mouse_x, mouse_y);
I already have all the gun rotating around the player effect but I would like to know how to measure an rotation so I could add an bullet in the chamber.Thanks in advance
 
Hopefully I can explain this well, but you can always test it for yourself if I can't....

If your gun is at 45 degrees, and you manually add to the image angle by another 360 degrees, it will return 405 degrees as the angle. When you just have point_direction it only uses 360, but you can go over that and still have it return the expected angle:

500 degrees would be 140 degrees, 720 is 360 etc etc

So you set a variable to the image angle when the reload started and hold it until the process is finished, and then just see if it's 360 degrees more than the variable being held. If it is - you know it has gone around fully, and the player has chambered the bullet.

Once the reload is finished you will go back to pointing at the mouse, and that returns image angle measurements to the usual 360 degree range.

pseudo code:

Code:
if !is_reload
{
image_angle = point_direction(x, y, mouse_x, mouse_y);
start_angle = image_angle;
}
else
{
if image_angle + chosen angle diff >= start_angle + 360
{
// can chamber, and end process;
image_angle = start_angle;
is_reload = false;
}
else
{
image_angle += chosen angle diff;
}
}
"chosen angle diff" is whatever amount you want to add to the rotation per step
 
Last edited:
J

julkibr

Guest
Hopefully I can explain this well, but you can always test it for yourself if I can't....

If your gun is at 45 degrees, and you manually add to the image angle by another 360 degrees, it will return 405 degrees as the angle. When you just have point_direction it only uses 360, but you can go over that and still have it return the expected angle:

500 degrees would be 140 degrees, 720 is 360 etc etc

So you set a variable to the image angle when the reload started and hold it until the process is finished, and then just see if it's 360 degrees more than the variable being held. If it is - you know it has gone around fully, and the player has chambered the bullet.

Once the reload is finished you will go back to pointing at the mouse, and that returns image angle measurements to the usual 360 degree range.

pseudo code:

Code:
if !is_reload
{
image_angle = point_direction(x, y, mouse_x, mouse_y);
start_angle = image_angle;
}
else
{
if image_angle + chosen angle diff >= start_angle + 360
{
// can chamber, and end process;
image_angle = start_angle;
is_reload = false;
}
else
{
image_angle += chosen angle diff;
}
}
"chosen angle diff" is whatever amount you want to add to the rotation per step
Just got home I will try this code thanks for answering
 
Top