Close
0%
0%

1-Pixel Pac-Man

Retro-gaming just got fewer pixels

Similar projects worth following
I created 1-Pixel Pac-Man using a 32x32 RGB matrix which is part of the SmartMatrix bundle. A Teensy 3.1 drives everything, with an Atari Joystick for control.

The original coin-op Pac-Man divided up the playing area into a grid of 28x31 boxes. This concept fits perfectly on the Smartmatrix, leaving room on either side for extra lives, and score (in binary).

Writing something like this yourself is an excellent coding exercise. The logic rules for the game are pretty simple, but there are a lot of them. As everything comes together the complexity builds and it becomes a challenging, yet rewarding exercise.

I wrote a blog post about this project which talks quite a bit more about the hardware. I also made a video to show off the game:

Hardware setup is pretty simple. Follow the assembly instruction that Louis posted. I'm not sure what I plan to do in the future, so I used the surface-mount pads on the back of the Teensy for the Atari Joystick. I used a ribbon cable, and instead of soldering the Teensy in place i used my own pin sockets. There are actually enough extra breakout pads on the back for two joysticks and I may write some head-to-head games in the future.

The Atari joystick uses a standard DB9 connector, which I soldered at the other end of the ribbon cable. I'm limiting the display brightness to 50% (which is still really bright) which keeps this application's current draw below 2A. That makes it possible to power the game with an external cellphone battery so I've connected a USB cable to the terminals on the LED module.

Future Improvements:

  • Animation when player is eaten by enemy
  • Pause between starting the level over or starting new level
  • Display score in decimal when game over
  • Add High Score screen and initial entry
  • Audio (this has to happen!)

  • 1 × Smartmatrix Bundle Hackaday Store
  • 1 × Teensy 3.1 Hackaday Store
  • 1 × Atari Controller eBay
  • 1 × DB9 Connector eBay
  • 1 × Ribbon Cable Bench extras

  • Joystick fixed with bamboo skewer

    Mike Szczys05/31/2015 at 17:34 0 comments

    Bamboo skewer, hot glue, a Dremel, and a drill are all it took for me to fix this broken Atari controller (mentioned in my previous project log).

  • Arduino IDE "includes" solved

    Mike Szczys05/31/2015 at 16:13 0 comments

    I wrote most of the code for this before I had the hardware. To do so I wrote a "hardware emulator" using the SDL2 library. This is great because I could work on it when all I with me was a computer.

    The problem came when I went to load it onto the Teensy 3.1 using the Arduino IDE. I had abstracted out all of the display and control specific stuff so that portability would be easy. But when I tried to compile, there were "undefined" errors for every function.

    I had correctly included the prototypes for each function in the header files, so I assumed the issue was that the linker wasn't pulling in the .c files. When I changed the name of the .c files to .cpp it work. How frustrating!

    Turns out the issue is that Arduino is compiling the .ino files as C++. This causes two issues:

    C Functions must be declared with EXTERN

    The .c files were getting included, but I need to tell the compiler to treat my C functions as C and not as C++. There is a helpful thread on the Arduino forums that shares the answer. You need to wrap function definitions within header files in some magic:

    #ifdef __cplusplus
    extern "C"{
    #endif
    
    void cFunctionPrototype1(void);
    void cFunctionPrototype2(void);
    
    #ifdef __cplusplus
    } // extern "C"
    #endif

    C99 won't work with C++

    I also like to define local variable in "for" loops using the C99 standard. That won't work at all with a C++ compile (apparently):

    for (uint8_t i = 0; i<7; i++) { }

    needs to be:

    uint8_t i;
    for (i = 0; i<7; i++) { }
    

  • Oh Noes... Crappy Joystick Design

    Mike Szczys05/30/2015 at 18:55 0 comments

    I took this project to the LayerOne conference with me last week and a lot of people had a fun time trying it out. Unfortunately the Atari joystick broke. I don't think it was overused, and cracking it open it just looks like poor engineering:

    You can see the little white "wing" that is hinged on the bottom of the white joystick plastic. This hing is integral to pushing down on the PCB clicky buttons so super-glue is not an option.

    I've ordered another one, but I'd like to have 2 anyway. I think it may be possible to repair this with a couple of bamboo skewers and some hot glue. If I have success with that I'll post a project log as an update.

