Make Your Own Arduboy Game: Part 6 - Graphics!


(Scott) #21

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.


(curly) #22

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


(curly) #23

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?


(Holmes) #24

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


(curly) #25

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


(Boti Kis) #26

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:


(curly) #27

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


(Holmes) #28

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.


(Jet Jaguar) #29

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

WAY TO REP US TEXAS BOYZ!


(Holmes) #30

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


(Holmes) #31

Third Coast!!! Aayyyyyy!!


(Jet Jaguar) #32

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


(Jet Jaguar) #33

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


(Erwin) #34

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


(Jet Jaguar) #35

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?


(Erwin) #36

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

Search for the arduino and Arduboy2 reference for help


(Holmes) #37

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.


(Jet Jaguar) #38

Would you mind expanding? or you can direct message


(Celine) #39

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


(Jet Jaguar) #40

GOT IT! Thank you!!!