The arcade-style computer games of 1980s played a big role in getting me fascinated about computers. Last weekend I decided to fulfill a childhood dream of writing my own invaders-like game. After a few hours of programming, I ended up with a simple game that I call Andromeda Invaders. You can play it now by clicking the link below:

Play Andromeda Invaders

It is a 1980s-arcade-style game that runs in a modern web browser. This game is inspired by Space Invaders, the 1978 arcade game developed by Tomohiro Nishikado. However, the game characters, gameplay and some technical aspects of this game are very different from those of Space Invaders.

## Inspiration

I first came across Space Invaders in the 1990s in the computer laboratory of my lower secondary school. Soon after playing the game a few times, I wanted to develop a similar game of my own. However, the little GW-BASIC programming I knew then was insufficient to write anything more sophisticated than simple text-based input/output programs. I did write several simple text-based quiz and adventure games back then but a more sophisticated game with graphics and audio remained elusive. As years went by, I gradually forgot about it, learnt more mainstream languages like C, Python, Lisp, etc. and got into programming as a career.

Although it is 25 years too late, I decided to spend a weekend now to fulfill my childhood desire to write my own Invaders-like game. This game fulfills a childhood dream of mine!

## Graphics and Audio

All of the graphics is done by drawing rectangles and text on an HTML5 `<canvas>` element using the Canvas API.

All of the audio is done by generating sine waves using `OscillatorNode` of the Web Audio API. The sine waves used for the game audio correspond to actual musical notes from the C major scale. Multiple notes are played together to form chords. The background music is a chord progression consisting of four chords repeating over and over again as long as the game is being played. When the game characters get hit, the hit sounds are made of a single chord that plays for a very short duration.

There is rudimentary support for playing this game on small screens and touchscreens using the buttons provided below the game canvas. However, this game is best enjoyed on a laptop/desktop device with a physical keyboard. On a device with physical keyboard, the game can be played in fullscreen mode by typing `f`. Since it is a single-file HTML game, it can be saved as a standalone file on your system.

## Levels

The game can be played indefinitely long in theory. However in practice, the difficulty level of the game rises steeply with each level and I would consider it remarkable if someone manages to reach level 10. None of my friends and colleagues who played this game over the weekend has been able to reach level 9 yet. However, many of them have reached level 8 within a few hours of practice. The steep rise in difficulty level is intentional, so that a single session of this game does not last too long.

Levels 1 to 20 present new difficulty levels in terms of the speed of the objects moving on the canvas. The difficultly levels remain constant between levels 21 and 1000. If someone were to complete level 1000, the game would reset to level 1 with the score intact. This is how one could potentially play the game indefinitely long.

## Conclusion

Like I mentioned above, this game is the result of a weekend's work. I wanted to keep it as simple as possible. Despite the simplicity, there are a few interesting concepts such as loss and recovery of health of the game characters, automatic release of laser pulses, etc.

There is a Git repository for this game at github.com/susam/invaders. The README file in this repository documents several technical details of this game. The source code is released under the MIT licence, so please feel free to play with the code, modify the game parameters and logic and alter the game. If you like this game, do share it with others.