share/hedgewars/Data/Scripts/Animate.lua
changeset 12088 1da37e2ba6fd
parent 12084 ccab0d396a7f
child 12594 d8adae379d3c
equal deleted inserted replaced
12087:78e9fbd52ffc 12088:1da37e2ba6fd
    48   end
    48   end
    49   FunctionList[1].func(unpack(FunctionList[1].args))
    49   FunctionList[1].func(unpack(FunctionList[1].args))
    50   RemoveFunction()
    50   RemoveFunction()
    51 end
    51 end
    52 
    52 
    53 function AnimInit()
    53 local function startCinemaLock()
    54   animPos = 1
    54      SetCinematicMode(true)
       
    55      SetInputMask(bnot(gmAnimate+gmAttack+gmDown+gmHJump+gmLeft+gmLJump+gmRight+gmSlot+gmSwitch+gmTimer+gmUp+gmWeapon))
       
    56 end
       
    57 
       
    58 local function stopCinemaLock()
       
    59      SetInputMask(0xFFFFFFFF)
       
    60      SetCinematicMode(false)
       
    61 end
       
    62 
       
    63 function AnimInit(startAnimating)
    55   lastx = 0
    64   lastx = 0
    56   lasty = 0
    65   lasty = 0
    57   jumpTypes = {long = gmLJump, high = gmHJump, back = gmHJump}
    66   jumpTypes = {long = gmLJump, high = gmHJump, back = gmHJump}
    58   jumpTimes = {long = 500, high = 500, back = 300, backback = 500} 
    67   jumpTimes = {long = 500, high = 500, back = 300, backback = 500} 
    59   moveDirs = {Right = gmRight, Left = gmLeft}
    68   moveDirs = {Right = gmRight, Left = gmLeft}
    70   AnimListNum = 0
    79   AnimListNum = 0
    71   FunctionList = {}
    80   FunctionList = {}
    72   FunctionListNum = 0
    81   FunctionListNum = 0
    73   skipping = false
    82   skipping = false
    74   skipFuncList = {}
    83   skipFuncList = {}
       
    84   animPos = 1
       
    85   if startAnimating then
       
    86      startCinemaLock()
       
    87   end
    75 end
    88 end
    76 
    89 
    77 function AnimSwitchHog(gear)
    90 function AnimSwitchHog(gear)
    78   --SetGearMessage(gear, 0)
    91   --SetGearMessage(gear, 0)
    79   --SetState(gear, 0)
    92   --SetState(gear, 0)
   286 end
   299 end
   287 
   300 
   288 function Animate(steps)
   301 function Animate(steps)
   289   if skipping == true then
   302   if skipping == true then
   290     animPos = 1
   303     animPos = 1
   291     SetCinematicMode(false)
   304     stopCinemaLock()
   292     SetInputMask(0xFFFFFFFF)
       
   293     SkipAnimation(steps)
   305     SkipAnimation(steps)
   294     return true
   306     return true
   295   end
   307   end
   296     
   308     
   297   if globalWait ~= 0 then
   309   if globalWait ~= 0 then
   298     return false
   310     return false
   299   end
   311   end
   300 
   312 
   301   if steps[animPos] == nil then
   313   if steps[animPos] == nil then
   302       animPos = 1
   314       animPos = 1
   303       SetCinematicMode(false)
   315       stopCinemaLock()
   304       SetInputMask(0xFFFFFFFF)
       
   305       return true
   316       return true
   306   end
   317   end
   307   
   318   
   308   if steps[animPos].args[1] ~= CurrentHedgehog and steps[animPos].func ~= AnimWait 
   319   if steps[animPos].args[1] ~= CurrentHedgehog and steps[animPos].func ~= AnimWait 
   309     and (steps[animPos].swh == nil or steps[animPos].swh == true) then
   320     and (steps[animPos].swh == nil or steps[animPos].swh == true) then
   310       AnimSwitchHog(steps[animPos].args[1])
   321       AnimSwitchHog(steps[animPos].args[1])
   311   end
   322   end
   312 
   323 
   313   SetInputMask(bnot(gmAnimate+gmAttack+gmDown+gmHJump+gmLeft+gmLJump+gmRight+gmSlot+gmSwitch+gmTimer+gmUp+gmWeapon))
   324   startCinemaLock()
   314   SetCinematicMode(true)
       
   315   retVal = steps[animPos].func(unpack(steps[animPos].args))
   325   retVal = steps[animPos].func(unpack(steps[animPos].args))
   316   if (retVal ~= false) then
   326   if (retVal ~= false) then
   317     animPos = animPos + 1
   327     animPos = animPos + 1
   318   end
   328   end
   319 
   329