Corona Quick Thought – Prototypes and Lines Of Code

Several recent posts on Corona’s forum have mentioned lines-of-code (LOC) metrics for some simple game mechanics, and it got me to wondering about what sort of metrics were “typical” of various little prototypes that I’ve tinkered with.

You can perhaps use these samples as rough guides for answering the question “what can be accomplished with x amount of coding?” Granted that not all coding styles are equivalent – the reader’s may be more/less verbose than my own – so take this as a rough guide only.

Note that all of the following prototypes were done with “plain vanilla out-of-the-box Corona.” None of the following prototypes use any other external plugins or libraries – the metrics given are for their entire set of code.

Also note that the genre of game can potentially be a significant factor to how much effort is needed to accomplish something minimally functional. All of the prototypes below are based on relatively simple genres to begin with.

Finally, note that none of these prototypes are full games.  There’s almost always way more work involved in all the other aspects of a finished game, and these prototype metrics make no attempt whatsoever to capture any of those aspects.


~1 LOC

A frequent source of frustration in the forum seems to be the loading Tiled maps since (at present) Corona offers no built-in support. Well, let’s put that to rest, shall we?
With one line of code you can have a tiled map loader. Seriously. Here it is:

Since Tiled will export to Lua format, loading its data is crazy simple.  Sure, it’ll take another 40 or so lines to actually render it in some minimal way, and maybe another 30 or so lines to implement a minimal camera for scrolling.  (and perhaps many hundreds more lines if you had the lofty goal of implementing every last feature that Tiled supports, rather than just what you actually need) But I’ll leave those as tasks for the reader, or a later post, because it’s off-topic, and there’s really just not that much to it.


~300 LOC

300 lines of code is enough for a skeletal RPG framework, with tiled map loader and renderer, scrolling camera, doors and room-based lighting and a simple character:


~400 LOC

400 lines of code is enough for a simple vertical shooter, with custom collision detection (you could perhaps do something similar, with less code, using the physics library, but it wasn’t appropriate here), pooled entities, and a scrolling camera/background (that really aren’t used here, but are present and ready just the same):


~600 LOC

600 lines of code is enough for a one-tap “dash” -type game, with generative level content, scrolling camera, parallax background, some player effects, an AI player for “demo mode”:


~1000 LOC

1000 lines of code is enough for a Lode Runner -type clone, with most of it being taken up by the enemy AI and supporting movement routines in Player (of which Enemy is a subclass) and Level:


~1300 LOC

1300 lines of code is enough for a fairly full-featured scrolling platformer, with a player character having multiple special moves (jump, double-jump, wall-cling/jump/slide), several special map objects (various spike hazards, lava hazard, springs, coins, stars):


Wrapping Up

My hope with this post is, to the extent that you might be aiming to achieve something similar to one of the prototypes above, that the reader might find these code metrics useful to give a reasonable guesstimate of how much effort might be involved. Happy coding! 🙂