2. The initial status of the game

I've already did a few commits before starting this work log, so here a summary what's already there.

I've used Aseprite [1] to create a `png` spritesheet, containing 4 32x32 pixel squares with a player ship, an enemy ship, a friendly bullet, and an enemy bullet. The bullets are only 4x4 but they're occupying a full 32x32 square, I might optimise that later.

I wrote a bit of code which does the following:

`love.load()`

This is the function which is called when the game loads. It mainly loads assets and initiates variables and tables.

`love.update(dt)`

This is the main game loop. `dt` contains the milliseconds since the last update.

In this function I evaluate if certain keys are pressed and initiate the corresponding actions. It does collision detection and updates positions of all entities.

`love.draw()`

This is a periodically called function to draw stuff on the screen. It's just that, it draws all the stuff on the screen.

`love.keypressed(key)`

This is a callback function which triggers whenever a key is pressed. It only evaluates the escape key and immediately quits.

`player.shoot()`

This is called whenever the spacebar is held down. It emits a bullet at regular intervals.

`detect_collisions()`

This function evaluates all collisions, currently between shots and enemies, and enemies and the player.

`player_shots_update()`

This is called regularly to update the position of bullets that the player fired. They are removed if they're off screen.

`enemies_update()`

Update positions and create new enemies at random intervals and positions. The enemies are removed once they're off screen.

That's it, you can move the ships around with the cursor keys, shoot enemies with `space`, and you will die if you crash into an enemy ship.

⬅ 1. Introduction

➡ 3. Math considerations

⬆ A vertical shoot'em'up game in Lua with LÖVE

🏠 callistix Gemini capsule

Created: 25/Jan/2024

Modified: 25/Jan/2024