Arduino Powered Space Invaders Like Game on 1602 LCD Character Display /AKA LCD Invaders/

Introduction: Arduino Powered Space Invaders Like Game on 1602 LCD Character Display /AKA LCD Invaders/

There is no need to introduce a legendary “Space Invaders” game. The most interesting feature of this project is that it uses text display for graphical output. It is achieved by implementing 8 custom characters.

You may download the complete Arduino sketch here:

https://github.com/arduinocelentano/LCD_invaders/

You could also check out another project where I teach how to stream video on a character display.

Supplies

  • Arduino UNO board;
  • LCD keypad shield;
  • USB cable for sketch uploading.

Step 1: Game Design

The screen does not allow to control separate pixels and provides just two lines of text which is not enough for game. But it allows to implement up to 8 custom characters. The trick is to process each 5x8 pixels character as two 5x4 pixels game cells. That is to say, we’ll have 16x4 game field, which makes sense. 8 characters is just enough to implement sprites for player's spaceship, bullets and animated aliens. Since the sprites are 5x4 and the characters are 5x8, we’ll need some characters with two sprites like “a spaceship and a bullet” sprite, “an alien and a bullet sprite” etc. All the custom characters are shown on the picture.

Step 2: Processing Buttons

Typically, all the buttons on an LCD shield are connected to the same analogue pin. There are different versions of LCD shield, so you’ll probably need to slightly change integer literals in my button processing code.

Step 3: Classes Hierarchy

I have implemented a base class GameObject which has coordinates and speed fields and processes collisions. Classes Ship, Alien and Bullet are inherited from it.

Step 4: Updating the Screen

Rendering logic may look somewhat complicated because we have to transform 16x4 game logic into 16x2 display. Please read the comments in the code for further reference. To avoid flickering, I used a two dimensional char array as a text buffer. It allows to use a couple (one for each line) of print operations to update the screen.

Step 5: Game Logic

Here is the heart of the game. The main loop changes coordinates of all the objects, checks all sorts of collisions and button press events. The speed of aliens and their shooting probability increases from level to level. But the score reward increases as well.

Step 6: An Easter Egg

There is no level after level 42. Seriously. It’s the Ultimate Level of Life, The Universe, and Everything. :)

Step 7: Playing :)

Space Challenge

Participated in the
Space Challenge

1 Person Made This Project!

Recommendations

  • Game Design: Student Design Challenge

    Game Design: Student Design Challenge
  • Big and Small Contest

    Big and Small Contest
  • For the Home Contest

    For the Home Contest

2 Comments

0
arduinocelentano
arduinocelentano

Reply 1 year ago

Hello.
Thank you for sharing. A nice tiny Arduboy-killer game console. :)
In fact, I have one more LCD1602 game. Maybe I'll share it later.