-- title: moveballmoon -- author: mieki256 -- desc: short description -- site: website link -- license: MIT License (change this to your license of choice) -- version: 0.1 -- script: moon class Ball new: (@x,@y,@scrw,@scrh) => @id = 1 + 2 * math.random(0,5) spd = 0.4 * @scrw / 60.0 a = math.rad(math.random(360)) @dx = spd * math.cos(a) @dy = spd * math.sin(a) update: => @x += @dx @y += @dy if @x<=0 or @x>=@scrw-16 @dx *=-1 if @y<=0 or @y>=@scrh-16 @dy *= -1 draw: => spr @id,@x,@y,0,1,0,0,2,2 export t=0 sw,sh=240,136 -- init objs export objs={} n=80 for i=1,n objs[i] = Ball(sw/2,sh/2,sw,sh) export TIC=-> -- update for i=1,#objs objs[i]\update! -- draw cls 0 for i=1,#objs objs[i]\draw! print "Lua: #{_VERSION}",4,8,12 print "count: #{t}",4,16,12 print "#{t//60} sec",4,24,12 t+=1