Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: Chockosta on October 18, 2011, 12:22:19 pm

Title: [Lua] CubeField
Post by: Chockosta 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  (http://www.omnimaga.org/index.php?action=dlattach;topic=10924.0;attach=10543) (modified 11/1/2011) (re-modified 11/27/2011)

(http://www.omnimaga.org/index.php?action=dlattach;topic=10924.0;attach=10386;image)
_________________
EDIT : 10/19/2011


Animated screenshot (thanks to Jonius7)
Spoiler For Spoiler:
(http://www.omnimaga.org/index.php?action=dlattach;topic=10924.0;attach=9935;image)

_________________
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:
(http://www.omnimaga.org/index.php?action=dlattach;topic=10924.0;attach=10010;image) (http://www.omnimaga.org/index.php?action=dlattach;topic=10924.0;attach=10011;image)

_________________
EDIT : 10/19/2011

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

Screenie :
(http://www.omnimaga.org/index.php?action=dlattach;topic=10924.0;attach=10137;image)

_________________
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 :
(http://www.omnimaga.org/index.php?action=dlattach;topic=10924.0;attach=10544;image)

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
Title: Re: [Lua] CubeField
Post by: Jim Bauwens 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?
Title: Re: [Lua] CubeField
Post by: Chockosta 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 :( )
Title: Re: [Lua] CubeField
Post by: Jim Bauwens 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)
Title: Re: [Lua] CubeField
Post by: Levak 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').
Title: Re: [Lua] CubeField
Post by: apcalc on October 18, 2011, 02:37:01 pm
This looks quite impressive!  Good Luck! :)
Title: Re: [Lua] CubeField
Post by: DJ Omnimaga 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.
Title: Re: [Lua] CubeField
Post by: Jim Bauwens 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 :)
Title: Re: [Lua] CubeField
Post by: DJ Omnimaga on October 18, 2011, 03:00:49 pm
Actually nvm it's not even in executable form. Can someone compile it?
Title: Re: [Lua] CubeField
Post by: Stefan Bauwens 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. :)
Title: Re: [Lua] CubeField
Post by: Jim Bauwens 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.
Title: Re: [Lua] CubeField
Post by: Levak 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")
Title: Re: [Lua] CubeField
Post by: Deep Toaster 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/ (http://clrhome.tk/resources/bbify/))
EDIT3: This is really fun. Nice job!
Title: Re: [Lua] CubeField
Post by: DJ Omnimaga 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):

(http://www.omnimaga.org/index.php?action=dlattach;topic=4550.0;attach=3797;image)
Title: Re: [Lua] CubeField
Post by: Jonius7 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
Title: Re: [Lua] CubeField
Post by: DJ Omnimaga on October 19, 2011, 02:47:58 am
Probablye due to the settings. They all need to be to 0 I think (contrast and stuff).
Title: Re: [Lua] CubeField
Post by: Jim Bauwens on October 19, 2011, 03:28:39 am
In case anyone wants to know how I got the source code (in Linux) :p
I opened his file with nspire_emu, and copied the source to the clipboard (of the device), and then use gcore to dump the memory of the entire nspire_emu process (fun).
Then I searched for some lua code and found the position in the dump. All I then did was copy and paste :D

(The built in memory dump function does not work for me)
Title: Re: [Lua] CubeField
Post by: Chockosta on October 19, 2011, 11:17:26 am
Thank you for the code !
And yeah, I need to fix 2 or 3 things.

DJ_O :
I really don't understand that bug...
NVM, fixed
And I'll try to make cubes more diagonal when you turn. It shouldn't be hard, but It will decrease the framerate a bit.

Jonius7 :
Thanks for the screenshot !
But it looks kinda weird... The framerate is really low and the grey squares don't show up...

Anyway, I'm going to add the TNS document and Jonius7's screenshot to the first post.
Could someone tell me if the document works for OS>=3.0.2 ?
Title: Re: [Lua] CubeField
Post by: DJ Omnimaga on October 19, 2011, 03:28:14 pm
I acutally made a screenshot, but it's in AVI format and doesn't run at the original frame rate. It's still the exact same speed as the game, though.
Title: Re: [Lua] CubeField
Post by: Jonius7 on October 19, 2011, 03:28:31 pm
I'm going to update the screenshot quite soon:
Title: Re: [Lua] CubeField
Post by: DJ Omnimaga on October 19, 2011, 03:32:33 pm
I appended my avi to the previous post. It's 2.21 MB. On calc the game runs at about 20-25 FPS, but the video runs at 15.

Btw can Lua display rotated cubes? If not, then it might be best to forget about my screen rotation idea lol. Else, maybe you can cheat like in Squidgetx game and simply display sprites of squares and display alternate ones when they're far away or rotating?
Title: Re: [Lua] CubeField
Post by: Jonius7 on October 19, 2011, 03:42:02 pm
Also another thing that could be added. In the original cubefield and the TI-84 version shown earlier, it starts with a corridor made out of cubes that the player travels through before entering the cubefield. Could this be implemented in the Lua version so it's not so easy to die instantly?

PS: I've uploaded the moving screenshot above.
Title: Re: [Lua] CubeField
Post by: Chockosta on October 19, 2011, 05:18:10 pm
DJ_O :
The function gc:fillPolygon() could be used, it would be quite easy.
Thanks for the avi btw !

Jonius7 :
The corridor would be harder... Well, I would have to create levels instead of random cubes. But I could do this.
And your latest screenie is great ! Thanks ! :)
Title: Re: [Lua] CubeField
Post by: Jonius7 on October 19, 2011, 06:12:27 pm
the corridor will only have to appear at certain times so from 0 - 150 score the corridor appears. Then maybe another one at 700 or something. You might have to extend where the black cubes come in from 1000 to maybe 1400. But the rest will be the same random cubes. I'm sure you can do this.
Title: Re: [Lua] CubeField
Post by: squidgetx on October 19, 2011, 06:30:40 pm
you can cheat like in Squidgetx game and simply display sprites of squares and display alternate ones when they're far away or rotating?

Heh heh. Basically, yeah XD
Title: Re: [Lua] CubeField
Post by: DJ Omnimaga on October 22, 2011, 10:57:53 pm
DJ_O :
The function gc:fillPolygon() could be used, it would be quite easy.
Thanks for the avi btw !

Jonius7 :
The corridor would be harder... Well, I would have to create levels instead of random cubes. But I could do this.
And your latest screenie is great ! Thanks ! :)
Yeah but can Lua actually display rotated polygons? If so, then that's epically awesome O.O
Title: Re: [Lua] CubeField
Post by: Levak on October 23, 2011, 04:01:13 am
DJ_O :
The function gc:fillPolygon() could be used, it would be quite easy.
Thanks for the avi btw !

Jonius7 :
The corridor would be harder... Well, I would have to create levels instead of random cubes. But I could do this.
And your latest screenie is great ! Thanks ! :)
Yeah but can Lua actually display rotated polygons? If so, then that's epically awesome O.O

