[Game]cPong [WIP]

action
game
release

#1

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.


EDIT: YOU CAN TRY THE GAME OUT NOW, DOWNLOAD BELOW:
cpong.bin (55.0 KB)


#2

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!


#3

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!


#4

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);

#5

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


#6

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.


#7

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.


#8

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);
  fileSetPosition(0);
  filePutChar(byte1);
  fileSetPosition(1);
  filePutChar(byte2);
  fileClose();
}

char readHiscore() {
  char tempByte;
  char tempHiscore;
  fileOpen("hiscore.txt",FILE_MODE_READWRITE);
  fileSetPosition(0);
  tempByte = (char)fileGetChar();
  fileSetPosition(1);
  tempHiscore = tempByte * 256 + (char)fileGetChar();
  fileClose();
  return tempHiscore;
}

#9

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!


#10

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

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

short readHiscore() {
  short result;
  fileOpen("hiscore.txt",FILE_MODE_READWRITE);
  fileSetPosition(0);
  fileReadBytes(reinterpret_cast<uint8_t *>(&result), static_cast<uint16_t>(sizeof(result)));
  fileClose();
  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.)


#11

It works fine :yum:


#12

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.


#13

Looks very inviting!


#14

Lots of floating point calculations?


#15

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.


#16

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.

Enjoy!


#17

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

edit:done

Thanks for a great game @trelemar !


#18

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.


#19

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.


#20

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 !