Game development using Lua and Love : Y’21 January fun

Published by

on


Happy New Year 2021 to all my blog post readers !!! Hope you and your family are safe and healthy

This being my very first blog of 2021, I would like to start this year with something fun. Over the winter holiday season of 2020/2021 (keeping myself socially distant from others and locked in my apartment); I decided to learn and develop beginners games.

I have always loved playing games (who does not?). Having owned Playstation (PS4) and many other consoles since childhood days, playing games always helped me relax and take my mind off some serious things in life. Having said that, I was always curious to learn about how people develop games. Being a software engineer professionally, I spent most of time working on building analytical and AI solutions for clients and companies. Game development is something completely new to me.

My First Game using Lua and Love – Recordings

Where to start?

As any learning enthusiast around the world, I search for game development courses on Udemy, a premier online learning platform. Out of the many available courses, I came across a very interesting course: Lua Programming and Game development with Love by Kyle Schaub.

The course takes on a journey of explaining the very basics of game development to using frameworks and third party applications to build animated games. I would highly recommend taking this course if you are a beginner like me.

There are multiple steps in learning the basics of game development, which involves learning basics about Lua programming; using Love2D framework and also understanding the various applications and libraries to develop a fully integrated game. In this blog I will try to give a brief overview of some of the concepts.

What is Lua?

Lua is a powerful, efficient, lightweight, embeddable scripting language. It supports procedural programming, object-oriented programming, functional programming, data-driven programming, and data description.

Definition from Lua.org website

Lua is the programming language of choice for many game development. It is fast and quite powerful scripting language to build games (among many other applications). World of Warcraft and Angry brids are among the most famous games developed using Lua.

What is Love?

Love or Love2D is a game development frameworks that is built using Lua. Love helps you build amazing 2D (two-dimensional) games that are very easy to build. Love provides a developer with all the building blocks and tools to develop a game. To top this, it is very lightweight, free and open-source.

Love framework usually builds on top of 3 basic functions:

  • love.load() : Its like an init/initialisation function of any programming. It is used for loading the data required for the games, which includes variables, tables, importing other .lua libraries, etc.,
  • love.update() : This is the most important part function. It updates the variables and functions at every frame per second. This gives the programs a sense of movement. By default, 2d games run on 60 frames per second.
  • love.draw() : This function is responsible for drawing the components in a game like player, enemies, obstacles, rewards, etc. Drawing in games are usually based of sprites. Sprites are usually images which are being loaded/drawn on the game environment.

Love Physics – Making components look realistic

Physics is an important module in Love2d framework. It enables you to build realistic interactions with the game world. Imagine a player (as in the Platformer game) jumping and running around the game environment. A player dies if it falls down the surface or comes in contact with the enemies. All of these interactions are made possible by the physics module in Love framework.

Building levels in Games

Subscribe to continue reading

Subscribe to get access to the rest of this post and other subscriber-only content.