share/hedgewars/Data/Scripts/Animate.lua
changeset 12778 cb29ec085767
parent 12594 d8adae379d3c
child 13032 91f23558c936
equal deleted inserted replaced
12777:255c2978b366 12778:cb29ec085767
     1 local animPos, lastx, lasty, jumpTypes, jumpTimes, moveDirs, jumpStarted
     1 local animPos, lastx, lasty, jumpTypes, jumpTimes, moveDirs, jumpStarted
       
     2 local moveTime = 0
     2 local backJumped, jTimer, awTime, globalWait, stageEvents, seNum, curEvent
     3 local backJumped, jTimer, awTime, globalWait, stageEvents, seNum, curEvent
     3 local needtoDecrease
     4 local needtoDecrease
     4 local AnimList, AnimListNum
     5 local AnimList, AnimListNum
     5 local FunctionList, FunctionListNum
     6 local FunctionList, FunctionListNum
     6 local skipFuncList
     7 local skipFuncList
   164 function AnimFollowGear(gear)
   165 function AnimFollowGear(gear)
   165   FollowGear(gear)
   166   FollowGear(gear)
   166   return true
   167   return true
   167 end
   168 end
   168 
   169 
   169 function AnimMove(gear, dir, posx, posy)
   170 function AnimMove(gear, dir, posx, posy, maxMoveTime)
   170   dirr = moveDirs[dir]
   171   dirr = moveDirs[dir]
   171   SetGearMessage(gear, dirr)
   172   SetGearMessage(gear, dirr)
   172   if GetX(gear) == posx or GetY(gear) == posy then
   173   moveTime = moveTime + 1
       
   174   if (maxMoveTime and moveTime > maxMoveTime) then
       
   175     SetGearMessage(gear, 0)
       
   176     SetGearPosition(gear, posx, posy)
       
   177     lastx = GetX(gear)
       
   178     lasty = GetY(gear)
       
   179     moveTime = 0
       
   180     return true
       
   181   elseif GetX(gear) == posx or GetY(gear) == posy then
   173     SetGearMessage(gear, 0)
   182     SetGearMessage(gear, 0)
   174     lastx = GetX(gear)
   183     lastx = GetX(gear)
   175     lasty = GetY(gear)
   184     lasty = GetY(gear)
       
   185     moveTime = 0
   176     return true
   186     return true
   177   end
   187   end
   178   return false
   188   return false
   179 end
   189 end
   180 
   190