Author Topic: [Lua] CubeField  (Read 37687 times)

0 Members and 1 Guest are viewing this topic.

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
[Lua] CubeField
« on: October 18, 2011, 12:22:19 pm »
Hello !

I hate school, I don't have enough free time to work on my games. (Yeah, I have a lot of simultaneous game projects)
But I managed to get a playable CubeField clone...

So basically you just have to avoid cubes :P
When you reach 1000, 2000, 3000... points, the speed increases and the colors change.
The 3D projection is not really realistic, I'll have to work on it.
And I also have to add a nice sprite for the player's ship.

But you still can have fun with this... (My highscore is 5600 points ! Can you beat it ?)



DOWNLOAD FINAL VERSION (modified 11/1/2011) (re-modified 11/27/2011)


_________________
EDIT : 10/19/2011


Animated screenshot (thanks to Jonius7)
Spoiler For Spoiler:

_________________
EDIT : 23/10/2011

-Now when you turn, the cubes become diagonal.
-The bug which caused some blocks that are farther to appear on top of the closer ones is fixed.
-Before the speed increases, a "Speed Up!" sign appears.
-Between 2 "levels", there is a corridor made of cubes.

_________________
EDIT : 23/10/2011

FINAL VERSION !

-There is a nice sprite for the player
-The corridor is more regular

Screenshots :
Spoiler For Spoiler:

_________________
EDIT : 10/19/2011

New final version :P
The 3D projection is now more realistic.
A little bugfix

Screenie :


_________________
EDIT : 10/19/2011

Yet another final version

Now the speed of the cubes automatically adapts to the framerate.
So the speed is the same on CX, clickpad, or computer software.

Color screenie :


Code :
Spoiler For Spoiler:
Code: [Select]
playerImg=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\128\000\128\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128")

cubesX={1,5,7,6,4,6,4,1,3,2,3,7,8,9,1,2,3,4,2,6,7,1,9,1,2,3,4}
cubesY={1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8,9,9,9}
lastCube=1
player=0
speed=0.08
moving=false
dir=1
moveStart=0
menu=true
score=0
level=1
color={225,170,0}
rotation=0
lastTick=0
delay=0

function render(gc)
 drawHorizon(gc)
 local size,x,y,i,polygon
 for j=1,27 do
  i=(j+lastCube-2)%27+1
  size=100/(10-cubesY[i])
  x=(cubesX[i]-7-player)/(10-cubesY[i])*150-size/2
  y=5/(10-cubesY[i])*50-180
  polygon=rotate({x,y,x+size,y,x+size,y+size,x,y+size,x,y})
  if cubesY[i]>1 then
   gc:setColorRGB(color[1],color[2],color[3])
   gc:fillPolygon(polygon)
   gc:setColorRGB(0,0,0)
   gc:drawPolyLine(polygon)
  end
  if y+size>3 and y<17 then
   if x<6 and x+size>-6 then
    menu=true
    score=math.floor(score)
   end
  end
 end
end

function rotate(p)
 local s,c=math.sin(rotation),math.cos(rotation)
 return {p[1]*c-p[2]*s+159,p[1]*s+p[2]*c+202,p[3]*c-p[4]*s+159,p[3]*s+p[4]*c+202,p[5]*c-p[6]*s+159,p[5]*s+p[6]*c+202,p[7]*c-p[8]*s+159,p[7]*s+p[8]*c+202,p[9]*c-p[10]*s+159,p[9]*s+p[10]*c+202}
end

function updateCubes()
 local step=menu and 0.06 or speed
 for i=1,27 do
  cubesY[i]=cubesY[i]+step*delay/30
  if cubesY[i]>10 then
   if score%1000<800 then
    cubesX[i]=math.random(0,140)/10+player
   else
    cubesX[i]=math.random(0,140)/200+player+(i-1)%2*5+4.1
   end
   cubesY[i]=cubesY[i]-9
   lastCube=lastCube==1 and 27 or lastCube-1
  end
 end
end