View all 3 project logs

Enjoy this project?

Share      

Discussions

jeff courington wrote 06/03/2015 at 18:08 point

What version of the Arduino IDE are you using? Under 1.6.4 the compile get's stuck on the .elf link and never finishes. The project compiles under 1.0.6 but numerous functions need to be declared static to avoid duplicate symbols during the link.

  Are you sure? yes | no

Mike Szczys wrote 06/03/2015 at 18:11 point

I've been using 1.6.3

  Are you sure? yes | no

jeff courington wrote 06/03/2015 at 18:25 point

Thanks for the quick reply. 1.6.3 works but I still get the duplicated symbols. I defined everything static that the compiler was complaining about and it completes. Not sure why I have to make changes but it is compiling so now I just have to wait on USPS to get my kit!

Awesome project!

Make that FedEx, just got the shipping notification!

  Are you sure? yes | no

Mike Szczys wrote 06/03/2015 at 18:47 point

I know there are some warnings for type errors that are still in there but it should compile just fine. I was using a different var type on my hardware-emulator branch than the Smartmatrix library is expecting. But other than that it should compile just peachy.

  Are you sure? yes | no

jeff courington wrote 06/03/2015 at 19:58 point

Thanks Mike. I just compiled it on a second machine (Windows 8.1 on both) using 1.6.4 without needing to change anything and it finished without issue. Something must be strange on the other system.

  Are you sure? yes | no

jeff courington wrote 06/03/2015 at 22:46 point

Just tried it on a 3rd machine (laptop windows 8.1) and had the same problem as the first. 1.6.4 does not complete the elf build. Downgrade to 1.6.3 and needed to add static to get the build to finish. Hopefully this will help someone else if they run into it also.

  Are you sure? yes | no

Michele Perla wrote 06/01/2015 at 09:14 point

Dude this is the coolest idea I've ever seen implemented on a 32x32 LED matrix! 

Cheers, Mick

  Are you sure? yes | no

Mike Szczys wrote 06/01/2015 at 16:00 point

Thanks! I had already done Tetris and Snake (on different displays) so I wanted a bigger challenge. This turned out to be a lot of work to implement but it was a lot of fun too.

  Are you sure? yes | no

frankstripod wrote 05/31/2015 at 23:16 point

I cringe a little when I see wires soldered to pads without a strain relief, maybe I have pulled off too many, but I thought of your project when I saw this: https://forum.pjrc.com/threads/26071-Using-all-Teensy3-x-pins-with-a-socket

2x14pin header, inner pins replaced with 90deg pins. Otherwise, I hope you get some relief :)

  Are you sure? yes | no

Mike Szczys wrote 06/01/2015 at 01:45 point

Yeah, I usually hot glue the cable to the board... Still need to do that!

  Are you sure? yes | no

frankstripod wrote 05/31/2015 at 22:27 point

Hi Mike. The video is marked private :( May we see it? Nice hack bamboo master!

  Are you sure? yes | no

Mike Szczys wrote 05/31/2015 at 22:28 point

Well, you know how these things go... Set to publish with the post at 0700 PDT tomorrow. ;-)

  Are you sure? yes | no

frankstripod wrote 05/31/2015 at 22:29 point

:)

  Are you sure? yes | no

Wancheng Zhou wrote 05/30/2015 at 15:28 point

That's so cool! :) 

  Are you sure? yes | no

tehaxor69 wrote 05/30/2015 at 14:52 point

That looks cool.

I'll try out Pac-Man with my 64x32 RGB LED Matrix.

  Are you sure? yes | no

PinheadBE wrote 05/30/2015 at 06:41 point

Looks great!  Thanks, Mike. Can't wait to see more...

  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