[Game]cPong [WIP]



cPong! - Single player circular pong mayhem!
Hey guys! For my first actual project I started remaking one of my old games. You can play the original TIC-80 version here!

cPong is very easy to play, but quite challenging. It is a variant of the multiplayer classic “Pong”, but with a mechanic tailored to single player. In the standard game mode, your objective is pretty simple: Keep the ball inside the border for as long as possible.

The game will (eventually) feature 3 different game modes:

  • Standard
  • Extreme - Ball speed increases over time, for the pros.
  • Multi - 2x balls, twice the challenge.

Once I get an SD card for my Pokitto I can implement a high score saving feature.

cpong.bin (55.0 KB)


If you need help with saving, I might write a tutorial on that this week :slight_smile: I figured it out the other day, so it’s fresh in my mind!


That’d be pretty cool. Honestly I haven’t even tried yet with the simulator so if I have trouble I’ll definitely let you know!


The docs say EEPROM works the same as Arduino so saving to EEPROM should be as simple as:

EEPROM.put(eepromAddress, highscore);

And loading:

ulong highscore = EEPROM.get<ulong>(eepromAddress);


yep. and if you avoid saving in say lowest 256 bytes we wont have conflicts at this point in time


Looks great, I love the particles!

I remember this being one one of the first games I ever made! I did have issues with the predictability of the ball considering you’re playing with 180 degrees on the inside of the circle.


Yeah, coming from Lua I’ve had the ball react in some weird ways. I realized that it’s a sign issue, so calculating the angle then adding pi to that works alot better. My new issue is the ball seems to bounce off the player at different speeds, which makes absolutely no sense to me considering sine and cosine compliment each other and I should get the same velocity no matter the input angle.


If you need help saving a short to SD card, assuming you’ve followed my tutorial, here’s some code for saving a short instead of a char (don’t know if this works – I think it will, but I haven’t tested it out yet):

void saveHiscore() {
  char byte2 = hiscore % 256;
  char byte1 = (hiscore - byte2) / 256;
  fileOpen("hiscore.txt", FILE_MODE_READWRITE);

char readHiscore() {
  char tempByte;
  char tempHiscore;
  tempByte = (char)fileGetChar();
  tempHiscore = tempByte * 256 + (char)fileGetChar();
  return tempHiscore;


Awesome thanks! You definitely saved me some time figuring that part out. Looks pretty straightforward. I haven’t tried saving yet, as soon as my Pokitto is functional I’ll let you know how it goes!


I’m not trying to undermine you here, but I think there’s an easier way:

void saveHiscore() {
  fileOpen("hiscore.txt", FILE_MODE_READWRITE);
  fileWriteBytes(reinterpret_cast<uint8_t *>(&hiscore), static_cast<uint16_t>(sizeof(hiscore)));

short readHiscore() {
  short result;
  fileReadBytes(reinterpret_cast<uint8_t *>(&result), static_cast<uint16_t>(sizeof(result)));
  return result;

I admit I haven’t tested it, but I’m fairly certain it works.

(Also the second fileSetPosition in each function is redundant since the API is for sequential file access - it already advances the file position every time a byte is read.)


It works fine :yum:


Current look with the new title screen. Also, @VonBednar was able to test for me and reported back that the game is running incredibly slow on HW. I’ll have to tone some effects and stuff down a bit when I can test for myself. The game it’s self though is pretty much finished.


Looks very inviting!


Lots of floating point calculations?


Yes, as well as mutiple sin calls in loops that I don’t think is really needed. I can just do it outside of the loops. I think I’ll be able to optimize. If not the particles will be the first to go.


bin file added. I had to remove some effects and stuff. Circle drawing was taking a huge toll on framerate. To achieve the thick circles I was drawing 2 filled circles.



Haha! The games page PHP script is not picking up the game because it starts with a small letter. I’ll fix that.


Thanks for a great game @trelemar !


Thanks Jonne! I’ve been messing with some other stuff as well. The lowres mode runs way faster than I was expecting. It’s pretty awesome! Hoping to come up with something a little deeper next.


Yes, that is, in addition to having 1/4 of pixels of Hi-Res mode, because Lo-Res drawing is optimized. Hi-Res drawBitmap is not yet optimized.


Does anyone know the math involved in translating an xyz (pitch roll yaw) accelerometer output to control the ball ??

I just got ADXL345 working and thought of hooking it up to this game.

Meeting some investors from Japan tomorrow. Wanted to make a demo #itsonly8pm !