X
xorphinindi
Guest
I'm having trouble adapting some code.
I have a stationary turret that the player can pan back and forth by changing its image_angle with the arrow keys.
I want to limit its rotation to a minimum and maximum angle from its original position.
The tutorial I followed does exactly what I want,
but it calculates the angle difference using mouse position rather than a set location.
Here's what I have now ---> in the step event:
In the script ---> scr_angleRotate:
I want it to have a full angle of 30 degrees so I've set minMaxAngle to 15.
I think I just need to change the (mouse_x, mouse_y) part but I can't figure out what to change it to for the life of me.
I have a stationary turret that the player can pan back and forth by changing its image_angle with the arrow keys.
I want to limit its rotation to a minimum and maximum angle from its original position.
The tutorial I followed does exactly what I want,
but it calculates the angle difference using mouse position rather than a set location.
Here's what I have now ---> in the step event:
Code:
pointDir = point_direction(x, y, mouse_x, mouse_y);
base_angle = image_angle;
delta = max(-minMaxAngle, min(minMaxAngle, angle_difference(pointDir, base_angle)));
image_angle = scr_angleRotate(image_angle, base_angle + delta, rSpeed);
Code:
angle = argument0;
baseDiff = argument1;
rotateSpeed = argument2;
calc = angle + median(-rotateSpeed, rotateSpeed, angle_difference(baseDiff, angle));
return calc;
I think I just need to change the (mouse_x, mouse_y) part but I can't figure out what to change it to for the life of me.