GameMaker [Solved] Setting point direction value in increments of 2

Hi,

I'm trying to get the pointing direction of an object to be in increments of 2. So whenever an object is facing a target, the direction value should be in multiples of 2. Essentially, only in even numbers, not odd numbers. Very similar to simply changing direction by having direction+=2. Problem is, I can't figure out how to get this to work with point_direction. Assume the object's target is the mouse.

Here is what I have:

Create:
Code:
threshold=4
dir = 90
starting_angle = 0//image_angle
ending_angle = 0//point_direction(x, y, mouse_x, mouse_y)
difference = angle_difference(ending_angle, starting_angle)
delta = min(abs(difference) / threshold, 1) * threshold * sign(difference)
Step:
Code:
starting_angle = dir
ending_angle = point_direction(x, y, mouse_x, mouse_y)
difference = angle_difference(ending_angle, starting_angle)  
delta = floor(min(abs(difference) / threshold, 1) * threshold * sign(difference))

dir += delta
This makes the object point towards the mouse, and produces dir values in factors of 1. How would I get the object to point at the mouse in factors of 2? I looked through the Real Numbers page in the manual, but since my math is horrendous, I couldn't recognize any function that would allow me to do this.

Thanks in advance!
 
^ Woah. That worked exactly as expected!

I searched the "~" character in the manual but it highlights it as an invalid search term. Do think it should be included there.

Thanks again.
 
Top