-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrevolution.lua
More file actions
50 lines (48 loc) · 1.45 KB
/
revolution.lua
File metadata and controls
50 lines (48 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--Rotate the pipe based on player direction
local direction = player:GetMovementDirection()
local rot = (direction-3) * 90
local diff = 0
--lerp angles interpolate the pipe movement to another direction
if sprite.Rotation < rot then
diff = -10
sprite.Rotation = sprite.Rotation + diff
return
end
if sprite.Rotation > rot then
diff = 10
sprite.Rotation = sprite.Rotation + diff
return
end
--Broken interpolation
if direction ~= -1 then
if sprite.Rotation < rot then
if(rot-sprite.Rotation > 0) then
diff = 10
end
if(rot-sprite.Rotation < 0) then
diff = -10
end
sprite.Rotation = sprite.Rotation + diff
return
end
end
--Club Interpolation still pretty broken
--Rotate the pipe based on player direction
local direction = player:GetMovementDirection()
local rot = (direction-3) * 90
if direction == -1 then
rot = 0
end
local diff = 0
--find the minimal angle distance between target rotation and sprite rotation
--rotate the sprite according to the player movement direction
if(rot-sprite.Rotation > 0) then
diff = 10
sprite.Rotation = sprite.Rotation + diff
return
end
if(rot-sprite.Rotation < 0) then
diff = -10
sprite.Rotation = sprite.Rotation + diff
return
end