Christopher Alexander
Member
So, I'm making a game where, at some times, all game objects rotate around the center of the screen. I've had it working just fine until now when I want to change a thing.
The code I'm running at the moment is:
This script stops running when "global.turn" equals the number of objects turning and then the game is set in another state. It's done somewhere else. I'm a messy coder. And I'm sure some of the things in there are unnecessary.
Now the thing is, with this code the objects, and their sprites, rotate around obj_origo, super good, but with my latest change I'd like it if the sprites do NOT rotate. I can get this effect by just removing everything that starts with "image_angle" but then I can't seem to find a case where I can stop the rotation at a quarter circle as is possible when checking the image_angle.
EDIT:
Basically; what do i put in the last if statement to know if there has been a quarter circle revolution if I can't use image_angle?
Any ideas or solutions?
The code I'm running at the moment is:
Code:
if (obj_timer.state == main_states.onRotationCW)
{
radius = point_distance(x, y, obj_origo.x, obj_origo.y);
angle = point_direction(x, y, obj_origo.x, obj_origo.y);
angle -= rotspeed;
image_angle -= rotspeed;
angle = angle mod 360;
image_angle = image_angle mod 360;
if (angle < 0)
{
angle += 360;
}
if (image_angle < 0)
{
image_angle += 360;
}
x = centerX - lengthdir_x(radius, angle);
y = centerY - lengthdir_y(radius, angle);
if (image_angle == 90 || image_angle == 180 || image_angle == 270 || image_angle == 0)
{
global.turn += 1;
turned = 1;
}
}
Now the thing is, with this code the objects, and their sprites, rotate around obj_origo, super good, but with my latest change I'd like it if the sprites do NOT rotate. I can get this effect by just removing everything that starts with "image_angle" but then I can't seem to find a case where I can stop the rotation at a quarter circle as is possible when checking the image_angle.
EDIT:
Basically; what do i put in the last if statement to know if there has been a quarter circle revolution if I can't use image_angle?
Any ideas or solutions?
Last edited: