Omnimaga

Calculator Community => TI Calculators => Lua => Topic started by: Adriweb on December 01, 2012, 11:06:17 am

Title: Doodle Jump in Lua
Post by: Adriweb on December 01, 2012, 11:06:17 am
Hi guys :)

A few days ago, I got bored and looked around what I could quickly do, and making Doodle Jump was what I thought first :D

So, after a few hours, here's what I've coded so far.



Updates : Graphics + main/welcome menu :)
(http://i.imgur.com/gYOLfm.png) (http://i.imgur.com/OuZpY.png) (http://i.imgur.com/1RLdk.png)

You can also play online :)  (but resize the window to approximately the image's size :P)
http://education.ti.com/html/nspireplayer/3.2.0/application/index.html?locale=en&nspirefile=https://raw.github.com/adriweb/Doodle-Jump-Lua/master/DoodleJumpLua32.tns

BTW : when launching the .tns, please either zoom up to 150% on the computer view, or switch to the handheld view ;)

Download :
- TI-Planet : http://tiplanet.org/forum/archives_voir.php?id=9446
- GitHub : https://raw.github.com/adriweb/Doodle-Jump-Lua/master/DoodleJumpLua.tns

( Version with bakcground image for 3.2 : https://raw.github.com/adriweb/Doodle-Jump-Lua/master/DoodleJumpLua32.tns )

Source Code : https://github.com/adriweb/Doodle-Jump-Lua/blob/master/DoodleJumpLua.lua


Title: Re: DoodleJumpLua
Post by: stevon8ter on December 01, 2012, 11:10:00 am
Looks great so far, but maybe it should be slown down a little bit...?
And can you maybe remove the cross so that it looks smoother? ;)
Title: Re: DoodleJumpLua
Post by: Adriweb on December 01, 2012, 11:18:58 am
Looks great so far, but maybe it should be slown down a little bit...?
And can you maybe remove the cross so that it looks smoother? ;)

Thanks.

Let me explain the thing :P

On the software, as usual, it looks smooth and all. On Calc it's still a bit slower. I'll see what I can do with that...
The "cross" is here so that you can actually control the game with the touchpad/mouse.

BTW : you can move left with left or [1] or [4] or [7], and right with right or [3] or [6] or [9], and shoot (at no enemies for now but they will come ^^) with click or 2 or 5 or 8.
Title: Re: DoodleJumpLua
Post by: stevon8ter on December 01, 2012, 11:20:59 am
ok cool , i don't have an nspire myself but i thought, let's take a look :p (i'm gonna download an emulator anyway
Title: Re: Doodle Jump in Lua
Post by: Rhombicuboctahedron on December 01, 2012, 11:54:36 am
Awesome!
This is more fun than the original game when you use the mouse, but the mouse doesn’t work well on the handheld.
Normally the touchpad is slow in responding, but with Lua, and especially a timer and graphics, it is very unresponsive.
But it’s still very fun even with the d-pad and the keyboard.
One thing I notice is that in the generation of the platforms, it seems that every now and then there is a section with no platforms and is too large to jump over, but good work anyway!

\\Next, add an accelerometer :)
Title: Re: Doodle Jump in Lua
Post by: Adriweb on December 01, 2012, 01:22:05 pm
Thanks !

This is more fun than the original game when you use the mouse, but the mouse doesn’t work well on the handheld.
Normally the touchpad is slow in responding, but with Lua, and especially a timer and graphics, it is very unresponsive.
But it’s still very fun even with the d-pad and the keyboard.
Hmmm, the touchpad isn't working so badly for me, with this script, I can play with no problems.
But yeah, universal control -> keyboard :P

One thing I notice is that in the generation of the platforms, it seems that every now and then there is a section with no platforms and is too large to jump over, but good work anyway!
I know, since it's all kinda random I don't control that, but let's say it's part of the game ? Always trying to get the highscore no matter what happens :P

Next, add an accelerometer :)
Sure, why not - Sadly I don't have the required Vernier sensors to test, though ^^

Edit :
Update : Graphics :)
(http://i.imgur.com/gYOLfm.png)
http://tiplanet.org/forum/archives_voir.php?id=9446
Title: Re: Doodle Jump in Lua
Post by: Sorunome on December 01, 2012, 02:48:37 pm
wow, this is pretty epic O.o gread work!
Title: Re: Doodle Jump in Lua
Post by: Adriweb on December 01, 2012, 04:10:39 pm
Version 1.2 :
- Welcome/Main Screen (with scrolling background :D)
- Highscore displayed
- Pause
- Original game scrolling mode (changeable)

(http://i.imgur.com/aOaUdm.png)

Same download link, or on github (always latest : https://raw.github.com/adriweb/Doodle-Jump-Lua/master/DoodleJumpLua.tns)
Title: Re: Doodle Jump in Lua
Post by: Sorunome on December 01, 2012, 04:11:29 pm
stop making it awesome :P
Now add the different themes :P
Title: Re: Doodle Jump in Lua
Post by: lkj on December 01, 2012, 04:36:41 pm
Looks good, but can't test it right now because it seems to be a 3.2 document :/
Title: Re: Doodle Jump in Lua
Post by: Adriweb on December 01, 2012, 06:01:17 pm
I saved it with 3.1, I hope I didn't push to github the one with 3.2...  Can you redownload the latest .tns from GitHub ?
I'll see tomorrow morning, sorry.

You can still try online :  http://education.ti.com/html/nspireplayer/3.2.0/application/index.html
Title: Re: Doodle Jump in Lua
Post by: lkj on December 01, 2012, 07:09:31 pm
The latest one from GitHub works now, thanks.

It's very hard to survive more than one second :P
Title: Re: Doodle Jump in Lua
Post by: Adriweb on December 01, 2012, 07:33:33 pm
Hmm My best score is 750, but it's all randomly generated ^^
Title: Re: Doodle Jump in Lua
Post by: Adriweb on December 02, 2012, 10:02:41 am
Version 1.3 with background image for 3.2 OSes, and some other little things and optimizations.
(thanks @ Jim Bauwens)

(http://i.imgur.com/rDScQ.png)

You can also play online :)  (but resize the window to approximately the image's size :P)
http://education.ti.com/html/nspireplayer/3.2.0/application/index.html?locale=en&nspirefile=https://raw.github.com/adriweb/Doodle-Jump-Lua/master/DoodleJumpLua32.tns
(mac or windows)

Download :
- For < 3.2 : https://raw.github.com/adriweb/Doodle-Jump-Lua/master/DoodleJumpLua.tns
- For 3.2 : https://raw.github.com/adriweb/Doodle-Jump-Lua/master/DoodleJumpLua32.tns
Title: Re: Doodle Jump in Lua
Post by: ElementCoder on December 02, 2012, 11:46:06 am
What bug are you fixing? I was reading your code and saw "-- fix of TI Bug...."
Title: Re: Doodle Jump in Lua
Post by: Adriweb on December 02, 2012, 11:54:37 am
Yeah, there is a timer issue on 3.2, which that fixes :
Code: [Select]
-- fix of TI Bug....
local tstart = timer.start
function timer.start(ms)
    if not timer.isRunning then
        tstart(ms)
    end
    timer.isRunning = true
end
local tstop = timer.stop
function timer.stop()
    timer.isRunning = false
    tstop()
end
Title: Re: Doodle Jump in Lua
Post by: ElementCoder on December 02, 2012, 02:49:04 pm
But what does it fix, or is it too technical/unknown and it is just known this fixes it?
Title: Re: Doodle Jump in Lua
Post by: Adriweb on December 02, 2012, 03:11:29 pm
Well, I'm not sure why it acts that way, but they probably chanced its internals and since then, when you call a timer.start() while there was another one running, it simply didn't start.

The fix here monitors when ther is a call to timer.start and stop and calls the stop() before starting another :P

We have reported that bug :)
Title: Re: Doodle Jump in Lua
Post by: Jim Bauwens on December 02, 2012, 05:09:07 pm
Just the weird part is that I have never encountered this bug :P
Title: Re: Doodle Jump in Lua
Post by: Adriweb on December 03, 2012, 02:18:18 pm
All right, Version 1.4 (beta) :

- Better platforms generation (:P)
- Better collisions detections
- Enemies !

(Still has the weird bug I've spent a few hours on but I can't understand- basically, the doodle will keep going up without bouncing, sometimes, when it goes through a jumpable platform, without bouncing on it first)

(http://i.imgur.com/OuZpY.png)
Title: Re: Doodle Jump in Lua
Post by: lkj on December 03, 2012, 04:04:55 pm
The highscore always resets when restarting the game on 3.1 (at least for me). And did you notice that in not constant scrolling mode it's almost impossible because the jump heights are much too short if the level doesn't go down while you're going up?

Also lol, I thought it was intended that you could jump without bouncing on the platforms :P
Title: Re: Doodle Jump in Lua
Post by: Adriweb on December 03, 2012, 07:00:00 pm
The highscore always resets when restarting the game on 3.1 (at least for me). And did you notice that in not constant scrolling mode it's almost impossible because the jump heights are much too short if the level doesn't go down while you're going up?

Also lol, I thought it was intended that you could jump without bouncing on the platforms :P

Hmm, weird, the scores should be saved.
I'll redo it in pure lua anyway (for now it's a basic variable, but there is a save/resotre thing in lua, kinda made for these things :D)

And yeah, about the constant scrolling, it's actually doable kindof on the software, I haven't tested that mode on-calc :D
Maybe I should indeed make it jump higher :P
However, you can trigger this mode if you ever find yourself stuck in the normal mode a little bit too low :D