Pixel Portal Game

I’m working on a 2D Portal-like game for the arduboy.

PixelPortal

Here is the code PixelPortal.

This time I tried to be more organized. I hope it will make it easier to fix and improve.

The character is just a pixel pecause I like the concept and also I thought it would give more room for more things in our little screen. But maybe it’s overextending on the simplicity.

gameplay

Now there are only 14 levels but it has a lot of potential for designing interesting rooms.

PixelPortal.ino.micro.hex (45.7 KB)

14 Likes

Is there cake?

1 Like

Yes but the cake is a lie.

It’s gotta be said, you are one of my favourite arduboy game devs :slight_smile: first longcat, now this, it’s a streak of awesomeness :muscle:

I love the mechanics … sometime you have to be moving left / right as you hit the portal to complete the moves. This is going to be good!

Yes, very good

Just to warn you, it’s a really bad idea to use new on Arduboy because it means the value reported as used memory will be inaccurate and you’ll be unable to predict how much memory your game actually uses. (If you want to know more, I can explain further. The short version is that it’s to do with dynamic allocation versus static allocation.)

Consider changing your portals and walls to be non-pointers and getting rid of the news.

Played thru all the levels in like half an hour this morning, really fun and I can imagine a ton of neat mechanics can be added to mix up gameplay. Looking forward to seeing this game grow.

Oh thanks for the heads up.
I used pointer and “new” because its the approach that I could make work.
I wanted an array of objects but if you would suggest a better alternative it would be great.

The proper way to have an array of objects (i.e. not pointers to objects) would be:

(Note that {} causes Portal and Wall's default constructors to be called for each array element, so you don’t need to explicitly call their constructors as you were doing before. I.e. you don’t need Portal() or Wall(), just using {} does that for you when you’re using objects instead of pointers.)

Of course, using objects instead of pointers means you need to use . instead of ->, so I’ve taken the liberty of doing all the conversions for you and turning it into a PR:

(I checked that it compiled, but I didn’t check if it still runs the same. Theoretically there’s no reason why it should appear to behave any differently to before, assuming I didn’t make any mistakes.)


Now, here’s the important bit, and why I brought up the issue in the first place…

Before:

Sketch uses 16364 bytes (57%) of program storage space. Maximum is 28672 bytes.
Global variables use 1358 bytes (53%) of dynamic memory, leaving 1202 bytes for local variables. Maximum is 2560 bytes.

After:

Sketch uses 15204 bytes (53%) of program storage space. Maximum is 28672 bytes.
Global variables use 1456 bytes (56%) of dynamic memory, leaving 1104 bytes for local variables. Maximum is 2560 bytes.

That RAM (‘dynamic memory’) increase isn’t actually an increase, it’s showing you memory that you were using before but couldn’t be measured because you were using new. In fact, it’s actually a decrease because you no longer need the memory you were using to store the pointers.

Notice that the progmem (‘program storage space’) has dramatically decreased. That’s because the functions that implement new have been expelled from your program because they’re no longer being used. It’s quite a large chunk of memory.

Hopefully you’ll agree that the saved memory and the ability to see how much memory you’re actually using is a significant improvement for relatively little work.

Omg pharap thanks a lot.

I was expecting a simple advice and being on my own to figure out how to really do it.

You are great.
And Dreamer2345 is also helping a ton with the longcat.

What an awesome community you (we) have here!!!

3 Likes

If you want any other help or suggestions, or have any other questions, feel free to ask.

1 Like

That’s a nice saving!

2 Likes

Great Game!

I had so much fun playing it, that I finished it in the emulator :laughing:

The last stage was hard!

2 Likes

Great little game, its very addicting.