Lua Colors Spinning Fan
Banget - Custom level - Mar 10, 2017 from AndroidIf fan led Colored Spinning.
Lua:
function init(is_sandbox)
id=world:get_entity(47)
tab={}
--Colors--
r={r=1,g=0,b=0.0,a=1}
g={r=0,g=1,b=0.0,a=1}
b={r=0,g=0,b=1.0,a=1}
w={r=1,g=1,b=1.0,a=1}
B={r=0,g=0,b=0.0,a=1}
p={r=1,g=0,b=0.5,a=1}
y={r=1,g=1,b=0.0,a=1}
a={r=1,g=1,b=1.0,a=0}
----------
--Draw--
draw={
a,r,a,g,a,b,a,w,a,p,a,y
}
--------
--Texels--
width=12
height=1
for y=0,height-1,1 do
for x=0,width-1 do
color=draw[1+y*width+x]
this:set_sprite_texel(x,height-y-1,color.r,color.g,color.b,color.a)
end
end
----------
speed=2
maxspeed=0
rot=0
end
function step(count)
if this:read(0)==1 then
this:set_sprite_blending(1)
this:set_sprite_filtering(0)
maxspeed=maxspeed+.003
if maxspeed>speed then maxspeed=speed end
rot=rot-maxspeed
else
maxspeed=0
end
lifespan=10
table.insert(tab,1,{rot})
tab[lifespan]=nil
x,y=id:get_position()
this:set_draw_z(id:get_layer()-1)
for i=1,#tab do
if this:read(0)==1 then
this:draw_sprite(x,y,tab[i][1],5,0.2,0,0,width,height)
end
end
end
Downloads: 102 - Level ID: 25394