[Closed] Pre-Games Jam 5 Warm Up

I have the base game created here. It’s bigger than any code I have request for a code review, but if you have a few moments; do you mind running and giving any feedback?

This is my first full game minus sound. :slight_smile: Proud of it, but don’t hold back on constructive criticism.

I was only going to have a quick skim and wait until I could do a proper review before discussing any of it, but I think the fact you have a memory leak is a big enough of an issue to address immediate.

When you use new to dynamically allocate something,
you always have to delete it when you’re done with it.
But you’re not deleting sequence, you’re just allocating more memory and storing the pointer, meaning the original pointer pointing to the memory that needs to be deallocated is then unreachable, which is practically the textbook example of a memory leak.

But even if you didn’t have the leak and you were deleting things properly,
I’d be advising you to get rid of new and delete.
The Arduboy only has 2.5KB of RAM, of which 1KB is taken up by Arduboy2’s statically allocated frame buffer, and an unspecified chunk is required for the call stack, which basically means there’s not enough memory to reliably support dynamic alloction.
If you try to use dynamic allocation, you’re likely to hit a memory fragmentation issue very quickly, hence it’s not really viable.

Use a fixed size array instead, it’s much safer.

There’s a number of other things I’d like to address when I get chance, but this one is really important because it actually has the potential to cause the Arduboy to crash (or worse, start behaving oddly whilst still running) after a certain number of calls to resetGame.

1 Like

I was trying to allow for the ability to increase the sequences via sequenceLength by incrementing it each win. I suppose I could make it the size of 10 and only check the first 5 and increment the max index till the length of the array.

I saw a post about cleaning up a dynamic array or not using them at all. I ignored it out of convenience laziness ignorance, but I was aware of this. I was not aware of the memory leak issue, so thank you for pointing that out.

I would really like to learn what you find if you have time. :)

1 Like

I thought of a very quick and simple memory game. Will see how it turns out. I’ve got a basic stick figure drawn with 1 frame per animation, but it should be interesting. Once I’ve got everything done if an artist (such as @Vampirics) wants to step in and do some simple, but better, animations they’d be more than welcome to.

Should I share the overall concept or leave it as a surprise for when it’s done?


This post kinda is turning into a more free form warm up and discussion. I would be floored to see your code for a simple game. A repo link to follow progression would be choice.

There are a lot of amazing developers on here and going through their code is great, but my experience to traverse C++ code in a educational manner is limited. A small game with tight code is what I secretly was hoping from this post. :P


Seeing animation in a simple game would also be very educational for me.

That’s actually what C#'s List<T> and C++'s std::vector<T> do internally.
They allocate enough memory to store N objects (where N is usually a power of two), even if they don’t need to store that many objects, and then gradually increase their Count/size until they hit their Capacity/capacity.
Then when they finally reach the end and another Add/push_back is requested, they finally allocate a new buffer that’s twice the size of the old one and copy the old memory across.
(std::vector<T> actually often uses pointers rather than tracking the number of elements for some reason. I’ve always assumed it’s believed to be more portable but I don’t know for sure.)

In this case though you wouldn’t be allocating more.
It might seem strange to have a fixed upper maximum,
but remember that all computers (even desktops) have a hard limit on how much memory they have,
so in reality you always have a fixed upper maximum.
It just happens to be that in this case the programmer chooses the maximum and can detect when it’s been reached.

You could probably fit more than 10 if you want.

The former link is a bit muddled, but the latter link is a good one.
(Particularly my follow up comment… mainly because it features that neat little doodle about heap fragmentation from “Munificent” Bob Nystom’s Game Programming Patterns book.)

And not the good kind.

Will do.

You could do both by putting it in a [details] block so people can choose whether to read it or not.

I really enjoy this type of in depth back and forth on the nuts n’ bolts of C++/ and what is happening in the back end you provide.

Honestly, learning C++ has given me a much greater understanding of programming in an efficient manner and not the hey it works, on to the next feature mentality I get into while at work.

1 Like

Here’s the github link: https://github.com/tuxinator2009/Arduboy_MemoryRhythm

Those who wish to have it remain a surprise can ignore the link for now.

