I did this function when i am bored. I see some one on otserv wrold NEVER uses cos and sin function so i did 2 functions
The function rotatePos is VERRY good to use in some spells. You can rotate a position by an center and radius and a angle
if you do it:
for angle=1,360 do
you can draw a circle.
Like this: (made in lua funmction)
(using luagd)
And getPosByAngle, you can define a new posittion by an distance and angle. Like: Send a spell 30º at 5 SQMS of distance.
:thumbup:
Here the functions
The function rotatePos is VERRY good to use in some spells. You can rotate a position by an center and radius and a angle
if you do it:
for angle=1,360 do
you can draw a circle.
Like this: (made in lua funmction)
(using luagd)
Lua:
require('gd')
im = gd.createTrueColor(500, 500)
for ang=1,360 do
local novo = rotatePos({x=250,y=250},100,ang)
im:setPixel(math.floor(novo.x),math.floor(novo.y),im:colorAllocate(255, 0,0))
end
im:png("out.png")
os.execute("out.png")
And getPosByAngle, you can define a new posittion by an distance and angle. Like: Send a spell 30º at 5 SQMS of distance.
:thumbup:
Here the functions
Lua:
function getPosByAngle(pos,distance,ang) --By Mock the bear
local ang = math.rad(ang)
pos.x = (math.cos(ang)*pos.x)+distance
pos.y = (math.sin(ang)*pos.y)+distance
return pos
end
function rotatePos(center,radius,ang) --By Mock the bear
ang = math.rad(ang)
center.x = (radius * math.cos(ang) - radius * math.sin(ang))+center.x
center.y = (radius * math.sin(ang) + radius * math.cos(ang))+center.y
return center
end