CapsAdmin

Untitled

Mar 1st, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.79 KB | None | 0 0
  1. chathud.markup.tags.blackhole = {
  2.     arguments = {1},
  3.    
  4.     pre_draw = function(markup, self, x,y, force)
  5.         local delta = FrameTime() * 2
  6.        
  7.         for k,v in pairs(markup.chunks) do
  8.             if v ~= self and v.w > 0 and v.h > 0 then
  9.                 if not v.phys then
  10.                     v.phys = {
  11.                         pos = {x = v.x, y = v.y},
  12.                         vel = {x = 0, y = 0},
  13.                     }  
  14.                 end
  15.                
  16.                 local phys = v.phys
  17.                
  18.                 phys.vel.x = phys.vel.x + (self.x - phys.pos.x) * 0.01 * force
  19.                 phys.vel.y = phys.vel.y + (self.y - phys.pos.y) * 0.01 * force
  20.                
  21.                 -- velocity
  22.                 phys.pos.x = phys.pos.x + (phys.vel.x * delta)
  23.                 phys.pos.y = phys.pos.y + (phys.vel.y * delta)
  24.  
  25.                 -- friction
  26.                 phys.vel.x = phys.vel.x * 0.97
  27.                 phys.vel.y = phys.vel.y * 0.97
  28.                
  29.                 v.x = phys.pos.x
  30.                 v.y = phys.pos.y
  31.             end
  32.         end
  33.     end,
  34. }
Add Comment
Please, Sign In to add comment