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

Thanks for the support! I’m working on the 7th tutorial right now! I hope I’m done with it tomorrow!

3 Likes

Perfect! I’m just getting caught up with these tonight!

Great! What kind of game are you hoping to make?

I’d like to make a platform game or maybe an action game. I’ve got no C/C++ experience but I am OK at using Game Maker: Studio’s language (which I think is based on Lua?). I bought an Arduboy so that I could start learning ‘proper’ programming and challenge myself to make small projects that fit the console.

1 Like

Love your tutorials, can’twait!

Hey, ya’ll! Part 7 is out, now! Make Your Own Arduboy Game: Part 7 - Make Pong From Scratch!

2 Likes

Thank you very much. I might try to reproduce part of the book of graphics that I designed 30 years ago. I will put it out as freeware, of course!

2 Likes

The more the merrier! :smiley:

Thank you so much for your very helpful tutorials! I’m a total noob so this has been great to learn the basics.

I have been trying to animate a sprite with multiple frames but cannot figure this out. Been looking at other games code but it’s still confuses me! Can you please make a tutorial (or just explain how to code) on how a sprite can be animated and moved the same time?

Thanks again:)

1 Like

I have to admit that even with my experience in programming, trying to read the documentation for the Arduboy library and work this out isn’t easy for me never mind for beginners. There are several different commands for drawing sprites with or without masks and the documentation does a bad job of explaining how to use them. Also, how are the actual bitmap files generated and what format are the sprites, frames, masks, tiles, etc. all stored in that bitmap> it’s a mystery not made easy at all. A good clear tutorial on these things would be a massive help to us all.

2 Likes

I get this to work but my character goes out of the screen if i move it too much to the right for example… is there a way to set a boundary?

yes

im probably doing it wrong but i use locx and locy as variables
(loc short for location)
and only let the charicter move left or right if locx is greater than zero and less than 128
and only up and down if locy is greater than zero and less than 64

// move player forward one pixel if (ab.pressed(RIGHT_BUTTON) && (locx < 100)){ locx += 1; }

(though in that i didnt want the player to move more than 100 px right from zero)

2 Likes

@curly’s response is very close to what you want.

Instead of the standard left, right, up, and down input, I’d suggest something along the lines of…

    if( arduboy.pressed(LEFT_BUTTON) && playerx > 0 ) {
        playerx = playerx - 1;
    }
    if( arduboy.pressed(RIGHT_BUTTON)  && playerx + 16 <= 128 ) {
        playerx = playerx + 1;
    }
    if( arduboy.pressed(UP_BUTTON) && playery > 0 ) {
        playery = playery - 1;
    }
    if( arduboy.pressed(DOWN_BUTTON) && playery + 16 <= 64 ) {
        playery = playery + 1;
    }

Basically, if you push up, you’re checking to see if the player’s X position is at the left of the screen or not. If it’s not at the left-side, you’ll be able to move to the left. To check the right side, you need to add the width of the player to the player’s X location in order to check the right side of the player with the right side of the screen. Use the same logic for the top and bottom of the screen. If you’re at the top of the screen (playery would be 0), you shouldn’t be able to move up. If the player is at the bottom, then the playery + 16 will be equal to the height of the screen.

1 Like

im not seeing any difference besides you call your variable something different than i call mine and yours is bigger , from what i understand

playery = playery + ;

will do the exact same thing as
playery += 1;

You’re right in saying that playery = playery + 1; is the same as playery += 1; . I was just being more specific with my example as it pertains to the original code, just in case someone else was looking over these responses and wondering the same thing.

Thank you @crait for expanding on your example! Thank you too @curly, understood the logic behind your code but i was wondering how to define loc… :sweat_smile:

1 Like

now that one im 90% shure im doing wrong :stuck_out_tongue: i define all variables right after including the arduboy2 library, though i THINK you can define things as you need them, and that may even be better… er im a noob :stuck_out_tongue:

1 Like

And to make it even simpler:

playery++;

or

++playery;

(Ever wonder why it’s called C++? It’s because it’s one language higher than C, or an increment of the C language.)

1 Like

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