LUA PROJECTS
ASTEROID BLAST GAME
This project is a single-player, fixed shooter game, inspired by classic arcade games of the late 70s and early 80s, primarily notable "Asteroids" developed by Atari, "Space Invaders" developed by Taito and "Galaga" developed by Namco. Asteroid Blast is space-themed and features both space-themed objects and sounds. The game aims to manoeuvre the ship through an asteroid field and "blast" asteroid to gain points; as the player progresses and reaches a certain number of points, planets begin to spawn. The player should aim to avoid these planets as they result in points being taken off the score when hit. There is the main menu, instructions, options, high scores and game scenes.
​

In order to develop this application, a game engine/ simulator is required. Solar2D, formally known as Corona SDK, is a free Lua-based game engine, allowing for cross-platform development. Figure 1 shows the main menu of Solar2D, and to access the project, select "Open Project" and select the project file. Solar 2D uses the Lua scripting language, a powerful, efficient, lightweight, embeddable scripting language. Lua is an extension programming language designed to support general procedural programming, object-orient programming, functional programming, and data-driven programming as it also has data description facilities. Lua is the leading scripting language for games as it combines simple procedural syntax with commanding data description constructs based on associate arrays and extendable semantics. In addition to a simulator, a text editor is required in order to develop the application. For this application, the text editor used was Sublime Text; however, there are other options such as Visual Studio Code and Notepad++; however, due to its layout and ease for accessing a file, Sublime Text was chosen for this project. Figure 2 is the project loaded into sublime text, with all the files and folders accessible on the left of the screen.
​
Essential information about this application is vital for understanding how the game runs. The build settings provide the device with the information needed for the application. The "build.settings" file for this application is set to "portrait" in both the default and supported orientations. This means that when the game should begin in a portrait orientation when the application is first loaded and that the only possible orientation supported is "portrait", meaning that if the player were to rotate their device to a landscape, the application would remain its portrait orientation. Also, in the build settings, the icon for the game is set. The configuration settings are located in the "config.lua" file, which displays the content table contained a series of settings, including the width, height and scale of the application. The width and height values specify the content area size for the application and are set at a width of "768" by a height of "1024". The scale is the most important setting as it specifies how to handle the content area for screens that maybe not match the aspect ratio of the defined content area size. For this application, the scale is set as "letterbox", meaning that the content area should fill the screen while preserving the same aspect ratio, making this is the ideal scale mode as it ensures everything is displayed within the screen bounds on all devices.
​
The application has many different elements, which are each distinctly spread over several Lua files. The foundations of the application, such as the physics set-up, random seed and main background image, are located in the "main.lua" file. The other main files, which allow the user to play the game, include the menu ("menu.lua"), instructions ("info.lua"), options ("options.lua"), high scores ("highscores.lua") and the actual game code located in the "game.lua" file. There are also two files for effects, the first being "backgroundeffects.lua", which creates a starfield animation to the background of the application. The second is the "pushtext.lua", which adds an animation/transition to certain text elements of the application. All images and sounds used in the game are stored in separate folders of the same name. The font and icon image are also located within the application folder. The game operates by the player dragging the ship left and right to avoid asteroids and shoot a laser at the targeted asteroid. The player can either tap on the ship or the laser button located in the bottom right corner to shoot lasers.
The video above shows the game running in the simulator. Code available to view on my Github account.

