Here goes my code:
timer.Create ("yes_i_really_did_it", 0.01, 30, function ()
achB.Paint = function (self, w, h)
surface.SetDrawColor (Color (255, 255, 255))
for j = 0, 5 do
surface.DrawLine (math.cos(i+3.14/5*2*j)*mul + 25, math.sin(i+3.14/5*2*j)*mul + 25, math.cos(i+3.14/5*2*(j+2))*mul + 25, math.sin(i+3.14/5*2*(j+2))*mul + 25)
end
end
i = i + 3.14/15
end)
So it makes a full turn in about 0.5 second.
Is there anything that I can do to optimize the process or to smooth star's movement? Seems like I can't set the timer delay to values below 1/60.
Whoosh, update
Now it stays fixed at the begining, rotates at hover and stops rotating only in nice position (with apex at the bottom)
local i = 3.14/25*2.5
local mul = 17
mypanel.Paint = function (self, w, h)
surface.SetDrawColor (Color (255,255,255))
for j = 0, 5 do
surface.DrawLine (math.cos(i+3.14/5*2*j)*mul + 25, math.sin(i+3.14/5*2*j)*mul + 25, math.cos(i+3.14/5*2*(j+2))*mul + 25, math.sin(i+3.14/5*2*(j+2))*mul + 25)
end
if self:IsHovered() or math.floor( (i)%(3.14/2.5)*100 ) != 31 then
i = i + 3.14/90
end
end
Hope that this piece of art may come in handy to you someday!
You can use FrameTime() for animations and just different things that require consistent timing
i = i + 3.14/90 * FrameTime() * 100
Sorry, you need to Log In to post a reply to this thread.