[OUTDATED] Make Your Own Arduboy Game: Part 6 - Graphics!

Look up global and local variables.

If you define them outside of any functions, such as right after including libraries, the variables are global. You can access them anywhere within the program.

If you define variables in a code block, when you need them, they are local. They only exist and are only accessible within that block. They disappear when you exit the block and are re-created the next time you enter the block.

thats what i thought was happening, i wasnt shure so i didnt say so, there are one or two i could make local, but for the most part i use em all in multiple places

so i want to make a sprite with 2 images that rotate between the two, is there an example somewhere on how to do this?

Can you elaborate on this or give us an example of what you mean?

like say you want your charicter to apear to be walking, maby in one image his feet are together, in the next one is infront of the other ect

When you mean alternating between images i’ve once made a test project for ArdBitmap for myself trying some things. Check it out here on github.

With the Sprite class it would be simpler, but you won’t have any compression, but as said it was just a test.
But pls don’t judge me, it isn’t cleaned up and wasn’t meant for the public. :slight_smile:

if anyone wouldnt judge its me, have you seen how sloppy my code is downloaded, ill take a look tomorrow for now i am sleepy

So, what you are asking for is to swap between two or more images to make it look like a character is moving? Basically, you can use a variable to remember which picture you are looking at. Then swap every few frames.

1 Like

Great tutorial, Crait! is there a limit to the size of an image before using your conversion tool?


1 Like

I think for the Arduboy, it may be 128x128.

Third Coast!!! Aayyyyyy!!

Awesome, thanks for the information! I will tinker around for sure. Just needing my Arduboy to arrive in the mail now.

1 Like

What application is best for making the images in? Whats the most common?

I personally like http://www.piskelapp.com


I tried putting the text from the earlier tutorial in the setup () to try and get a title screen going before the graphics displayed, it only showed for a second before it was cleared out. how could i extend the time to be like a title screen before the graphics show?

You can do a dirty delay with delay(milliseconds);

Search for the arduino and Arduboy2 reference for help

1 Like

You could use the delay() function, but instead, what you should do is create an if statement that that changes based on a variable. We could call that variable, gamestate. If gamestate is 0 (gamestate == 0), then we want to show the text. If gamestate is 1 (gamestate == 1), then we want to display all the code that draws and handles player movement. We could also incorporate a way to change the value of gamestate with a button press. Of course, we’ll do all this inside of the loop section. Remember, the setup section is only run once and nothing stops the Arduboy from continuing on to the loop section.

Lemme know if this helps or if you need more explicit directions.

Would you mind expanding? or you can direct message

Check out my code for my super simple Rick and Morty Game: https://github.com/celinebins/RickandMortyGame

It uses the Case function to tell the code what to do next… So you get kinda like a title screen until a button (of your choice) is pressed.

A little more information in this article: https://issuu.com/arduboymag/docs/13524906647515680366/31

1 Like

GOT IT! Thank you!!!

1 Like