Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
18 June, 2013, 06:33:35 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1] 2 3 ... 7   Go Down
  Print  
Author Topic: [Lua] CubeField -  (Read 4508 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
Chockosta
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Male
Last Login: 14 June, 2013, 19:48:20
Date Registered: 03 June, 2011, 20:14:17
Location: France
Posts: 443


Topic starter
Total Post Ratings: +159

View Profile
« on: 18 October, 2011, 18:22:19 »
+5

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 Tongue
When you reach 1000, 2000, 3000... points, the speed increases and the colors change.
The 3D projection is not really realistic, I'll have to work on it.
And I also have to add a nice sprite for the player's ship.

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



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


_________________
EDIT : 10/19/2011


Animated screenshot (thanks to Jonius7)
Spoiler for Hidden:

_________________
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 Hidden:

_________________
EDIT : 10/19/2011

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

Screenie :


_________________
EDIT : 10/19/2011

Yet another final version

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

Color screenie :


Code :
Spoiler for Hidden:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
playerImg=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\128\000\128\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\128\000\128")

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Chockosta (Loic Pujet) - Sorry for my poor English...
Look at my projects :
in C code : Periodic table, Space invaders, Fall, Snake, Minesweeper, nCraft (WIP)
in Lua : Snake, Space invaders, Bobby Carrot, Minesweeper, Mazes 3D, nSpaint, FreeCell, Tiny3D-Viewer, CubeField, Gravity Guy
Jim Bauwens
Lua! Nspire! Linux!
Editor
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 00:06:13
Date Registered: 28 February, 2011, 22:32:12
Location: Belgium
Posts: 1736


Total Post Ratings: +180

View Profile WWW
« Reply #1 on: 18 October, 2011, 18:38:59 »
0

Looks very nice Smiley
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?
Logged

Chockosta
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Male
Last Login: 14 June, 2013, 19:48:20
Date Registered: 03 June, 2011, 20:14:17
Location: France
Posts: 443


Topic starter
Total Post Ratings: +159

View Profile
« Reply #2 on: 18 October, 2011, 18:41:32 »
0

Yes...
There is Levak's script, but I'm too lazy Tongue

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

Chockosta (Loic Pujet) - Sorry for my poor English...
Look at my projects :
in C code : Periodic table, Space invaders, Fall, Snake, Minesweeper, nCraft (WIP)
in Lua : Snake, Space invaders, Bobby Carrot, Minesweeper, Mazes 3D, nSpaint, FreeCell, Tiny3D-Viewer, CubeField, Gravity Guy
Jim Bauwens
Lua! Nspire! Linux!
Editor
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 00:06:13
Date Registered: 28 February, 2011, 22:32:12
Location: Belgium
Posts: 1736


Total Post Ratings: +180

View Profile WWW
« Reply #3 on: 18 October, 2011, 18:47:35 »
0

Right now I'm not in windows, but I'll try to do it later. (or someone else might beat me)
Logged

Levak
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: Yesterday at 23:24:38
Date Registered: 04 April, 2010, 23:42:49
Location: France
Posts: 858


Total Post Ratings: +150

View Profile WWW
« Reply #4 on: 18 October, 2011, 20:17:09 »
0

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 Big frown< (crappy video driver and crappy new ubuntu update and crappy dual screen ... have to reformat everything - cool story bro').
Logged

Human always wants to survive and that's why he will fall one day.
My website - TI-Planet - iNspired-Lua
apcalc
The Game
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 01:07:09
Date Registered: 20 March, 2010, 16:31:47
Location: 2003 UB313
Posts: 1393


Total Post Ratings: +118

View Profile
« Reply #5 on: 18 October, 2011, 20:37:01 »
0

This looks quite impressive!  Good Luck! Smiley
Logged


DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Online Online

Gender: Male
Last Login: Today at 06:33:15
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50586


Total Post Ratings: +2634

View Profile WWW
« Reply #6 on: 18 October, 2011, 20:45:44 »
0

Is this like the CubeRunner game on the 83+? This definitively seems interesting nonetheless. I'm gonna give this a try as soon as possible.
« Last Edit: 18 October, 2011, 21:00:44 by DJ_O » Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
Jim Bauwens
Lua! Nspire! Linux!
Editor
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 00:06:13
Date Registered: 28 February, 2011, 22:32:12
Location: Belgium
Posts: 1736


Total Post Ratings: +180

View Profile WWW
« Reply #7 on: 18 October, 2011, 20:51:48 »
0

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 Big frown< (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 Smiley
« Last Edit: 18 October, 2011, 20:52:09 by jimbauwens » Logged

DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Online Online

Gender: Male
Last Login: Today at 06:33:15
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50586


Total Post Ratings: +2634

View Profile WWW
« Reply #8 on: 18 October, 2011, 21:00:49 »
0

Actually nvm it's not even in executable form. Can someone compile it?
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
Stefan Bauwens
Creator of Myst 89 - סטיבן
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Yesterday at 21:57:50
Date Registered: 25 February, 2011, 15:41:10
Location: Belgium
Posts: 1744


Total Post Ratings: +134

View Profile WWW
« Reply #9 on: 18 October, 2011, 21:08:50 »
0

This looks very cool. I hope Jim puts it on his calc and lets me try it. Smiley
Logged

Jim Bauwens
Lua! Nspire! Linux!
Editor
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 00:06:13
Date Registered: 28 February, 2011, 22:32:12
Location: Belgium
Posts: 1736


Total Post Ratings: +180

View Profile WWW
« Reply #10 on: 18 October, 2011, 21:54:43 »
0

Here is a non encrypted one, my luna refused to work, and the Ti-Nspire Student Software freaked out.

* cube.tns (1.75 KB - downloaded 16 times.)
Logged

Levak
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: Yesterday at 23:24:38
Date Registered: 04 April, 2010, 23:42:49
Location: France
Posts: 858


Total Post Ratings: +150

View Profile WWW
« Reply #11 on: 18 October, 2011, 22:20:50 »
0

Here it is :
(found a laptop running under linux)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
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


1
2
3
4
5
6
7

playerImg=image.new("\\020\\000\\000\\000\\020\\000\\000\\000\\000\\000\\000\\000\\040\\000\\000\\000\\016\\000\\001\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\00me=&quot;1word&quot;/&gt;
function drawMenu(gc)
 if menu then
 gc:setColorRGB(0,0,0)
 00\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\151\\194\\000\\128\\000\\128\\000\\128\\000\\128\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\000\\000\\128\\151\\194\\151\\194\\151\\194\\000\\128\\000\\128\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\000\\128\\000\\128\\061\\215\\061\\215\\061\\215\\000\\128\\000\\000\\000\\128\\151\\194\\151\\194\\000\\128\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\000\\128\\061\\215\\061\\215\\000\\128\\000\\128\\000\\128\\000\\128\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\128\\000\\128\\000\\128")
« Last Edit: 18 October, 2011, 22:21:18 by Levak » Logged

Human always wants to survive and that's why he will fall one day.
My website - TI-Planet - iNspired-Lua
Deep Thought
So much to do, so much time, so little motivation
Administrator
LV13 Extreme Addict (Next: 9001)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 03:12:44
Date Registered: 19 May, 2009, 08:00:00
Location: The Universe
Posts: 7832


Total Post Ratings: +713

View Profile WWW
« Reply #12 on: 19 October, 2011, 04:07:58 »
0

Cuberunner! Looks great. Trying it right now Smiley

EDIT: Levak, your source has some broken HTML entities shocked

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

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

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

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

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

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

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

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

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

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

function on.escapeKey()
 menu=true
end

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

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

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


Generated by the BBify'r (http://clrhome.tk/resources/bbify/)
EDIT3: This is really fun. Nice job!

* cubes.tns (4.34 KB - downloaded 15 times.)
« Last Edit: 19 October, 2011, 04:28:11 by Deep Thought » Logged




DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Online Online

Gender: Male
Last Login: Today at 06:33:15
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50586


Total Post Ratings: +2634

View Profile WWW
« Reply #13 on: 19 October, 2011, 05:16:01 »
0

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):

Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
Jonius7
aka jhgenius
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 14 June, 2013, 11:39:51
Date Registered: 03 September, 2010, 02:50:11
Location: Gold Coast, Australia
Posts: 1749


Total Post Ratings: +50

View Profile WWW
« Reply #14 on: 19 October, 2011, 07:25:51 »
0

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


* COOL.GIF (97.84 KB, 324x244 - viewed 383 times.)
« Last Edit: 19 October, 2011, 08:43:50 by Jonius7 » Logged



Userbars.com is down?
+9001
Intermediate TI-nspire Basic Programmer
Programmed some CASIO Basic in the past
DJ_O Music Discographist Wink
Userbars for these coming... in the process

My Released and Announced Projects (Updated 2013/01/29)
TI-nspire BASIC
TI-nspire Hold 'em | Health Bar | Scissors Paper Rock | Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled)

TI-nspire Lua
Numstrat | TI-nspire Hold 'em Lua | Terraria (coming soon)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Spoiler for Other Stuff:
Spoiler for Want your own HonestDownloads userbar?:
Hello! Do you want to show your affection for my website, HonestDownloads? Then here is a userbar I specially created earlier just for HonestDownloads users!

To add it to your signature just copy and paste the code below into your sig and you'll become an instant supporter of my website!

1
[URL=http://www.jhgenius01.webs.com][IMG]http://s1.bild.me/bilder/060112/3684792HDuserbaruser.png[/IMG][/URL]
Spoiler for My TI-nspire Basic Programs (Updated 2012/04/15):
***List of Programs in the TI-nspire Stadium***
Group Release 2012/04/07 on omnimaga.org

Games
   Noteable Release    ticalc.org Release Development/Not Publicly Released
2010/05/08 TI-nspire Hold 'em
   2012/04/07 v1.1.2   2012/04/10 v1.1.3  2012/04/14 v1.2.1
2010/08/03 Cosmic Legions
   2012/04/07 v0.2.2.2 (1st Release)
2010/08/12 Battle of 16s
   2012/04/07 v0.2.7
2010/09/10 Health Bar
   2012/04/07 v1.2     2012/04/02 v1.0   
2010/12/04 sTIck RPG
   2012/04/07 v0.1.5.2
2011/01/09 Monopoly
   2012/04/07 v0.16    (1st Release)
2012/04/09 Scissors Paper Rock
   2012/04/14 v0.8.1

Miscellaneous
2010/11/07 中文 (Chinese) Demonstration
   2012/04/07 v1.3     (1st Release)

Potential/Minor Programs
2010/09/26 Shanghai Metro
   2012/04/07 v0.2     (1st Release)
2010/12/22 TI-nspire Programming Tutorials
   2012/04/07 v0.1     (1st Release)
2010/12/28 Casino Games
   Was not released.
2011/04/22 Interlink
   2012/04/07 v0.0.4   (1st Release)
2012/03/22 Hierarchy
   2012/04/07 v0.01

Demo Programs (some may become Potential Programs)
2010/06/23 Monopoly (Board)
   2012/04/07 Prototype
2010/07/14 Strategy Battle
   2012/04/07 v0.12
2010/10/05 JRPG
   2012/04/07 v0.2
2010/11/02 PlotGrid
   2012/04/07 v0.2
2010/11/24 civilizaTIon™
   2012/04/07 v0.11

Purely Informational
2011/01/05 TI-nspire Stadium Changelog
   2012/04/07 v2
   Created to list significant releases of my programs. A page similar to this List of Programs in the TI-nspire Stadium was included in the documentation of most of my programs until sometime in Late 2011/Early 2012.

All games and programs coded in TI-nspire Basic.
© 2010-2012 Jason Ho.
Last Updated 14 April 2012

jhgenius01.webs.com
Will be moving! Stay tuned for updates.
Spoiler for Progress of Doodle God Axe:
2011/12/21 4% - Progress Suspended, ideas of graphical sprites still uncertain
Spoiler for Other Other You Know What Other Stuff I'm Talking About Stuff Stuff (Updated 2012/01/17):
Pages: [1] 2 3 ... 7   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 5.866 seconds with 30 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.