Close
0%
0%

Retro Racing Game on a 16x2 Character LCD

Implementing an animated classical game on 1602 character LCD.

Similar projects worth following
Imagine the nostalgia of playing a classic arcade game on a small, pixelated screen. With a 16x2 character display, you can bring that experience to life in a fun and interactive way. Although it provides only text output, you could create up to 8 custom characters and map your logical game space to 16x2 character matrix, as I did in my 👾previous LCD game. This time I am going to push hardware limits a little bit further to create more sophisticated animation.

💡 In the video, you may notice subtle textures resembling moving asphalt. This isn't a glitch; rapidly turning pixels on and off on this type of display creates a grayscale effect. Play with contrast of your display to see it.

Animation Techniques

For this project, I utilized a game "engine" from LCD Invaders game. It maps 16x4 game field to 16x2 LCD. But instead of implementing a custom character for every state of the sprite I designed a sort of code-pages approach. Think of each sprite as a deck of cards containing various animation frames of the same character. By rapidly switching these "cards" (custom characters), we can create the illusion of animation on the screen. Through experimentation, I discovered that using lcd.createChar() is significantly faster than lcd.print(). Although we are still limited to displaying only 8 custom characters at a time, we can swiftly replace them to achieve an animated effect across the entire screen.


Game Over?

Looking to level up your gaming experience? Dive into customization by personalizing this game or crafting your very own masterpiece using the same animation technique. Get creative with the spritemap array to give your sprites a unique look. And why stop there? You might also want to port the game to a 20x4 character LCD to have enough space for implementing curved roads.

Share your ideas in the comments below!

lcdrally.ino

Arduino sketch

x-arduino - 11.42 kB - 07/23/2024 at 06:06

Download

  • 1 × Arduino UNO board Or another compatible board
  • 1 × LCD keypad shield Or bare LCD and a couple of push buttons, if you like.

  • 1
    Step 1

    Schematics

    Unless you are strong enough, it is nearly impossible to connect the LCD shield incorrectly. In case you decide to use a bare LCD, I have attached its schematics as a reference.

    Customizing the Controls

    Please download the attached Arduino sketch and open it with Arduino IDE. If your LCD shield is different from mine, you'll probably need to tune ADC button values in the buttonPressed() function. If you decided to use separate push buttons on digital pins instead, your buttonPressed() function would be structured as follows, assuming pins 2 and 3 are used:

    byte buttonPressed()
    {
     if(!digitalRead(2))
       return btnDOWN;
     if(!digitalRead(3))
       return btnUP;
     return btnNONE;
    }


    Uploading the Code

    Connect your board, choose the correct port and press "Upload" button.

View all instructions

Enjoy this project?

Share

Discussions

Alexey Vazhnov wrote 07/25/2024 at 15:48 point

Awesome project!

@arduinocelentano , could you please publish the code (and maybe the whole project) under some opensource license? So other people can re-use it and improve without legal concerns :)

  Are you sure? yes | no

arduinocelentano wrote 08/15/2024 at 17:02 point

Thank you for your feedback! In fact the code is attached to the
project, see the “Files” section. Feel free to use it under GNU
GPLv3. Maybe I’ll upload it into a GitHub repository after some
tuning and fixes.

  Are you sure? yes | no

Alexey Vazhnov wrote 08/15/2024 at 17:14 point

GPL v3 — awesome!

It would be great to see the code in any git repository.

  Are you sure? yes | no

Dan Maloney wrote 07/24/2024 at 00:37 point

Very cool! Loved you LCD Bad Apple, too. Wrote this up for the blog, should publish soon. Thanks for posting, and good luck in the contest.

  Are you sure? yes | no

arduinocelentano wrote 07/24/2024 at 16:05 point

Thank you very much for your feedback and your interest in my projects!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates