-- title: testcart -- author: mieki256 -- desc: short description -- script: lua Obj = {} Obj.new = function(cx, cy, ang, r) local o = { id=0, x=0, y=0, t=0, cx=cx, cy=cy, ang=ang, r=r } o.update = function(self,dr) self.id = 1 + (self.t % 32 // 16) local rad = math.rad(self.ang) local r = self.r self.x = r*math.cos(rad)+self.cx self.y = r*math.sin(rad)+self.cy self.ang = self.ang + 1.5 self.r = self.r + dr self.t = self.t + 1 end o.draw = function(self) spr(self.id,self.x-4,self.y-4,0) end setmetatable(o, {__index=Obj}) return o end scrw, scrh = 240, 136 cx, cy = scrw/2, scrh/2 t=0 -- init objs objs = {} n = 24 for i=1,n do local o = Obj.new(cx, cy, i*360/n, 60) table.insert(objs, o) end -- main loop function TIC() local r = 0 if btn(0) then r=-1 end if btn(1) then r=1 end -- update for i, o in ipairs(objs) do o:update(r) end -- draw cls(0) for i, o in ipairs(objs) do o:draw() end print("Lua: " .. _VERSION,4,8*1,12) print("count: " .. t,4,8*2,12) print(t//60 .. " sec",4,8*3,12) t=t+1 end