Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Adriweb

Pages: 1 ... 95 96 [97] 98 99 ... 115
1441
TI-Nspire / Re: [Lua] CubeField
« 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)

1442
TI-Nspire / Re: [Lua] CubeField
« 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 ...



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

if so, I definitely can do something for you .... ( ;-)  )

1443
Calculator C / Re: Timers in the Nspire
« on: October 22, 2011, 03:15:11 pm »
(although it's easier than C/native)

;)

1444
Lua / Re: TNS and ZIP file differences
« on: October 19, 2011, 10:12:26 am »
Extended has worked on that unknown 13 (0D field) compression algorithm (a part of the encryption has been patented and is thus public).

http://ndlessly.wordpress.com/2011/05/22/d-method-encryption-and-lua-hopes-for-os-3-0-2/
and
http://ndlessly.wordpress.com/2011/07/31/lua-to-tns-converter-a-little-bit-further/

He said that since he made a program to compress correctly (bypassing (and not breaking) the patented stuff, that's why it's not illegal), it wouldn't be so hard technically to build a de-compress tool.

1445
News / Re: The Launch of a new website : TI-Planet
« on: October 17, 2011, 02:48:17 pm »
I'm the one who made the iOS app ;)

It facilitates the access to the website (especially now with the mobile version), but it's mainly a news reader, that parses quite well the news from the RSS.
On the next version, there's social integration etc.

btw, it's already got something like 300 downloads ;)

1446
Lua / Re: Platform-specific Problem
« on: October 14, 2011, 07:20:59 am »
About that gc thing, jim'post is exactly what to read and learn.

The reason platform.gc() is not recommended is that it's actually going to be gone (kind of) in future version of the lua API.
So please, use the gc passed by on.paint(gc), as Jim showed you.

the reason platform.gc() was created and made available in the first place was to be able to access some primary functions like string length etc. (getStringWidth...) before the on.paint event....

1447
Lua / Re: Platform-specific Problem
« on: October 13, 2011, 06:11:31 pm »
Here are several things you might want to pay attention to :

- Don't use platform.gc(): as your standard GC context (only use the on passed in the on.paint(gc) event).
- Make sure you refresh the drawing buffer often enough. That might be the real problem of yours, here. Actually, the software refreshes constantly, contraty to the device, which refrehes only when needed or when it's asked. So make sure that when you want to draw something and update the screen consequently, call platform.window:invalidate().


About your 2nd question, the code would indeed be needed...

Good Luck ;)

1448
Lua / Re: Oh Nspire-Lua, you so crazy!
« on: October 08, 2011, 05:54:09 pm »
Interesting.

I've come across things like this but it appears that TI fixed most of these memory-hacking stuff (in the upcoming version).



I can also assume you're right about direc tmemory reading and somehintg like forcing a cast to a string output, with the correspondig ascii code being some chinese chars.....


Can you see more of the memory by dumping it thourgh nspire_emu / ncubate and try to see what could match with the chinese char's ascii number ?

1449
Lua / Re: MoonScript for Nspire
« on: October 02, 2011, 04:51:33 pm »
Awesome !

Definitely going to check this out :)

1450
General Calculator Help / Re: Non-Cas to CAS
« on: September 28, 2011, 10:58:02 am »
Not even sure that it will work when Ndless 3 get released.
It will need a lot of work if it's ever re-done.

And while OSLauncher is a technical achievment for the community, it' also dangerou, both for TI and u, cince the exams acceptances institutions would want to ban the Nspire (even the non-cas) in order to be sure nobody gets the CAS on their calc. And then TI would probably stop developing the Nspires as we see them now.
Then that'd be a shame don't you think ?

Hope you see my point.

1451
TI Z80 / Re: Chemix
« on: September 27, 2011, 01:33:18 pm »
Nice project :)

(btw, my school - engineer school - doesn't allow calculators at all, for any tests or whatever)

1452
TI-Nspire / Re: [Lua] Traductor
« on: September 26, 2011, 01:59:04 pm »
www.wordreference.com is by far my favorite translation (not translator :P) website.

1453
TI-Nspire / Re: [Lua] Tiny3D
« on: September 26, 2011, 01:57:34 pm »
nice ! :D

1454
nice !

Making a third-party SDK for reading/writing .tns is getting closer I think :P

Might not be done at all, but it could have a great potential, I'm sure....

1455
Lua / Re: Те́трис, anyone?
« on: September 25, 2011, 12:32:41 pm »
Among other examples, you can find a Lua tetris here (at the bottom) :

http://www.compasstech.com.au/TNS_Authoring/Scripting/

For tutorials, go to : http://www.inspired-lua.org

Pages: 1 ... 95 96 [97] 98 99 ... 115