Iterations - Zugamifk/Garden GitHub Wiki
Garden has been a sort of large project for me to try out different coding concepts and learn how to do it in general. It's been coded in Lua with LOVE2D since the beginning, and now I feel my understanding of it is good enough I can maybe start a serious version. In each iteration I tried to make as much functional content as possible, until I reached the limits of my code's functionality. Each time I've learned how to avoid these limits, but because of poor design and understanding, I haven't been able to salvage much of the code in each iteration. This is both good and bad, as each iteration has much improvement on the last, but it means a lot more time and a lot less productivity. Still, I'm learning and that's the real point.
The first iteration was my first real attempt at anything big with Lua. I had made small silly games before, and I felt I was ready to start making my game. The first iteration was called Libraria, the same name as the D&D setting I had created long ago that a lot of the inspiration for this game came from. Although not nearly as heavy on the fantasy side.
This version was purely functional, with no object oriented programming involved at all. This made it difficult to track individual items and create new ones, and I eventually had to scrap it because of this. However, I did get a lot of work on natural processes in. By the time I scrapped this version, I had implemented seasons, weather, plants growing, aging, flowering and seeding. This version also was the most efficient, using less than 15MB of memory with a 100x100 tile map. This is likely because all objects were references to static tables, so they didn't carry any of their own values. Individual tiles did, however, and I soon realized this meant I couldn't use big maps if I wanted to track all unique information inside of tile arrays. This, combined with my poorly organized code and lack of OOP knowledge led me to drop the version and study some more programming concepts before trying again.
The second time I began this project I was equipped with good knowledge of how to implement OOP in Lua, use metatables and had certain design ideas for some of the core background tasks, such as drawing and iterating over map tiles quickly. It took me a good month of coding before anything playable was out, but now the game ran several functions that managed different aspects of the game, rather than just one big one that did everything. I also now had tables for everything in the game, and stored things in nested tables so they'd be easy to reference or name without worrying about conflicts.
The game also had a much more interactive UI, with a drag and drop style inventory, tooltips for items and certain icons, close buttons on hud windows, and at one point I rehauled the graphics and drawing functions for isometric view. I added a startup_options table for debugging, and also wrote an algorithm to track and spread heat. While I didn't add as many features as I could have, I found I was finding more and more limits in what I could do, and many of the functions I wrote seemed to lag the whole game, taking a long while to make efficient.
Eventually I sat down and looked at the whole design and realized it was way too fragmented, and too many things were being calculated multiple times for different jobs. I put off work for a year I spent at university, and I learned a lot in that time, so it felt like it might be a good time for a new iteration.
Now we have the third iteration. Among other things, this version is has far more predesign to it. I've sat down and planned out a lot of the design this time, and figured out ways to synchronize variable updates so they only happen once per iteration of tasks. Another important aspect is that this version is entirely modular. That is, each lua file encompasses a unique set of variable and variable references. This means I shouldn't ever have to rewrite everything again, and it should make tracking issues a lot easier. I feel that with this much planning, I should be a lot more productive. Hopefully I can get a game done by the end of the summer.