Click here to download Bigg's Jukebox demo
I was a bit miffed that we didn't have many good example pieces of v3 running in lua mode. Biggs stepped up and provided this little tech demo, showing off a few fundamentals in this box-rendering jukebox demonstration.
His readme text follows:
Biggs's Demo's Readme!
Hi, y'all. I wrote a simple jukebox in Verge. It is very basic, but if you study the code, I show off some of the things that can be done with Lua. It's sweet!
Features it shows off are:
- engineStep(func) and engineLoop(func) for hiding the implementation details of the game loop
- managed resource lists for not having to keep track of loading/freeing resources in code all over the place (sounds, images, etc., but only currently used for modules and fonts in the demo)
- see ui.lua for fonts usage and system.lua for implementation of the list.
- a declarative, album information "language" to showcase how XML is not needed with Lua--create your own data!
- programmatically (automatically) generated menus from the album info.
- coroutines for a sweet multithreading demonstration (and makes coding sprites much easier too!)
- see sprites.lua for coding, appMenus.lua for usage,and system.lua for implementation
I recommend that anyone trying to understand the code will read through every single Lua file until they see how each part of the demo works together.
I have commented some files, but not others.
Notes
You might notice a lag whenever a song is selected to play.
This is because each coroutine will block all other coroutines until it is finished drawing itself. Since loading a song is both a blocking/synchronous call and takes a while to load, all other coroutines will wait on the coroutine that is loading the song. There is no way around this, unless one could break the loading functions down into baby steps and execute a step at a time inside the coroutine. The coroutine that is loading, would then slow down, but no other coroutines would.