Enhance orbiting animations to actually support circles.

This commit is contained in:
Leshana
2018-01-20 17:28:14 -05:00
parent d58b25f1a5
commit b6a4531303

View File

@@ -3,18 +3,27 @@
Turn(.) //BYOND handles cases such as -270, 360, 540 etc. DOES NOT HANDLE 180 TURNS WELL, THEY TWEEN AND LOOK LIKE SHIT Turn(.) //BYOND handles cases such as -270, 360, 540 etc. DOES NOT HANDLE 180 TURNS WELL, THEY TWEEN AND LOOK LIKE SHIT
/atom/proc/SpinAnimation(speed = 10, loops = -1) /atom/proc/SpinAnimation(speed = 10, loops = -1, clockwise = 1, segments = 3)
var/matrix/m120 = matrix(transform) if(!segments)
m120.Turn(120) return
var/matrix/m240 = matrix(transform) var/segment = 360/segments
m240.Turn(240) if(!clockwise)
var/matrix/m360 = matrix(transform) segment = -segment
speed /= 3 //Gives us 3 equal time segments for our three turns. var/list/matrices = list()
//Why not one turn? Because byond will see that the start and finish are the same place and do nothing for(var/i in 1 to segments-1)
//Why not two turns? Because byond will do a flip instead of a turn var/matrix/M = matrix(transform)
animate(src, transform = m120, time = speed, loops) M.Turn(segment*i)
animate(transform = m240, time = speed) matrices += M
animate(transform = m360, time = speed) var/matrix/last = matrix(transform)
matrices += last
speed /= segments
animate(src, transform = matrices[1], time = speed, loops)
for(var/i in 2 to segments) //2 because 1 is covered above
animate(transform = matrices[i], time = speed)
//doesn't have an object argument because this is "Stacking" with the animate call above
//3 billion% intentional
//The X pixel offset of this matrix //The X pixel offset of this matrix
/matrix/proc/get_x_shift() /matrix/proc/get_x_shift()