Learn Programming
For Absolute Beginners
Defold is an excellent tool for first time creators to use to learn programming. It enables you to get into making games without being overwhelmed, and is still capable of advanced usage. Above all else, don’t ever get discouraged, don’t allow yourself to get overwhelmed. Take breaks when you need to, but always keep coming back. Break projects down into individual tasks, and focus only on single problems one at a time. Give yourself a bullet point list of very small goals to accomplish every time you work. If you face a problem that you don’t understand do a search to try to find answers (site:defold.com ...), and ask questions. Search first. Know that there are no dumb questions (although if you keep asking questions which have already been answered / keep asking questions which reading the manuals once through would answer it can get annoying). The community will be happy to answer any questions as best as it can. If something is not clear in a thread where a question was already answered then ask for more clarity.
Deliberate Practice
A good way to learn is to do. Read chapters in this book, and attempt to implement the features discussed on your own. When you see code do not copy and paste ever. Instead write code out on your own. Think about what each bit of code might do. You will sometimes make mistakes with typing example code, but this is OK. Making mistakes and learning from them can help you to learn and remember long term.
If your goal is to master the features of Defold, to be able to make any kind of game you wish to with Defold, then it is in your interest to work with Defold daily. Don’t go a day without opening the Defold Editor and working on something. Keep a list of features you wish to implement, and do one at a time. Always have a specific goal before you start each day. Learn new things every day. Ask questions in the community forum. Search for answers in the official docs. Pick specific problems you want to solve, and tackle those small and focused problems for the day. Break your larger goals into small lists of specific tasks, and only focus on those small, focused tasks until they are done.
Take notes, and consider writing tutorials of your own, because teaching can also be a great way to solidify your knowledge. Anyone with the desire to can make games, and with Defold you can make better games faster.
Coding Tips
Don’t try to be smart when writing code. Have you ever written code in the past, and then came back to it sometime later and wondered how it even works? This shouldn’t happen. You should write code as simple as possible, and on as many lines as is needed to make each step have perfect clarity. Anyone should be able to look at a line of code and understand how it works, how it transforms data.
Use math instead of conditional statements (if then else …) when you can. This requires understanding more math, which you should endeavor to learn. Mathematical methods can be clearer, be more flexible, and be less likely to be buggy than long lists of conditional statements.
Avoid duplicate function calls. If you have a long list of a repeated function call consider a rework. Transform the data instead, and then call the function call a single time at the end of the block of code.
Don’t create Lua tables when you don’t need to - such as with return statements. Lua supports returning multiple values, which can then be assigned to multiple variables. Creating Lua tables has a cost (memory / garbage collection), and so should be avoided when it’s not necessary.
Don’t allow yourself to go into feature creep. Only code features you immediately need. Avoid building tools - especially for projects where you don’t have a genuinely fun prototype yet. Use tools by others as much as you can to increase your productivity. Defold is this kind of tool - it has so much built in that enables you to get to making the actual game faster.
Keep your code clean and tidy. Leave it better than how you found it. Avoid duplicating functionality all over your code.
Spend your time really learning the features of Lua: tables, metatables , coroutines, modules as a start.
Explore the library of available Lua modules published on the community portal, and make examples with integrate the features into Defold projects. There is a great amount of work done by others that is freely available for you to use, and you should use these resources if they enable you to make your games better.
Ask others to review your code. You may feel shy, insecure about your code. You don’t want others to think less of you for possibly doing things the hard way or in a dumb way. This is normal. Everyone feels this way even if they won't admit it. You don’t have to throw your code into the world. You can find mentors who you can trust who can help you to improve your code quality. The most important thing is that you are getting code reviews done as it will help you to learn through the mistakes others have made and learned from before. Even less experienced coders can be useful for doing reviews - we all don’t know everything, and they may have some insights which you, as a more experienced coder, don’t. If someone is harsh about your code don’t take it personally, and don’t attack them.
Your code may be honestly trash, but someone being harsh is talking about the probably naively written code and not you. Learn, move on, and do better.
Offer to review the code of others. You can learn new things, and help share your own learning and problem solving insights.
Last updated