@Pharap has always been an ever present, and valuable, resident expert in c++ that’ll gladly help anyone out be it silly mistakes by people new to c++ or common gotchas made even by veterans.

He’ll also gladly chat your ear off if you let/ask him :P


Woo! Thanks for contributing to the post and my sneaky ploy to learn from simple games by sophisticated developers!

As you can see there is literally nothing but empty files (even the INO file is just an empty setup and loop functions with no includes or anything). Going to try and commit each stage from project init, setting up includes and dependencies, and make commits each step of the way so you’ll be able to somewhat follow along with my process (though it’s been a bit).


You keep your cotton-picking hands off @vampirics - I have him busy on another project :slight_smile:


Sadly I get the impression that’s quite common.

That and the attitude that all customers are going to have 3GHz 8-core CPUs and 16GB of RAM to burn through, and that the software being written is somehow entitled to actually use all of that and it doesn’t have to share it with other software.

I’d best stop there, lest I climb on a soapbox and rant on for 8 more paragraphs.

Emphasis on anyone. (I’m really not that picky…)

This is true.

Paradoxically I’m actually quite quiet in person.
I find typing much easier than talking.

That’s a fork of Eried’s repo presumably created to upload or update one of the games on it.

@lyellick, I’ve written a preliminary wall of text.
I’m on the fence about whether to post it now or wait a bit in case more things occur to me.


Well it’s coming along nicely so far at least. I’ve got the generator working to create an infinite sequence requiring only 8 bytes of data (2 uint32_t variables one for the initial seed to repeat the sequence from the beginning and one for the current value in the sequence).

Hehe :stuck_out_tongue:

1 Like

I removed that blur from that post because I noticed it was really a fork a few moments ago.

I’ll take it. :P

This struck a cord in me for some reason. More so from the standpoint of applying that to different industries, which would be an interesting discussion.

Disclaimer: I didn't take this personally, hope you don't read this as that. Just talkin' with ya.

I do get complacent in development by leaning on the vast memory and processing power a server(s) provides. I work in automating cloud infrastructures and use frameworks and a higher level language, higher not implying superior, to complete tasks. I don’t have to worrying about the lower level processes/resource handling. Allowing the framework to handle things way better than I could build within a sprint or direct my team to complete within the scope and on time. I do rely on the fact the code being run on a system has more than enough resources to handle it even though the code is not optimized to a T.

To me it comes down to:

  • Is it maintainable and inline to what the framework provides and does well?
  • Did we build something that wont cause another developer to say WTF?

Now, if I were a developer who only worked on systems with a finite amount of resources I would have a totally different mentality on how the code was written. With developing on the Arduboy I do have the incentive to build light software to the best of my knowledge until I learn a better way. I have to else I get memory leaks or use resources too quickly.

To your point…

Is it really entitlement or is that comment more for development on finite systems? By developers who come into it with the mentality it will be run with the 3GHz 8-core CPUs and 16GB of RAM to burn?

I think the disconnect between your comment and how I took it is which customer/scope are you focusing on. Not saying striving to develop the leanest application to run on any system can’t be applied to any industry. That being said is it really transferable to all industries in a way it positively affects velocity?

I personally would like to hear your soapbox/perspective. From what I have seen in your code is you have a mature and polished knowledge of development practices and a solid philosophy based off people who built the foundation.

It would be refreshing to hear your soapbox/perspective and you have a eager ear.

Here’s my submission:


A post was merged into an existing topic: [WIP] September

Don’t want hog this post anymore than I have, but I’ve read through your post and will start applying this to my games jam 5 game.

If you make a separate topic/thread for your game like @tuxinator2009 has then I can migrate the assessment/review to that thread.

1 Like

@tuxinator2009 wins by being the only person to submit! He also wins by being a good guy. <3

Thanks for contributing. I think the best thing to come out of this was having a game that was super simple which applied fundamentals anyone can learn from.

Have a fun Game Jam 5!


Thanks it was kind of fun to make something really basic and simple. Your theme got me thinking about the old classic Simon Says and the idea just popped in my head to have a figure do a different pose for each button press to give it some life (ie. make it look like a random dance). Then I wanted to keep it incredibly simple so as to help be a good demonstration for beginners and newcomers.