BYTEPATH mini is an Android port and following of adnzzzzZ's BYTEPATH tutorial.
If you like BYTEPATH mini, I suggest you buy the original version, which has way more content and is way more polished.
- If you're using ZeroBrane Studio, beware of enabling
mobdebug, as this can kill the performance of your game - Time manipulation commands are super useful for debugging. You can build them into your game simply by multiplying
dtby a time factor. - On that same note, a "pause" and "resume" command is also helpful, which you can do by multiplying
dtby0, or just wrapping your update calls in anifblock. - What is
make_distrib.sh? If you're running UNIX, this is an easy script that you can run to package your game into a.love. Useful when you want to distribute it. This script can be improved by excluding the actual script itself, but I find this works fine. - A useful idiom you can use for Lua:
for _, val in ipairs(table or {}) do
endThis way, you don't need to check whether or not the table exists. Why does this work? The or operator will always return the second argument if the first argument is false.
- Some useful functions:
table.sort, for sorting tablesunpackfor returning all elements inside of the table. Note thatunpackonly returns the first returned value if it is not the last one in a list of expressions.s:find, wheresis a string, finds a pattern inside of the string and returns the start and end indices of it.typereturns the type of the value.- LOVE-Specific:
font:getWidth(text)returns the width of the given text using the font thatfontrepresents.
- LOVE-Specific: Colors work differently in LOVE 11.0. They range from
0-1instead of0-255now. - LOVE-Specific: The functions
love.keyboard.isDown()andlove.mouse.isDown()now throw exceptions instead of returning false upon an invalid key constant. - Always define a
lengthfunction for tables. The#operator only returns the largest indice in a table. - LOVE-Specific: Always clear your Canvas after using it, otherwise you'll run into an error at the end of the draw loop.
- ZeroBrane-Specific:
CTRL+Ire-formats the current file for you. Use this all the time to avoid wasting time on re-formatting text. - Handy simplification for operator precedence: numerical
>comparison>boolean - Functions by default return
nil, which is equivalent tofalse, so if you're designing a function that returns aboolean, you only need to insert thetruecase. Though it is probably much more clear if you explicitly returnfalse. - Debug utilities are extremely useful. An example: adding the ability to slow down or pause your game using hotkeys. Very easy to implement, and helps a lot with debugging.
- Something I've wanted to do but haven't had the chance to: add a debug function to iterate through all game objects, and draw their bounding boxes (if they have self.w, self.h, self.x, self.y attributes, which every game object should.) Previously I had done this on an object by object basis and often removed the code after I fixed the bug (in which I would then re-add it shortly afterwards anyways), which is really inefficient.