Introduction
A month or two before I decided to start writing this, I set out to write my own game engine. There weren’t really any off-the-shelf engines that I was aware of that would let me wrangle with the inner workings of a turn-based tactics game the way I wanted, and the terrible job I had which I had recently quit had me so seperated from programming that I really wanted a project that could help me brush off the rust and prove to myself that I could accomplish great things.
Of course, before I started, there was a research phase, and since this was the first project I had ever written I wanted to find resources on the kind of patterns you needed to know about in order to make a game engine. I come from a background in enterprise software, and my college degree has a specialization in Java. I knew from the start that writing games would require logic that would make my inner coding grandfather cry. But try as I might, I wasn’t able to find any books about the subject that weren’t either absurdly in-depth and specialized, and the more general ones were so basic that they were rolled up into coding tutorials. So I decided to write my own.
Who is this for?
This book is for anyone who already has a great grasp of coding concepts - someone who has ideally already written and deployed their own projects. While we will be focusing on LÖVE and the Lua programming language, I aim to focus on the concepts more than actual code. If you’re looking to start writing game logic of any type, this is probably going to have some useful information.
Why Lua and LÖVE?
I know there is a sizeable audience who might come across this document and think to themself, “Why isn’t he using PyGame?” And to be frank, that’s a great question. PyGame is an extremely well polished piece of software and there are tons of developers who have experience with it, so help is always around the corner. In the end, the choice to use LÖVE was fairly arbitrary, though it does have some strong benefits in my personal opinion.
The project I alluded to in the first paragraph of this introduction is actually my second attempt at making a game. My first attempt was actually me playing around with the PlayDate SDK, which is built around Lua. Of course, since I didn’t actually have a concept formed, it didn’t really go anywhere, but it was an exciting first taste into the exciting world of programmatic computer graphics outside of turtle graphics. I had heard of LÖVE prior to the PlayDate experiments, and sometime between those experiments and the present someone made a viral smash hit called Balatro built on top of LÖVE.
But if I’m being honest, the thing that really sold me on LÖVE was Lua. It’s really a lovely little language that is so compact that it’s not entirely uncommon to have Lua interpereters built into high performance C-language video game engines. I also adore the documentation; the [Reference Manual] formally describes it’s syntax while being verbose and helpful enough for you to learn the language if you have a decent computer science background. In spite of it only a little more than a year older than python, it somehow doesn’t quite feel as rigid. I kind of liken it to a mix of Python and JavaScript. If you know either of those programming languages, you shouldn’t have a problem parsing Lua.
Next: Getting Started