0 Members and 1 Guest are viewing this topic.
You already ported it? But why is there the border at the top of the screen? Is it in Lua instead of C++? How fast does it run btw?Also if someone made a vid of calc demos, the following song would fit really well
I've ported most of the code the Lua and it seems to be working almost properly in the student software. (It probably will be very very slow on calc ;P). However, the code (of the original) it very unoptimized and the person porting it to the Nspire C should really rewrite some of it I'm already changing a lot in my Lua port ^^Btw, it uses 15x15 textures.
Would you be able to describe precisely how it works ?
local reg = {}local wormImglocal width, heightlocal wormTexture = {0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x7fab,0x7fab,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x7fab,0x7fab,0x3F53,0x3F53,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x3F53,0x3F53,0x7fab,0x7fab,0x3F53,0x3F53,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x3F53,0x3F53,0x7fab,0x7fab,0x3F53,0x3F53,0x1f2b,0x1f2b,0,0,0,0,0,0x1f2b,0x1f2b,0x3F53,0x3F53,0x7fab,0x7fab,0x3F53,0x3F53,0x1f2b,0x1f2b,0,0,0,0,0,0x1f2b,0x1f2b,0x3F53,0x3F53,0x7fab,0x7fab,0x3F53,0x3F53,0x1f2b,0x1f2b,0,0,0,0,0,0x1f2b,0x1f2b,0x3F53,0x3F53,0x7fab,0x7fab,0x3F53,0x3F53,0x1f2b,0x1f2b,0,0,0,0,0,0x1f2b,0x1f2b,0x3F53,0x3F53,0x7fab,0x7fab,0x3F53,0x3F53,0x1f2b,0x1f2b,0,0,0,0,0,0x1f2b,0x1f2b,0x3F53,0x3F53,0x7fab,0x7fab,0x3F53,0x3F53,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x3F53,0x3F53,0x7fab,0x7fab,0x3F53,0x3F53,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x1f2b,0x3F53,0x3F53,0x7fab,0x7fab,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x7fab,0x7fab,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab}function on.construction() width = 338/2 height = 212/2 wormImg = {} local tsize = 15 local width, height = width, height local wormImg = wormImg local SPOKES = 1200 local spokeCalc = {} local spokeCosCalc = {} local spokeSinCalc = {} local x,y,z local divCalcX,divCalcY = 0,0 local sin, cos, log, floor = math.sin, math.cos, math.log, math.floor local XCENTER = floor(width/2) local YCENTER = floor(height/2 - height/4) local DIVS = SPOKES/2 for i=1, SPOKES do local n = 2*math.pi*i/SPOKES spokeCalc[i] = n spokeCosCalc[i] = cos(n) spokeSinCalc[i] = sin(n) end local incW = width/DIVS local incH = height/DIVS for j=1, SPOKES, 2 do z = log(j/DIVS)*25-25 divCalcX = divCalcX + incW divCalcY = divCalcY + incH for i=1, SPOKES do x = floor(divCalcX*spokeCosCalc[i]) + XCENTER y = floor(divCalcY*spokeSinCalc[i] - z ) + YCENTER if x>=0 and x<=width and y>=0 and y<=height then if not wormImg[y] then wormImg[y] = {} end wormImg[y][x] = 1 + floor(i/8)%tsize + tsize*(floor(j/12)%tsize) end end end timer.start(0.05)endlocal function shiftup() local wormTexture = wormTexture local reg=reg for k=1, 15 do reg[k]=wormTexture[k] end for k=16, 15*15 do wormTexture[k-15]=wormTexture[k] -- +1 for C to Lua end for k=1,15 do wormTexture[k+210]=reg[k] endendlocal function shiftright() local wormTexture = wormTexture local last for k=0, 14 do last=wormTexture[15*k+15] for i=15, 2, -1 do wormTexture[15*k+i]=wormTexture[15*k+(i-1)] end wormTexture[15*k + 1]=last endend--count=0function on.paint(gc) local wormTexture = wormTexture local wormImg = wormImg local height, width= height-1, width-1 local pos=0 for y=0, height do local yy=wormImg[y] for x=0, width do pos=pos+1 gc:setColorRGB(wormTexture[yy[x]]) gc:fillRect(x*2, y*2, 2, 2) --gc:fillRect(x, y, 1, 1) end end --count=count+1 --gc:setColorRGB(0xFF00FF) --gc:drawString(""..count, 100, 100, "top")endfunction on.timer() shiftup() shiftright() platform.window:invalidate()end