Advertisement
Rexzoolyblack

Sprite Move Plugin

May 1st, 2015
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.98 KB | None | 0 0
  1. Sprite = {};
  2.  
  3. function Sprite.Int()
  4.     wait = false;
  5.     debug = true;
  6.     Up = 0;
  7.     Down = 0;
  8.     Left = 0;
  9.     Right = 0;
  10.     _WinHandle = Application.GetWndHandle();
  11. end
  12. function Sprite.Move(s_image, m_drc, n_width, n_height, n_speed, m_l, m_u, m_r, m_d)
  13.     WindSize = Window.GetSize(Application.GetWndHandle());
  14.     G_B = {Y = 0, X = 0, W = n_width, H = n_height};
  15.     PCU_B = {Y = Image.GetPos(s_image).Y,X = Image.GetPos(s_image).X, W = Image.GetSize(s_image).Width, H=Image.GetSize(s_image).Height};
  16.    
  17.     if n_speed == nil or n_speed == '' then
  18.         n_speed = 1;
  19.     end
  20.     if m_l == nil or m_l == '' then
  21.         m_l = 0;
  22.     end
  23.    
  24.     if m_u == nil or m_u == '' then
  25.         m_u = 0;
  26.     end
  27.    
  28.     if m_r == nil or m_r == '' then
  29.         m_r = 0;
  30.     end
  31.    
  32.     if m_d == nil or m_d == '' then
  33.         m_d = 0;   
  34.     end
  35.  
  36.     if m_drc == _UP then
  37.         ImCon = PCU_B.Y - m_u;
  38.         if ImCon <= G_B.Y then
  39.             Y_Action = PCU_B.Y;
  40.             X_Action = PCU_B.X;
  41.         else
  42.             Y_Action = PCU_B.Y-n_speed;
  43.             X_Action = PCU_B.X;
  44.         end
  45.     end
  46.     if m_drc == _Down then
  47.         ImCon = PCU_B.Y + PCU_B.H - m_d;
  48.         if ImCon >= n_height then
  49.             Y_Action = PCU_B.Y;
  50.             X_Action = PCU_B.X;
  51.         else
  52.             Y_Action = PCU_B.Y+n_speed;
  53.             X_Action = PCU_B.X;
  54.         end
  55.     end
  56.     if m_drc == _Left then
  57.         ImCon = 0 - m_l;
  58.         if PCU_B.X <= ImCon then
  59.             Y_Action = PCU_B.Y;
  60.             X_Action = PCU_B.X;
  61.         else       
  62.             Y_Action = PCU_B.Y;
  63.             X_Action = PCU_B.X-n_speed;
  64.         end
  65.     end
  66.     if m_drc == _Right then
  67.         ImCon = PCU_B.X + PCU_B.W - m_r;
  68.         if ImCon >= n_width then
  69.             Y_Action = PCU_B.Y;
  70.             X_Action = PCU_B.X;
  71.         else
  72.             Y_Action = PCU_B.Y;
  73.             X_Action = PCU_B.X+n_speed;
  74.         end
  75.     end
  76.     if wait ~= true then
  77.         Image.SetPos(s_image, X_Action, Y_Action);
  78.     end
  79. end
  80.  
  81. function Sprite.Switch(s_image, m_drc, t_images)
  82.     if type(t_images) ~= 'table' then
  83.         Dialog.Message('Eror', 'Argument 3 must be of a table type.');
  84.         return 'Argument 3 must be of a table type.';
  85.     else
  86.         if m_drc == _UP then
  87.             Down = 0;
  88.             Left = 0;
  89.             Right = 0;
  90.             if Up == 0 or Up == 6 then
  91.                 Image.Load(s_image, t_images.UP.One);
  92.                 Up = Up+1;
  93.             elseif Up == 1 or Up == 2 or Up == 4 or Up == 5 or Up == 7 or Up == 8 or Up == 10 or Up == 11 then
  94.                 Up = Up+1;
  95.             elseif Up == 3 then
  96.                 Image.Load(s_image, t_images.UP.Two);
  97.                 Up = Up+1;
  98.             elseif Up == 9 then
  99.                 Image.Load(s_image, t_images.UP.Three);
  100.                 Up = Up+1;
  101.             elseif Up == 12 then
  102.                 Up = 0;
  103.             end
  104.         end
  105.         if m_drc == _Down then
  106.             Up = 0;
  107.             Left = 0;
  108.             Right = 0;
  109.             if Down == 0 or Down == 6 then
  110.                 Image.Load(s_image, t_images.Down.One);
  111.                 Down = Down+1;
  112.             elseif Down == 1 or Down == 2 or Down == 4 or Down == 5 or Down == 7 or Down == 8 or Down == 10 or Down == 11 then
  113.                 Down = Down+1;
  114.             elseif Down == 3 then
  115.                 Image.Load(s_image, t_images.Down.Two);
  116.                 Down = Down+1;
  117.             elseif Down == 9 then
  118.                 Image.Load(s_image, t_images.Down.Three);
  119.                 Down = Down+1;
  120.             elseif Down == 12 then
  121.                 Down = 0;
  122.             end
  123.         end
  124.         if m_drc == _Left then
  125.             Up = 0;
  126.             Down = 0;
  127.             Right = 0;
  128.             if Left == 0 or Left == 6 then
  129.                 Image.Load(s_image, t_images.Left.One);
  130.                 Left = Left+1;
  131.             elseif Left == 1 or Left == 2 or Left == 4 or Left == 5 or Left == 7 or Left == 8 or Left == 10 or Left == 11 then
  132.                 Left = Left+1;
  133.             elseif Left == 3 then
  134.                 Image.Load(s_image, t_images.Left.Two);
  135.                 Left = Left+1;
  136.             elseif Left == 9 then
  137.                 Image.Load(s_image, t_images.Left.Three);
  138.                 Left = Left+1;
  139.             elseif Left == 12 then
  140.                 Left = 0;
  141.             end
  142.         end
  143.         if m_drc == _Right then
  144.             Up = 0;
  145.             Down = 0;
  146.             Left = 0;
  147.             if Right == 0 or Right == 6 then
  148.                 Image.Load(s_image, t_images.Right.One);
  149.                 Right = Right+1;
  150.             elseif Right == 1 or Right == 2 or Right == 4 or Right == 5 or Right == 7 or Right == 8 or Right == 10 or Right == 11 then
  151.                 Right = Right+1;
  152.             elseif Right == 3 then
  153.                 Image.Load(s_image, t_images.Right.Two);
  154.                 Right = Right+1;
  155.             elseif Right == 9 then
  156.                 Image.Load(s_image, t_images.Right.Three);
  157.                 Right = Right+1;
  158.             elseif Right == 12 then
  159.                 Right = 0;
  160.             end
  161.         end
  162.     end
  163. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement