Mechanics in 250 Or Less With Corona - Doodle Jump

I saw a post the other day that made me think, “I bet I could make that game mechanic in less than 250 lines of code using SSK and Corona”.

(The post: https://forums.coronalabs.com/topic/74105-rebound-length))

The mechanic in question is “Doodle Jump - Jumping”

This demo code implements: 

  • Basic player
  • Platforms
  • Springs
  • Coins
  • Dangers
  • Endless generation
  • Touch and keyboard input (instead of tilting) to steer
  • Screen wrapping
  • Camera code
  • and of course jumping…

in less than 250 lines of code ( in main.lua ).

https://github.com/roaminggamer/RG_FreeStuff/raw/master/gamesIn250/001_doodleJump.zip

The example comes with a ‘basic’ and ‘prettier’ version.

https://www.youtube.com/watch?v=TvO8k0rgK_U&feature=youtu.be

While this is a LONG WAYS from an actual game, it shows the power of Corona coupled with SSK.

Cheer,

Ed

PS - Beware.  There may be bugs in the code and I’ll fix major ones if I or others find them.

That’s awesome :slight_smile:

Fantastic @roaminggamer!

Rob

nice one thumbs up

Thank you again!

Hehe, that’s great. I’m always doing stuff like that too :slight_smile: Corona is insanely quick to prototype stuff.

Now try it in 250 lines of code without SSK!!

SSK is part of hard work and knowledge of @roaminggamer. I do not see why he would have to try to do it in 250 lines without SSK. I give it to RG, simply brutal, fantastic, excellent example … Thank you!

Interesting idea… hmmm

I might be able to do this, but I worry that nobody would then be able to read the code…

OK, I tried, but I was simply unable to implement all of the original mechanics (SSK version)  in 250 lines or less of pure-Corona.

I took out the SSK code and replaced it with the most compact code I could come up with in 50 minutes…

See the sub-folder ’ nossk/

The game is now 152 lines longer and doesn’t quite have the same functionality.  Some of the nice debug features were simply too much of a pain to reproduce.

Note: I will never do this again.  Long-hand coding sucks once you know how to use the power of SSK.  I’m way too lazy to do it the long way and I want my code to be easily maintainable and legible. 

Longhand code is soooo much work to write, maintain, and read.  Blech!

PS - Some lines I replaced w/o annotating, but for the most part I commented out the SSK code and then noted the NO SSK difference so you can see how much longer the code becomes.

@dodi_games: uhm, wow, way to overanalyze a small forum comment. Why would he need to do this? Why would he need to do it in 250 with SSK in the first place? He doesn’t need to do this.

But it’s a fun challenge! That’s why!

@thomas6

And it was also fun to capture your attention.
:slight_smile:

Okay, good, fun is important! Besides this, I do believe that the concept of coding a game or app in as little lines as possible becomes quite irrelevant if you don’t count the lines of code in submodules or -libraries.

My main.lua files typically only have 10 to 20 lines of code. I don’t really consider this to be much of a benchmark, since the rest of my code runs into the 10.000s of lines.

I hope that sheds some more light on my challenge to write this game without outside modules.

From the point of view of the topic, it is not really a game, it is the mechanics of the game, I would practically understand that it is the speed in which it is written using existing resources of the programmer, those external modules. But in this topic I think it’s more in the mechanics of the game where the magic is.

I think the main point here is that you can do a lot in Corona with far fewer lines of code than you might run into with other languages and APIs.

We used to market that it’s 1/10th of the code of doing things natively.

A polished, functional, marketable game, of course, will take more code, time and effort.

I think @roaminggamer is doing a great job of showing the power of Corona. How many other platforms can you test a game mechanic in such small amounts of code and see the results instantly? Try it, if it doesn’t work, try something else. It’s about iteration.

Rob

@roaminggamer I like the 250 challenge.  You essentially just held your own mini game jam of one  :)   Nice work!   Hows this for a game jam idea.  250 lines of code, as many libraries as you like, 72 hours?

Personally, what I love about Corona is that it is the closest programming experience I’ve found to making art (Flash coming in second).  The process, the discovery, the fast implementation that can be refined later - it’s great way to think openly and be creative while doing a very concrete activity - coding.  When I make art I’m constantly refining and adapting and changing my mind and that’s how I feel with Corona.  For example, I don’t have to get caught up with strict data-typing.  I can play it loose and let the model emerge instead of making concrete decisions during the phase of development that should be open and playful.

I for one have never ever been able to prototype a game as quickly as I can now, before using Corona. Most projects I do, the prototype is done in a day.

Well, my $0.02…

1)  If it’s main purpose is the lines-of-code metric, then it “cheats” that metric by relying on (and not counting) external code.  If you were to take that approach to the extreme, then why not just put the ENTIRE mechanic in a separate module, then call it with a single line of code from main (thereby allowing you claim just 1 LOC to implement), fe:

-- main.lua require("doodlejump"):run()

2)  If it’s main purpose is as a tutorial, then it suffers from over-complexity due to “can’t just run it”.  The linked zip won’t run as is (I just tried it) without apparently first obtaining and installing SSK… except for the “nossk” version.   That installation step isn’t covered or even mentioned within the code itself, so it’s hardly “beginner-friendly” as a tutorial.

3)  If it’s main purpose is as a “promotional tool”, then see 2) above - the SSK versions won’t work as-is, but the no-SSK version does.  Code that won’t run out-of-the-box doesn’t leave a great first impression.

4)  If it’s main purpose is as a “demonstration tool” (ie “see how SSK can shorten your development cycle”), then having a no-SSK version would be critical for that comparison.  (though the stated 152 line difference is “unfair” - if you remove all the “SSK/NOSSK” comment lines and otherwise dead SSK leftovers, the actual difference is around 80 lines)

Purpose Of Post

Sorry, but it was #5

#5 Satisfy my curiosity and creativity itch.

I saw a post the other day that made me think, “I bet I could make that game mechanic in less than 250 lines of code using SSK and Corona”.

I wondered if a game mechanic similar to doodle-jump could be done in a few lines of code.   (I wanted to test a theory I have; See below.)

Choice Of Limit (250 lines)

I chose 250-lines as a limit on of the off chance I’d do more of these.  That way I could be consistent in my goal/measure/limit.

My Theory On Game Mechanics and Corona + SSK

It is my theory/opinion that the core interaction  (the mechanic) of almost 90% of retro or hyper-casual games can be achieved in 250 lines or less.  This assumes using Corona and (for me) SSK. 

While SSK is not a requirement, I am way too lazy to implement anything even marginally complicated without it.  I hate re-coding solution to problems I have already solved.

 … without SSK I’d probably have to quadruple that limit to cover most mechanics.

Why Use SSK?

As far as the motivation for using SSK, I only use it for myself anymore.  It makes coding way easier and more legible than the long-hand equivalents.   I am, and always have been lazy.  I hate typing more code and reading more code than I need to.

What About The Noobs?

As for new folks… I didn’t give them much thought.  I think they should be able to browse through it and understand the main thrust of the mechanics.  I don’t intend this as a template, tutorial, or any kind of teaching device. 

Last Words

Again, at the end of the day this was about satisfying my curiosity.  Once I’d done it, I figured why not share.  Someone might get something out of it.  If so, great.  If not, oh well.

I think Corona is great and I absolutely agree with Rob’s statement:

You can do a lot in Corona with far fewer lines of code than you might run into with other languages and APIs.

In the spirit of your reason #5, RoamingGamer, I’ve been dabbling around a bit to see in how many lines I could write a similar game. I’ll upload it here when I’m done.