gc:drawPoly({x1, y1, x2, y2, ... })
You can make your own rotation matrix, apply it and give the x, y couple result to drawPoly
Title: Re: [Lua] CubeField
Post by: Chockosta on October 23, 2011, 07:31:18 am
Update !

-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.

Should I keep my little square for the player or should I create a sprite ?

As usual, I've attached a TNS file which contains the code. Could someone please extract the code ?
Thanks !
Title: Re: [Lua] CubeField
Post by: Adriweb on October 23, 2011, 07:38:20 am
Here :

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,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

function render(gc)
 drawHorizon(gc)
 local size,x,y,i,polygon
 for j=1,27 do
  i=(j+lastCube-2)%27+1
  size=cubesY[i]*cubesY[i]/1.5+8
  x=(cubesX[i]-7-player)*20*(cubesY[i]*cubesY[i]/20+0.5)-size/2
  y=cubesY[i]*cubesY[i]*2-152
  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 cubesY[i]>7.5 and cubesY[i]<8.5 then
   if x<7 and x+size>-7 then
    on.escapeKey()
   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
  if cubesY[i]>10 then
   if score%1000<800 then
    cubesX[i]=math.random(10,140)/10+player
   else
    cubesX[i]=math.random(10,140)/100+player+(i-1)%2*5+4
   end
   cubesY[i]=1
   lastCube=lastCube==1 and 27 or lastCube-1
  end
 end