function updateMove()
 if moving then
  player=player+0.07*dir*delay/30
  if math.abs(rotation)<0.15 or dir==rotation/math.abs(rotation) then
   rotation=rotation-0.005*dir*delay/30
  end
  if timer.getMilliSecCounter()-moveStart>=150 then
   moving=false
  end
 else
  if math.abs(rotation)>0.005 then
   rotation=rotation-0.005*rotation/math.abs(rotation)*delay/30
  end
 end
end

function drawPlayer(gc)
 if not menu then
  gc:drawImage(playerImg,149,192)
 end
end

function drawHorizon(gc)
 local s,c=math.sin(rotation),math.cos(rotation)
 gc:setColorRGB(0,0,0)
 gc:drawLine(s*142-c*200+159,202-c*142-s*200,c*200+s*142+159,s*200-c*142+202)
end

function drawMenu(gc)
 if menu then
  gc:setColorRGB(0,0,0)
  gc:setFont("sansserif","r",30)
  gc:drawString("CubeField",80,10,"top")
  gc:setFont("sansserif","b",12)
  gc:drawString("Press Enter",115,150,"top")
  local highscore=var.recall("highscore")
  if not highscore then
   var.store("highscore",0)
   highscore=0
  end
  if score>highscore then
   var.store("highscore",score)
   document.markChanged()
  end
  local str="Score : "..tostring(score).."              Highscore : "..tostring(highscore)
  gc:drawString(str,159-gc:getStringWidth(str)/2,100,"top")
 end
end

function drawScore(gc)
 if not menu then
  gc:setColorRGB(0,0,0)
  gc:setFont("sansserif","r",12)
  gc:drawString(tostring(math.floor(score)),2,0,"top")
  if score%1000>950 then
   gc:setFont("sansserif","r",30)
   gc:drawString("Speed Up !",80,10,"top")
  end
 end
end

function levelUp()
 speed=speed+0.02
 level=level+1
 if (level-1)%5==0 then
  color={225,170,0}
 elseif (level-1)%5==1 then
  color={0,0,255}
 elseif (level-1)%5==2 then
  color={100,100,100}
 elseif (level-1)%5==3 then
  color={90,255,0}
 elseif (level-1)%5==4 then
  color={255,255,255}
 end
end

function on.paint(gc)
 render(gc)
 drawPlayer(gc)
 drawMenu(gc)
 drawScore(gc)
 gc:setColorRGB(0,0,0)
 gc:setFont("sansserif","r",8)
 gc:drawString("Lua CubeField - Par Loic Pujet",10,200,"top")
 updateFPS()
 timer.start(0.01)
end

function on.timer()
 timer.stop()
 updateCubes()
 updateMove()
 if not menu then
  score=score+delay/30
  if score>level*1000 then
   levelUp()
  end
 end
 platform.window:invalidate()
end

function on.enterKey()
 if menu then
  menu=false
  speed=0.08
  moving=false
  score=0
  level=1
  color={225,170,0}
  for i=1,27 do
   cubesY[i]=cubesY[i]-5
  end
 end
end

function on.arrowLeft()
 if not menu then
  dir=-1
  moving=true
  moveStart=timer.getMilliSecCounter()
 end
end

function on.arrowRight()
 if not menu then
  dir=1
  moving=true
  moveStart=timer.getMilliSecCounter()
 end
end

function on.charIn(ch)
 if ch=="6" then
  on.arrowRight()
 elseif ch=="4" then
  on.arrowLeft()
 end
end

function updateFPS()
 delay=timer.getMilliSecCounter()-lastTick
 delay=delay<300 and delay or 0
 lastTick=timer.getMilliSecCounter()
end
« Last Edit: November 27, 2011, 08:13:18 am by Chockosta »

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: [Lua] CubeField
« Reply #1 on: October 18, 2011, 12:38:59 pm »
Looks very nice :)
Quote
(BTW, my Nspire Computer Software free trial expired. Could someone just copy/paste and post the code on page 1.1 of the attached document ? Thanks.)
Do you mean that this is made in OcLua and that you need a "real" document?

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: [Lua] CubeField
« Reply #2 on: October 18, 2011, 12:41:32 pm »
Yes...
There is Levak's script, but I'm too lazy :P

(Moreover, I don't have time, I really sould do my homework :( )
« Last Edit: October 18, 2011, 12:42:07 pm by Chockosta »

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: [Lua] CubeField
« Reply #3 on: October 18, 2011, 12:47:35 pm »
Right now I'm not in windows, but I'll try to do it later. (or someone else might beat me)

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: [Lua] CubeField
« Reply #4 on: October 18, 2011, 02:17:09 pm »
Right now I'm not in windows, but I'll try to do it later. (or someone else might beat me)
And my Ubuntu 11.10 is out of order D:< (crappy video driver and crappy new ubuntu update and crappy dual screen ... have to reformat everything - cool story bro').
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline apcalc

  • The Game
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1393
  • Rating: +120/-2
  • VGhlIEdhbWUh (Base 64 :))
    • View Profile
Re: [Lua] CubeField
« Reply #5 on: October 18, 2011, 02:37:01 pm »
This looks quite impressive!  Good Luck! :)


Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Lua] CubeField
« Reply #6 on: October 18, 2011, 02:45:44 pm »
Is this like the CubeRunner game on the 83+? This definitively seems interesting nonetheless. I'm gonna give this a try as soon as possible.
« Last Edit: October 18, 2011, 03:00:44 pm by DJ_O »

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: [Lua] CubeField
« Reply #7 on: October 18, 2011, 02:51:48 pm »
Right now I'm not in windows, but I'll try to do it later. (or someone else might beat me)
And my Ubuntu 11.10 is out of order D:< (crappy video driver and crappy new ubuntu update and crappy dual screen ... have to reformat everything - cool story bro').

Forget about 11.10, just use 11.04 with classic desktop, much better :)
« Last Edit: October 18, 2011, 02:52:09 pm by jimbauwens »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Lua] CubeField
« Reply #8 on: October 18, 2011, 03:00:49 pm »
Actually nvm it's not even in executable form. Can someone compile it?

Offline Stefan Bauwens

  • Creator of Myst 89 - סטיבן
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1799
  • Rating: +162/-24
  • 68k programmer
    • View Profile
    • Portfolio
Re: [Lua] CubeField
« Reply #9 on: October 18, 2011, 03:08:50 pm »
This looks very cool. I hope Jim puts it on his calc and lets me try it. :)


Very proud Ticalc.org POTY winner (2011 68k) with Myst 89!
Very proud TI-Planet.org DBZ winner(2013)

Interview with me

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: [Lua] CubeField
« Reply #10 on: October 18, 2011, 03:54:43 pm »
Here is a non encrypted one, my luna refused to work, and the Ti-Nspire Student Software freaked out.

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: [Lua] CubeField
« Reply #11 on: October 18, 2011, 04:20:50 pm »
Here it is :
(found a laptop running under linux)
Code: [Select]
cubesX={1,5,7,6,4,6,4,1,3,2,3,7,8,9,1,2,3,4,2,6,7,1,9,1,2,3,4}
cubesY={1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,&lt;nod;/node&gt;
 cubesY[i]=cubesY[i]+step
 if cubesY[i]>10 then
 cubesX[i]=math.random(10,140)/10+player
 cubesY[i]=1
 end
 end
end

function updateMove()
 if moving then
 player=player+0.04*dir
 if timer.getMilliSecCounter()-moveStart>=150 then
 moving=false
 end
 end
end

function drawPlayer(gc)
 if not menu then
 --gc:drawImage(playerImg,149,192)
 gc:setColorRGB(100,100,100)
 gc:fillRect(149,192,20,20)
 end
end

function drawMenu(gc)
 if menu then
 gc:setColorRGB(0,0,0)
 gc:setFont("sansserif","r",30)
 gc:drawString("CubeField",80,10,"top")
 gc:setFont("sansserif","b",12)
 gc:drawString("Press Enter",115,150,"top")
 local highscore=var.recall("highscore")
 if not highscore then
 var.store("highscore",0)
 highscore=0
 end
 if score>highscore 7,7,8,8,8,9,9,9}
player=0
speed=0.05
moving=false
dir=1
moveStart=0
then
 var.store("highscore",score)
 document.markChanged()
 end
 local str="Score : "..tostring(score).." Highscore : "..tostring(highscore)
 gc:drawString(str,159-gc:getStringWidth(str)/2,100,"top")
 end
end

function drawScore(gc)
 if not menu then
 gc:setColorRGB(0,0,0)
 gc:setFont("sansserif","r",12)
 gc:drawString(tostring(score),2,0,"top")
 end
end

function levelUp()
 speed=speed+0.01
 level=level+1
 if (level-1)%5==0 then
 color={225,170,0}
 elseif (level-1)%5==1 then
 color={0,0,255}
 elseif (level-1)%5==2 then
 color={100,100,100}
 elseif (level-1)%5==3 then
 color={90,255,0}
 elseif (level-1)%5==4 then
 color={255,255,255}
 end
end

function on.paint(gc)
 render(gc)
 drawPlayer(gc)
 drawMenu(gc)
 drawScore(gc)&lt;t;&gt;menu=true
score=0
level=1
color={225,170,0}

function render(gc)
 &lt;leaf name=&quot;1word&quot;&g/node&gt;
 gc:setColorRGB(0,0,0)
 gc:setFont("sansserif","r",8)
 gc:drawString("Lua CubeField - Par Loic Pujet",10,200,"top")
 timer.start(0.01)
end

function on.timer()
 timer.stop()
 updateCubes()
 updateMove()
 if not menu then
 score=score+1
 if score%1000==0 then
 levelUp()
 end
 end
 platform.window:invalidate()
end

function on.escapeKey()
 menu=true
end

function on.enterKey()
 if menu then
 menu=false
 speed=0.05
 moving=false
 score=0
 level=1
 color={225,170,0}
 for i=1,27 do
 cubesY[i]=cubesY[i]-5
 end
 end
end

function on.arrowLeft()
 if not menu then
 dir=-1
 moving=true
 moveStart=timer.getMilliSecCounter()
&lt;leaf name=&quot;1word&quot;t;gc:setColorRGB(0,0,0)
 gc:drawLine(0,60,317,60)
 local size,x,y
 for i=1,27 do
 end
end

function on.arrowRight()
 if not menu then
 dir=1
 moving=true
 moveStart=timer.getMilliSecCounter()
 end
end&lt;ce=&quot;1word&quot;&gt;size=cubesY[i]*cubesY[i]/1.5+8
 x=(cubesX[i]-7-player)*20*(cubesY[i]*cubesY[i]/20+0.5)-size/2+160
 y=cubesY[i]*cubesY[i]*2+50
 if cubesY[i]>1 then
 gc:setColorRGB(color[1],color[2],color[3])
 gc:fillRect(x,y,size,size)
 gc:setColorRGB(0,0,0)
 gc:drawRect(x,y,size,size)
 end
 if cubesY[i]>7.5 and cubesY[i]<8.5 then
 if x<167 and x+size>151 then
 on.escapeKey()
 end
 end
 end
end

function updateCubes()
 local step=menu and 0.05 or speed
 for i=1,27 do
 cubesY[i]=cubesY[i]+step
 if cubesY[i]>10 then
 cubesX[i]=math.random(10,140)/10+player
 cubesY[i]=1
 end
 end
end

function updateMove()
 if moving then
 player=player+0.04*dir
 if timer.getMilliSecCounter()-moveStart>=150 then
 moving=false
 end
 end
end

function drawPlayer(gc)
 if not menu then
 --gc:drawImage(playerImg,149,192)
 gc:setColorRGB(100,100,100)
 gc:fillRect(149,192,20,20)
 end
end

function drawMenu(gc)
 if menu then
 gc:setColorRGB(0,0,0)
 gc:setFont("sansserif","r",30)
 gc:drawString("CubeField",80,10,"top")
 gc:setFont("sansserif","b",12)
 gc:drawString("Press Enter",115,150,"top")
 local highscore=var.recall("highscore")
 if not highscore then
 var.store("highscore",0)
 highscore=0
 end
 if score>highscore then
 var.store("highscore",score)
 document.markChanged()
 end
 local str="Score : "..tostring(score).." Highscore : "..tostring(highscore)
 gc:drawString(str,159-gc:getStringWidth(str)/2,100,"top")
 end
end

function drawScore(gc)
 if not menu then
 gc:setColorRGB(0,0,0)
 gc:setFont("sansserif","r",12)
 gc:drawString(tostring(score),2,0,"top")
 end
end

function levelUp()
 speed=speed+0.01
 level=level+1
 if (level-1)%5==0 then
 color={225,170,0}
 elseif (level-1)%5==1 then
 color={0,0,255}
 elseif (level-1)%5==2 then
 color={100,100,100}
 elseif (level-1)%5==3 then
 color={90,255,0}
 elseif (level-1)%5==4 then
 color={255,255,255}
 end
end

function on.paint(gc)
 render(gc)
 drawPlayer(gc)
 drawMenu(gc)
 drawScore(gc)
 gc:setColorRGB(0,0,0)
 gc:setFont("sansserif","r",8)
 gc:drawString("Lua CubeField - Par Loic Pujet",10,200,"top")
 timer.start(0.01)
end

function on.timer()
 timer.stop()
 updateCubes()
 updateMove()
 if not menu then
 score=score+1
 if score%1000==0 then
 levelUp()
 end
 end
 platform.window:invalidate()
end

function on.escapeKey()
 menu=true
end

function on.enterKey()
 if menu then
 menu=false
 speed=0.05
 moving=false
 score=0
 level=1
 color={225,170,0}
 for i=1,27 do
 cubesY[i]=cubesY[i]-5
 end
 end
end

function on.arrowLeft()
 if not menu then
 dir=-1
 moving=true
 moveStart=timer.getMilliSecCounter()
 end
end

function on.arrowRight()
 if not menu then
 dir=1
 moving=true
 moveStart=timer.getMilliSecCounter()
 end
end

Code: [Select]

playerImg=image.new("\\020\\000\\000\\000\\020\\000\\000\\000\\000\\000\\000\\000\\040\\000\\000\\000\\016\\000\\001\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\00me=&quot;1word&quot;/&gt;
function drawMenu(gc)
 if menu then
 gc:setColorRGB(0,0,0)
 00\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\000\\128\\000\\128\\000\\128\\000\\128\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\000\\128\\000\\128\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\000\\128\\000\\128\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\128\\151\\194\\151\\194\\000\\128\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\000\\128\\061\\215\\061\\215\\000\\128\\000\\128\\000\\128\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\000\\128\\000\\128")
« Last Edit: October 18, 2011, 04:21:18 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: [Lua] CubeField
« Reply #12 on: October 18, 2011, 10:07:58 pm »
Cuberunner! Looks great. Trying it right now :)

EDIT: Levak, your source has some broken HTML entities O.O

EDIT2: Managed to open up jimb's unencrypted version. Attached is an encrypted TNS made with Luna, and here's the source:
Spoiler For Lua source:
Quote from: Lua
cubesX={1,5,7,6,4,6,4,1,3,2,3,7,8,9,1,2,3,4,2,6,7,1,9,1,2,3,4}
cubesY={1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8,9,9,9}
player=0
speed=0.05
moving=false
dir=1
moveStart=0
menu=true
score=0
level=1
color={225,170,0}

function render(gc)
 gc:setColorRGB(0,0,0)
 gc:drawLine(0,60,317,60)
 local size,x,y
 for i=1,27 do
  size=cubesY[i]*cubesY[i]/1.5+8
  x=(cubesX[i]-7-player)*20*(cubesY[i]*cubesY[i]/20+0.5)-size/2+160
  y=cubesY[i]*cubesY[i]*2+50
  if cubesY[i]>1 then
   gc:setColorRGB(color[1],color[2],color[3])
   gc:fillRect(x,y,size,size)
   gc:setColorRGB(0,0,0)
   gc:drawRect(x,y,size,size)
  end
  if cubesY[i]>7.5 and cubesY[i]<8.5 then
   if x<167 and x+size>151 then
    on.escapeKey()
   end
  end
 end
end

function updateCubes()
 local step=menu and 0.05 or speed
 for i=1,27 do
  cubesY[i]=cubesY[i]+step
  if cubesY[i]>10 then
   cubesX[i]=math.random(10,140)/10+player
   cubesY[i]=1
  end
 end
end

function updateMove()
 if moving then
  player=player+0.04*dir
  if timer.getMilliSecCounter()-moveStart>=150 then
   moving=false
  end
 end
end

function drawPlayer(gc)
 if not menu then
  --gc:drawImage(playerImg,149,192)
  gc:setColorRGB(100,100,100)
  gc:fillRect(149,192,20,20)
 end
end

function drawMenu(gc)
 if menu then
  gc:setColorRGB(0,0,0)
  gc:setFont("sansserif","r",30)
  gc:drawString("CubeField",80,10,"top")
  gc:setFont("sansserif","b",12)
  gc:drawString("Press Enter",115,150,"top")
  local highscore=var.recall("highscore")
  if not highscore then
   var.store("highscore",0)
   highscore=0
  end
  if score>highscore then
   var.store("highscore",score)
   document.markChanged()
  end
  local str="Score : "..tostring(score).."              Highscore : "..tostring(highscore)
  gc:drawString(str,159-gc:getStringWidth(str)/2,100,"top")
 end
end

function drawScore(gc)
 if not menu then
  gc:setColorRGB(0,0,0)
  gc:setFont("sansserif","r",12)
  gc:drawString(tostring(score),2,0,"top")
 end
end

function levelUp()
 speed=speed+0.01
 level=level+1
 if (level-1)%5==0 then
  color={225,170,0}
 elseif (level-1)%5==1 then
  color={0,0,255}
 elseif (level-1)%5==2 then
  color={100,100,100}
 elseif (level-1)%5==3 then
  color={90,255,0}
 elseif (level-1)%5==4 then
  color={255,255,255}
 end
end

function on.paint(gc)
 render(gc)
 drawPlayer(gc)
 drawMenu(gc)
 drawScore(gc)
 gc:setColorRGB(0,0,0)
 gc:setFont("sansserif","r",8)
 gc:drawString("Lua CubeField - Par Loic Pujet",10,200,"top")
 timer.start(0.01)
end

function on.timer()
 timer.stop()
 updateCubes()
 updateMove()
 if not menu then
  score=score+1
  if score%1000==0 then
   levelUp()
  end
 end
 platform.window:invalidate()
end

function on.escapeKey()
 menu=true
end

function on.enterKey()
 if menu then
  menu=false
  speed=0.05
  moving=false
  score=0
  level=1
  color={225,170,0}
  for i=1,27 do
   cubesY[i]=cubesY[i]-5
  end
 end
end

function on.arrowLeft()
 if not menu then
  dir=-1
  moving=true
  moveStart=timer.getMilliSecCounter()
 end
end

function on.arrowRight()
 if not menu then
  dir=1
  moving=true
  moveStart=timer.getMilliSecCounter()
 end
end


Generated by the BBify'r (http://clrhome.tk/resources/bbify/)
EDIT3: This is really fun. Nice job!
« Last Edit: October 18, 2011, 10:28:11 pm by Deep Thought »




Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Lua] CubeField
« Reply #13 on: October 18, 2011, 11:16:01 pm »
I tried it now and it's really great. My only complaint is that sometimes some blocks that are farther appears on top of the closer ones. You might need to fix that. Also it would be cool if when turning, you could make everything more diagonal, like in the TI-84 Plus version (Axe):


Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: [Lua] CubeField
« Reply #14 on: October 19, 2011, 01:25:51 am »
This looks very nice. Any chance of a moving screenshot to see it in action?
EDIT: nvm I've created a screenshot myself using CalcCapture:

I don't know why the grey of the squares don't show up
« Last Edit: October 19, 2011, 02:43:50 am by Jonius7 »
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)