Continuing Studies

Hey. I’ve had my Arduboy for a few weeks now and have had a lot of fun playing with it, but it seems apparent to me that to make the kind of games for it I want to make, I need more knowledge. Unfortunately, I can’t seem to find an Arduboy library that works for my purposes or one I know how to operate to begin with without delving into concepts such as namespaces, operating on bits, and even concepts regarding dealing with memory addresses. It all started for my quest to take a sprite and flip it horizontally. The Arduboy2 library appeared to be incapable of this because sprite data is stored in PROGMEM, meaning each and every sprite must be held there. The Ardbitmap library seems to solve this using code more complicated than what I can understand but it doesn’t seem to work when I test it.

As it’s unfeasible to assume that the libraries provided already are capable of doing everything I could possibly want, it seems like the only way for me to progress is to learn more about C++ coding. I’m wondering if anyone has any advice for what to focus on, or any useful resources they’re willing to share.

I am not sure if this will help you get started, but I altered the Sprites library to rotate images in memory (90, 180, 270 degrees only) for rendering. You could use this for inspriation …

2 Likes

In regard to your original problem…

I’m not sure quite why Ardbitmap wouldn’t be working.
If you still want to solve that then I could perhaps look into it if you can provide more details of the situation.

In regard to solving the problem, it is solvable,
but it’s certainly not an easy problem to solve if you don’t understand bits, bytes and memory addresses.

The data being stored in progmem has no implication on the solvability.
Essentially what it entails is reversing the vertical order in which the pixels of the image are written to the screen,
but the Arduboy’s slightly awkward screen format makes it somewhat difficult to do in an efficient way.

If speed isn’t an issue then you could solve it the ‘naive’ way by just manually drawing the image ‘upside down’ using setPixel, but that would be quite slow,
which means it wouldn’t be suitable for more action-oriented games.


In regard to learning more about C++ and programming…

While you don’t need to know advanced concepts to write basic games,
if you want to get the best out of your Arduboy or develop more advanced games then eventually you will have to learn more advanced topics.

Understanding bits, bytes, RAM, progmem and pointers are an absolute minimum for understanding how to maximise memory usage.

namespaces aren’t as neccessary - they are simply a tool to help with organising code and helping to prevent name clashes.

For learning more about C++ I recommend the tutorial on this website: https://www.learncpp.com/

There’s also some good advice in the ISO C++ FAQ: https://isocpp.org/faq

For other concerns, I refer you to the rest of my Resource Collection, particularly the sections about C++ and general programing.
(I still lack links for explaining certain concepts, but it’s a good start.)

I particularly recommend reading “What I tell all new programmers” and “How to Program”,
because there’s more to programming than just learning a language or telling a computer what to do.

At its heart, computer programming is actually about problem solving,
programming languages are simply the way the solution is expressed and implemented.

Lastly, don’t be afraid to ask for help if you need it.

2 Likes

If you grab my project, I have included a flag to flip vertically - I have only done it for one mode but search for flipHoriz in the code and you will see how easy it was. I can implement the other modes if you need.

I have a bit of experience with ArdBitmap albeit with the compressed images. I have discovered a number of issues when the image is not an even number of pixels wide and not a multiple of 8 high. What problems are you experiencing?

It threw up a billion errors, I couldn’t even begin to understand them. And upon looking at your code for rotating/flipping sprites, I’m not sure I understand how it’s accomplished there either, although I might not need to as long as I can use it correctly. It’s probably my fault but I don’t know what to fix as it seemed like I followed the instructions. The example code seems to work fine but it uses Arduboy, not Arduboy2. I didn’t bother looking for help on it because it seemed like up until that point I had found an obstacle at every turn and it felt like if someone just spoon fed me how to use it, then I was liable to run into more obstacles later anyways.

Thanks for linking those resources. They look useful, I’ll take a look. The issue of flipping sprites I know is solvable but I just lack the understanding to get it working or use someone else’s code apparently. The game I’m trying to make is a clone of the old v-pet Digimon toys, and I’m trying to make as much room to put monsters in the game as possible. If I have to mirror each sprite and store them both in PROGMEM that will take up a lot of space. I could also save even more space by breaking the sprites down and using various methods of masking to build each sprite out of reusable components, but I’m not sure how to do that intelligently either. Speed should not be an issue as I’m not even running the game at 60fps, and there shouldn’t be much going on most of the time. Even if it does lag a little I don’t think it will make a huge difference.

I started trying to make a clone of the D-Terminal once.
I only got round to making sprites, but I covered the whole font and multiple settings screens.

A small sample:

DManSelect

Your biggest problem will probably be fitting the sprites in.
Graphics tend to use the most room.

I just realised that when you said ‘horizontally’ you probably meant inverting the x axis, and I was assuming the y axis.
Flipping on the x axis is somewhat easier.

If you don’t have any luck with @filmote’s library then I might be able to help with that.

Horizontal flipping is easier because you can just change the order that you write the bytes in,
all the bit shifting and masking is the same as it would normally be.

That’s only really plausible if you design the monsters to be that way.
That’s a good approach for animation though.
That’s what Paper Mario TTYD did.

1 Like

Ah that’s cool! If you ever want to continue with that I know some people who would be really into it.

Yeah, and I did rearrange the array like you said. Problem was, of course, the arduboy drawing functions expect it to be in PROGMEM and I have no idea how to convert successfully.

Hrm. I’ll have a think about it.
I didn’t think anyone would be that interested,
it’s just something I started doing on a whim.

It’s not just a matter of rearranging the array,
you’d have to actually write a custom rendering function.

Like I say, try @filmote’s library first:

If you want to have a go at writing it yourself then I can help explain the things you need to know, but you’ll need to understand (at a minimum):

  • Memory
    • RAM
    • Progmem
  • Pointers
  • Bytes
  • Bits
  • Bitwise operations
    • Shifting
    • Anding
    • Oring

I’d recommend just using filmote’s library for now.

I have created a new repo https://github.com/filmote/SpritesExt that is the basic Sprites library with a simple flip horizontal parameter.

It is working for most scenarios but still needs a little TLC when the image is partially on the right hand side of the screen, as shown below. I have run out of time today - maybe you can fix the scenario and submit the changes back to me?

ArduboyCapture%20(17)

2 Likes