end

function updateMove()
 if moving then
  player=player+0.07*dir
  if math.abs(rotation)<0.1 then
   rotation=rotation-0.005*dir
  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)
  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 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(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")
 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.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


Very smooth game :)

and ...
(http://i.imgur.com/aELpAs.jpg) (http://imgur.com/aELpA)


but wait... you did all that oncalc ?
(NO WAY ?)

if so, I definitely can do something for you .... ( ;-)  )
Title: Re: [Lua] CubeField
Post by: Chockosta on October 23, 2011, 07:40:46 am
Thanks a lot !
And yes, I entirely did that on-calc. (Just love on-calc programming)

What can you do for me ? :)
Title: Re: [Lua] CubeField
Post by: Adriweb on October 23, 2011, 07:44:11 am
a nice surprise :)
I'll send you an email soon.

btw, I just looked at the code, it's pretty good programming :D

congratz :)



(btw : I won't tell how I extracted the code... :D buzz buzz buzz)
Title: Re: [Lua] CubeField
Post by: Chockosta on October 23, 2011, 07:55:02 am
Thanks :)

(And I'm very curious!)

EDIT : Oh, and by the way, the latest release is available here (http://www.omnimaga.org/index.php?action=dlattach;topic=10924.0;attach=10006)
Title: Re: [Lua] CubeField
Post by: Chockosta on October 23, 2011, 02:21:47 pm
Sorry for double-posting, but...

Update ! (again)

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

I just modified the source which Adriweb gave to me, so no need to extract the code this time.

I think this is the final release...
Jonius7, could you please do another animated screenshot ? :)

Final source code :
Spoiler For Spoiler:
Quote from: Lua
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.1
moving=false
dir=1
moveStart=0
menu=true
score=0
level=1
color={225,170,0}
rotation=0

function render(gc)
 drawHorizon(gc)
 local size,x,y,i,polygon
 for j=1,27 do
  i=(j+lastCube-2)%27+1
  size=cubesY[i]*cubesY[i]/1.5+8
  x=(cubesX[i]-7-player)*20*(cubesY[i]*cubesY[i]/20+0.5)-size/2
  y=cubesY[i]*cubesY[i]*2-152
  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 cubesY[i]>7.5 and cubesY[i]<8.5 then
   if x<7 and x+size>-7 then
    on.escapeKey()
   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
  if cubesY[i]>10 then
   if score%1000<800 then
    cubesX[i]=math.random(10,140)/10+player
   else
    cubesX[i]=math.random(10,140)/200+player+(i-1)%2*5+4.1
   end
   cubesY[i]=1
   lastCube=lastCube==1 and 27 or lastCube-1
  end
 end
end

function updateMove()
 if moving then
  player=player+0.07*dir
  if math.abs(rotation)<0.1 then
   rotation=rotation-0.005*dir
  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)
  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(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")
 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.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

Generated by the BBify'r (http://clrhome.tk/resources/bbify/ (http://clrhome.tk/resources/bbify/))


DOWNLOAD (http://www.omnimaga.org/index.php?action=dlattach;topic=10924.0;attach=10009)
Title: Re: [Lua] CubeField
Post by: DJ Omnimaga on October 23, 2011, 02:31:37 pm
Wow pretty nice and I like the new sprite. It reminds me the 84+ one now. I'll try it soon. :D


EDIT: I like the update, also my highscore is 3260 :P
Title: Re: [Lua] CubeField
Post by: Levak on October 23, 2011, 02:43:00 pm
I've just tested and it is quite nice =)

the only thing I would say is that the paralax is a bit strange. Closer objects are going slower than Far ones. It is a bit difficult to go between to cubes along Z axis (forward).

You really well managed game-events (speed up), but I think you better make it faster to come, don't you think ?

I haven't looked at the code yet.
Title: Re: [Lua] CubeField
Post by: Chockosta on October 23, 2011, 05:20:35 pm
My highscore with the latest version is 5064...

And yes, my 3D projection may look strange... I made it very quickly.
And you think that the speed up should come faster ? I usually reach at least the third level...
Title: Re: [Lua] CubeField
Post by: DJ Omnimaga on October 23, 2011, 08:24:41 pm
I've just tested and it is quite nice =)

the only thing I would say is that the paralax is a bit strange. Closer objects are going slower than Far ones. It is a bit difficult to go between to cubes along Z axis (forward).

You really well managed game-events (speed up), but I think you better make it faster to come, don't you think ?

I haven't looked at the code yet.
Yeah I noticed that too. Sometimes I find myself going between two blocks, expecting to pass through, but the area becomes narrower and narrower, then I die.

As for speed I think maybe starting the speed of 1000 pts at 0 might be best, so the 1000 pts won't take too long to come.
Title: Re: [Lua] CubeField
Post by: Deep Toaster on October 23, 2011, 08:29:55 pm
the only thing I would say is that the paralax is a bit strange. Closer objects are going slower than Far ones. It is a bit difficult to go between to cubes along Z axis (forward).
Yeah I noticed that too. Sometimes I find myself going between two blocks, expecting to pass through, but the area becomes narrower and narrower, then I die.[/quote]Same. Remember that close objects are supposed to approach faster, or they seem to slow down.
Title: Re: [Lua] CubeField
Post by: Jonius7 on October 24, 2011, 06:35:32 am
Sorry for double-posting, but...

Update ! (again)

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

I just modified the source which Adriweb gave to me, so no need to extract the code this time.

I think this is the final release...
Jonius7, could you please do another animated screenshot ? :)

Final source code :
Spoiler For Spoiler:
Quote from: Lua
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.1
moving=false
dir=1
moveStart=0
menu=true
score=0
level=1
color={225,170,0}
rotation=0

function render(gc)
 drawHorizon(gc)
 local size,x,y,i,polygon
 for j=1,27 do
  i=(j+lastCube-2)%27+1
  size=cubesY[i]*cubesY[i]/1.5+8
  x=(cubesX[i]-7-player)*20*(cubesY[i]*cubesY[i]/20+0.5)-size/2
  y=cubesY[i]*cubesY[i]*2-152
  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 cubesY[i]>7.5 and cubesY[i]<8.5 then
   if x<7 and x+size>-7 then
    on.escapeKey()
   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
  if cubesY[i]>10 then
   if score%1000<800 then
    cubesX[i]=math.random(10,140)/10+player
   else
    cubesX[i]=math.random(10,140)/200+player+(i-1)%2*5+4.1
   end
   cubesY[i]=1
   lastCube=lastCube==1 and 27 or lastCube-1
  end
 end
end

function updateMove()
 if moving then
  player=player+0.07*dir
  if math.abs(rotation)<0.1 then
   rotation=rotation-0.005*dir
  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)
  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(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")
 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.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

Generated by the BBify'r (http://clrhome.tk/resources/bbify/ (http://clrhome.tk/resources/bbify/))


DOWNLOAD (http://www.omnimaga.org/index.php?action=dlattach;topic=10924.0;attach=10009)

I shall do so, may need to w8 a while though.
and yes from DJ_O and DT, there is this gap oftentimes which should look passable, but instead the precision of moving left and right isn't great and BAM! game over.
Title: Re: [Lua] CubeField
Post by: Chockosta on October 24, 2011, 07:10:02 am
You guys are right, I have to correct that.
(So Jonius7, please wait a bit before recording your screenshot :) )

EDIT :

This "bug" comes from an annoying problem (see attachment)
I really don't know how could I fix that.
Title: Re: [Lua] CubeField
Post by: Hayleia on October 24, 2011, 08:20:27 am
Yeah ! a DoorsCS sprite :w00t:

My highscore with the latest version is 5064...
1109 D:

and yes from DJ_O and DT, there is this gap oftentimes which should look passable, but instead the precision of moving left and right isn't great and BAM! game over.
Also, could you please add that the movement can be controlled by the keys 4 and 6 ? Because Athéna's touchpad won't let me play with my fingers always on it :( Done
Another problem that may not be fixable is the delay with the keys. You know, when you press left, it goes left a bit, then comes back, then goes left a lot, instead of going left a lot from the beginning.

Anyway, great work !!! :D
Title: Re: [Lua] CubeField
Post by: Chockosta on October 24, 2011, 08:26:27 am
You can control with 4/6, can't you ?

Anyway, thanks!
Title: Re: [Lua] CubeField
Post by: Hayleia on October 24, 2011, 08:32:11 am
/me is stupid.
Yes I can. I was just so excited by your game that I quitted the emulator (without trying 4 and 6) to tell you that you are awesome and then thought it would be great to have 4 and 6 while posting, so I said it XD. Sorry.
Title: Re: [Lua] CubeField
Post by: Chockosta on October 24, 2011, 08:58:10 am
No problem :)

And the key delay is a huge problem, but this is caused by TI's Lua framework. I tried to make the movement smooth, but this is the best I can do.
Title: Re: [Lua] CubeField
Post by: Chockosta on October 31, 2011, 07:14:07 am
Okay, it should look better now.
Could someone try it and tell me if the 3D projection is realistic ?

DOWNLOAD (http://www.omnimaga.org/index.php?action=dlattach;topic=10924.0;attach=10136)

Spoiler For code:
Quote from: Lua
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.1
moving=false
dir=1
moveStart=0
menu=true
score=0
level=1
color={225,170,0}
rotation=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
   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
  if cubesY[i]>10 then
   if score%1000<800 then
    cubesX[i]=math.random(10,140)/10+player
   else
    cubesX[i]=math.random(10,140)/200+player+(i-1)%2*5+4.1
   end
   cubesY[i]=1
   lastCube=lastCube==1 and 27 or lastCube-1
  end
 end
end

function updateMove()
 if moving then
  player=player+0.07*dir
  if math.abs(rotation)<0.15 or dir==rotation/math.abs(rotation) then
   rotation=rotation-0.005*dir
  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)
  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(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")
 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.enterKey()
 if menu then
  menu=false
  speed=0.1
  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

Generated by the BBify'r (http://clrhome.tk/resources/bbify/ (http://clrhome.tk/resources/bbify/))
Title: Re: [Lua] CubeField
Post by: Yeong on October 31, 2011, 07:17:17 am
It's awesome but the key responding is kinda bad D:
Title: Re: [Lua] CubeField
Post by: Chockosta on October 31, 2011, 07:19:06 am
Is that just because of stupid TI's key input, or is it worse than previous versions ?
Title: Re: [Lua] CubeField
Post by: Yeong on October 31, 2011, 07:20:35 am
I don't think it's worse than a previous version.
also, 3d stuff is nice :D
Title: Re: [Lua] CubeField
Post by: Deep Toaster on October 31, 2011, 06:17:59 pm
It's awesome but the key responding is kinda bad D:
Not his fault. Nspire Lua doesn't repeat keypresses at all.
Title: Re: [Lua] CubeField
Post by: Jim Bauwens on October 31, 2011, 06:19:03 pm
IIRC it repeats the arrows.
Title: Re: [Lua] CubeField
Post by: Deep Toaster on October 31, 2011, 06:25:14 pm
You're right, my bad. There's a horrible pause though :(
Title: Re: [Lua] CubeField
Post by: Yeong on October 31, 2011, 06:26:48 pm
so that key problem won't be solved until ndless 3?
Title: Re: [Lua] CubeField
Post by: Jim Bauwens on October 31, 2011, 06:28:11 pm
Or possibly an OS update :)
Title: Re: [Lua] CubeField
Post by: Deep Toaster on October 31, 2011, 07:00:34 pm
so that key problem won't be solved until ndless 3?
Ndless doesn't affect Lua at all, does it?
Title: Re: [Lua] CubeField
Post by: Yeong on October 31, 2011, 07:03:55 pm
I mean by continuous keypress generally.
since Lua can't do it D:
Title: Re: [Lua] CubeField
Post by: Chockosta on November 01, 2011, 05:49:49 am
So do you think my game is ready to be uploaded on ticalc.org and TI-planet ?
Title: Re: [Lua] CubeField
Post by: Deep Toaster on November 01, 2011, 09:35:44 am
Yep, it's great :)

Maybe throw in a readme?
Title: Re: [Lua] CubeField
Post by: Chockosta on November 01, 2011, 01:26:30 pm
Since english is my second language, my readmes look pathetic.
Here is the one that I have written for this game :
Code: (readme) [Select]
CUBEFIELD

|-------------------------------------------------------------------------------|
|FRANCAIS |
|-------------------------------------------------------------------------------|
| Touches : |
|Flèches ou 4/6 : se déplacer |
|-------------------------------------------------------------------------------|
|Ceci est un jeu inspiré de CubeRunner (pour téléphones), écrit en Lua (OS>3) |
|Survivez aussi longtemps que possible sans rentrer dans les cubes ! |
|Tous les 1000 points, un couloir annonce le passage au nivau suivant, où la |
|vitesse augmente. |
|-------------------------------------------------------------------------------|

|-------------------------------------------------------------------------------|
|ENGLISH |
|-------------------------------------------------------------------------------|
| Keys :    |
|Arrows or 4/6 : move |
|-------------------------------------------------------------------------------|
|This is a game inspired by CubeRunner (for smartphones), written in Lua (OS>3) |
|Survive as long as you can without getting hit by the cubes! |
|Every 1000 points, a corridor appears to introduce the next level, where the |
|speed icreases. |
|-------------------------------------------------------------------------------|

|-------------------------------------------------------------------------------|
|Loïc Pujet (Chockosta), 2011 |
|-------------------------------------------------------------------------------|

Is there any mistake ?
Title: Re: [Lua] CubeField
Post by: Hayleia on November 01, 2011, 01:36:08 pm
I think that you should write "Survive as long as you can without getting hitten by the cubes!" but an answer from someone whose first language is English would be better ;D

EDIT: nope, that was an epic fail from me D:
EDIT 2: Lol I really said hitten ?
EDIT 2.5: must have been confused with hidden and eaten maybe
EDIT 3: Next time I'll say hited :P
Title: Re: [Lua] CubeField
Post by: JosJuice on November 01, 2011, 01:41:48 pm
I think that you should write "Survive as long as you can without getting hitten by the cubes!" but an answer from someone whose first language is English would be better ;D
"getting hit" is correct. There don't seem to be any problems with the readme.
(English isn't my first language either, though :P)
Title: Re: [Lua] CubeField
Post by: Chockosta on November 01, 2011, 01:44:21 pm
Hayleia :
Haven't you learnt the irregular verbs ?
(j/k :D )

Okay, I'll upload it
Title: Re: [Lua] CubeField
Post by: Hayleia on November 01, 2011, 01:47:11 pm
Hayleia :
Haven't you learnt the irregular verbs ?
(j/k :D )

Okay, I'll upload it
I learnt them a long time ago, (hit/hit/hit) but now, in English class, we learn to discuss about topics, we don't learn to speak anymore D:
Title: Re: [Lua] CubeField
Post by: Chockosta on November 01, 2011, 02:08:51 pm
Oh, by the way, here is the final archive...
Title: Re: [Lua] CubeField
Post by: DJ Omnimaga on November 01, 2011, 03:43:10 pm
Nice to see it finished. :D

Are you also planning to upload it in Omnimaga archives Chokosta by the way?

Also I need to write a news when I have time, although lately there was a huge rush of Casio game releases so I've been busy. :P
Title: Re: [Lua] CubeField
Post by: Keoni29 on November 01, 2011, 03:44:22 pm
What's next? Starwing???
Title: Re: [Lua] CubeField
Post by: Yeong on November 01, 2011, 03:44:55 pm
Final Fantasy.
/me runs
Title: Re: [Lua] CubeField
Post by: Keoni29 on November 01, 2011, 03:46:22 pm
Final Fantasy.
/me runs
Hmm probably not. Starwing is doable. (put an FX chip in your nspire!!)
Title: Re: [Lua] CubeField
Post by: DJ Omnimaga on November 01, 2011, 04:07:42 pm
Well he might want to rename it to Star Fox if he does that or include both name in the readme, since a lot of Nspire users are from United States (and Starwing in USA is called Star Fox).  It could be possible if he manages to gain a decent framerate out of his 3D engine. Else he could do Space Dementia, which is similar but has no floor nor building obstacles.

Final Fantasy type games tend to be rather hard for someone who only made arcade games before. Usually people will only do one of both, although a CX RPG is definitively doable (after all I did 23 RPGs on the 83+ I think)
Title: Re: [Lua] CubeField
Post by: Chockosta on November 02, 2011, 02:36:20 pm
Are you also planning to upload it in Omnimaga archives Chokosta by the way?
Oh, I always forget to upload my games on Omni. (Don't know why :) )
Yes, I'll submit it.

Well he might want to rename it to Star Fox if he does that or include both name in the readme, since a lot of Nspire users are from United States (and Starwing in USA is called Star Fox).  It could be possible if he manages to gain a decent framerate out of his 3D engine. Else he could do Space Dementia, which is similar but has no floor nor building obstacles.

Final Fantasy type games tend to be rather hard for someone who only made arcade games before. Usually people will only do one of both, although a CX RPG is definitively doable (after all I did 23 RPGs on the 83+ I think)
Yes, I really should use my 3D engine... Space Dementia/StarFox is a good idea :)

And I never coded a RPG. I might be able to do it, but yes, it would be quite hard fore an arcade-games-coder like me.
Title: Re: [Lua] CubeField
Post by: DJ Omnimaga on November 11, 2011, 11:17:08 pm
The problem with RPGs is that most people start too big. For a first RPG you need to have only one dungeon and maybe 3-4 different attacks and one enemy. Even then, you need to have played actual SNES/PS1 RPGs for years to grasp the RPG concept and make one. I hope you eventually start working on your 3D engine again or do something with it. :)
Title: Re: [Lua] CubeField
Post by: Jonius7 on November 17, 2011, 12:53:03 am
It's been a while but I'll see if i can make a moving screenshot today. after i get home.
Title: Re: [Lua] CubeField
Post by: Jonius7 on November 17, 2011, 04:43:06 am
Sry double post but here is my moving screenie of 3d cubefield! It goes into the 3rd zone of cubes so that should be enough of a preview.
Title: Re: [Lua] CubeField
Post by: Stefan Bauwens on November 17, 2011, 05:30:49 am
That looks very nice. Thanks for that screenie.
Title: Re: [Lua] CubeField
Post by: Chockosta on November 17, 2011, 01:00:07 pm
Thanks a lot !
This looks awesome.
Title: Re: [Lua] CubeField
Post by: Jonius7 on November 18, 2011, 11:56:15 pm
Oh and just to comment, your game has had lots of improvements since i last saw it.
well done for adding the corridors and diagonal slanting and the arrow sprite. Looks great!
Title: Re: [Lua] CubeField
Post by: Chockosta on November 23, 2011, 10:22:45 am
Bump !

I just received my CX CAS (Yay !), and I noticed that this game was painfully slow on CX.
So I modified it to adjust the speed to the CX. The speed didn't change for grayscale nspires.

Could anyone tell me if this is too hard (on a CX) ?
PS : I managed to reach 9100 points !

Title: Re: [Lua] CubeField
Post by: Jim Bauwens on November 23, 2011, 10:26:33 am
I would try to do some tricks with optimizing functions, like localizing variables and stuff like that.
If there are some images that can easily be replaced with fillRect and stuff like that, do it!
Title: Re: [Lua] CubeField
Post by: Chockosta on November 23, 2011, 10:37:57 am
I don't use images.
I only use fillPolygon...

And localisation, on the nSpire, seems to be less useful than on PC.
Title: Re: [Lua] CubeField
Post by: Jim Bauwens on November 23, 2011, 10:40:33 am
Oh wait
I was thinking of bobby carrot :p

Localization really does allot for me ;)
Anyway, try to look if there is any code that can be simplified, like calculations.
I'll take a look at the source too.

Edit:
Can you share the source :D
Title: Re: [Lua] CubeField
Post by: Chockosta on November 27, 2011, 08:01:03 am
Oh, I haven't seen your edit ! Sorry...

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

The new release is attached, with a color screenshot...

Here is the source :
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
Title: Re: [Lua] CubeField
Post by: Jim Bauwens on November 28, 2011, 03:27:16 am
What I do in my code if I use a table value quite often in function is localize it (local x = cubes[x ]).
This way accessing the variable is much faster.

And it really helps ;)
Title: Re: [Lua] CubeField
Post by: Chockosta on November 28, 2011, 12:05:38 pm
Thats a really useful habit. (+1)

I haven't anymore speed problems with CubeField, but this will help me for other projects.
I will try to remember that. Thanks. :)
Title: Re: [Lua] CubeField
Post by: Jim Bauwens on November 29, 2011, 06:59:42 am
Thanks :)
I'm glad that you have solved all your issue's too :)
Title: Re: [Lua] CubeField
Post by: DJ Omnimaga on December 25, 2011, 10:12:51 pm
I like the new update. Two suggestions I got are:

-Allow going behind blocks. Right now we have to wait until we're about 4 steps away from a block before being able to move behind it, else we die.
-Add a minimum value for the space between the two blocks appearing at once, so we don't end up stuck in dead-ends as much or without enough space to go between two blocks.
Title: Re: [Lua] CubeField
Post by: Jonius7 on January 17, 2012, 02:01:17 am
-Add a minimum value for the space between the two blocks appearing at once, so we don't end up stuck in dead-ends as much or without enough space to go between two blocks.
I think the original cubefield allowed cubes to get as close as touching edges with each other, but not overlapping. That could be something to consider.
Title: Re: [Lua] CubeField
Post by: Chockosta on January 17, 2012, 01:24:18 pm
-Allow going behind blocks. Right now we have to wait until we're about 4 steps away from a block before being able to move behind it, else we die.
This would be quite hard to do. I would have to change my collision detection. And since my blocks are squares and not cubes, they dont have a defined thickness. (I'm not sure this is the correct word)
-Add a minimum value for the space between the two blocks appearing at once, so we don't end up stuck in dead-ends as much or without enough space to go between two blocks.
This is possible, but I think it would possibly become too easy. I will test this.
Title: Re: [Lua] CubeField
Post by: AzNg0d1030 on January 18, 2012, 10:06:58 pm
Do you think using the 3D engine thing you've been using, that you could make the blocks 3D?
Also, do you plan on making the game so that in between the levels are those criss cross paths? (And then later the colors become black and green?)
Title: Re: [Lua] CubeField
Post by: Chockosta on January 19, 2012, 12:10:25 pm
My 3D engine is too slow for that, it wouldn't be a good idea to use it.

About criss cross paths, I can try... But now I'm working on others projects, so you have to wait a bit :)
Title: Re: [Lua] CubeField
Post by: AzNg0d1030 on January 20, 2012, 06:33:25 pm
My 3D engine is too slow for that, it wouldn't be a good idea to use it.

About criss cross paths, I can try... But now I'm working on others projects, so you have to wait a bit :)
Aw shnikeys
Title: Re: [Lua] CubeField
Post by: Jonius7 on February 09, 2012, 06:18:21 am
It is a great project that has been nicely done. I checked the other day, it is in the top 10 files downloaded in the last 7 days in the Ti-nspire section of ticalc.org. Well done!
Title: Re: [Lua] CubeField
Post by: hellninjas on February 15, 2012, 03:20:03 pm
I think I've played this more than I have blinked O.o
Title: Re: [Lua] CubeField
Post by: Jonius7 on February 16, 2012, 03:34:41 am
I haven't got a terribly high score on it, no. Only about 2000ish.
Title: Re: [Lua] CubeField
Post by: Chockosta on February 16, 2012, 08:37:05 am
Mine is 7043...
Title: Re: [Lua] CubeField
Post by: Jonius7 on February 22, 2012, 05:00:54 pm
In that case, I'll try again, and concentrate more!
Cuz I didn't play much else besides recording for those moving screenshots.