Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creator: Bolodefchoco
- --Made in: 17/12/2016
- --Last update: 17/12/2016
- --[[ Notes:
- Does:
- Invoca efeitos especiais semelhantes a raios
- ]]--
- math.angle = function(x1,y1,x2,y2)
- return math.atan2(y2-y1,x2-x1)
- end
- math.dist = function(x1,y1,x2,y2)
- return (math.abs(x1-x2)^2 + math.abs(y1-y2)^2)^.5
- end
- table.random = function(x)
- return x[math.random(#x)]
- end
- draw = {}
- draw.line = function(x1,y1,x2,y2,id)
- local dist = math.dist(x1,y1,x2,y2)
- local ang = math.angle(x1,y1,x2,y2)
- for i = 0,math.floor(dist/7) do
- local x = x1 + math.cos(ang) * (i * 7)
- local y = y1 + math.sin(ang) * (i * 7)
- tfm.exec.displayParticle(id,x,y,math.random() * ((3/10)/2),math.random() * ((3/10)/2))
- end
- end
- draw.ray = function(x1,y1,x2,y2)
- local particles = table.random({0,1,2,9})
- local dist = math.dist(x1,y1,x2,y2)
- local ang = math.angle(x1,y1,x2,y2)
- local randDist = function()
- return math.random() * 25 + 25
- end
- local randAng = function()
- return math.pi/(math.random() * 450 + 40)
- end
- local w = {{x1,y1}}
- local t = 0
- local randAngle = randAng() * ((dist - t)/70)
- local z = table.random({-1,1})
- local v = ang + randAngle * z
- local randDistance = randDist()
- while randDistance < dist-t do
- t = t + randDistance
- local x = x1 + math.cos(v) * t
- local y = y1 + math.sin(v) * t
- w[#w+1] = {x,y}
- randDistance = randDist()
- randAngle = randAng() * ((dist - t)/70)
- z = z * -1
- v = ang + randAngle * z
- end
- w[#w+1] = {x2,y2}
- for i = 1,#w - 1 do
- local w1 = w[i]
- local w2 = w[i+1]
- draw.line(w1[1],w1[2],w2[1],w2[2],particles)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement