--[[
Rotation Puzzle 001 [V1] (03/02/2015)
Written by AFRLme [Lee Clarke]
-- + --
afrlme@outlook.com | skype @ AFRLme
-- + --
This script is donation optional. In game credit is non-negotiable.
You are free to: ¹ use it in your game(s). ² modify the script.
Do not remove - or edit - this comment block.
--]]
-- * variables * --
local size, pos
-- * tables * --
local t = {0, 60, 120, 180, 240, 300}
-- * function which rotates the tiles * --
function rotateObject(obj, delay, direction)
obj = Objects[obj]
obj.RotationCenter = { x = -1, y = -1 }
obj.Rotation = obj.Rotation
if direction then
if math.floor(math.deg(obj.Rotation)) == 0 or math.ceil(math.deg(obj.Rotation)) == 0 then obj:to(delay, {Rotation = math.rad(60)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 60 or math.ceil(math.deg(obj.Rotation)) == 60 then obj:to(delay, {Rotation = math.rad(120)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 120 or math.ceil(math.deg(obj.Rotation)) == 120 then obj:to(delay, {Rotation = math.rad(180)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 180 or math.ceil(math.deg(obj.Rotation)) == 180 then obj:to(delay, {Rotation = math.rad(240)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 240 or math.ceil(math.deg(obj.Rotation)) == 240 then obj:to(delay, {Rotation = math.rad(300)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 300 or math.ceil(math.deg(obj.Rotation)) == 300 then obj:to(delay, {Rotation = math.rad(0)}, easeLinearOut)
end
else
if math.floor(math.deg(obj.Rotation)) == 0 or math.ceil(math.deg(obj.Rotation)) == 0 then obj:to(delay, {Rotation = math.rad(300)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 60 or math.ceil(math.deg(obj.Rotation)) == 60 then obj:to(delay, {Rotation = math.rad(0)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 120 or math.ceil(math.deg(obj.Rotation)) == 120 then obj:to(delay, {Rotation = math.rad(60)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 180 or math.ceil(math.deg(obj.Rotation)) == 180 then obj:to(delay, {Rotation = math.rad(120)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 240 or math.ceil(math.deg(obj.Rotation)) == 240 then obj:to(delay, {Rotation = math.rad(180)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 300 or math.ceil(math.deg(obj.Rotation)) == 300 then obj:to(delay, {Rotation = math.rad(240)}, easeLinearOut)
end
end
end
-- * function which randomizes tile degrees at begin of scene * --
function initPzl_1(obj)
for i = 1, 3 do
-- + --
obj = Objects["pzl-001_"..i]
obj.RotationCenter = { x = -1, y = -1 }
obj.Rotation = obj.Rotation
-- + --
obj:to(0, { Rotation = math.rad( t[math.random(6)] ) }, easeLinearOut)
end
end
-- * function which checks if tiles rotation value is 0 * --
function checkPzl_1(o)
if math.floor(math.deg(Objects[o].Rotation)) == 0 or math.ceil(math.deg(Objects[o].Rotation)) == 0 then
return true
end
end