Programming Tutorials

Does anyone know of any tutorials on how to make a video game or when the internet guide will be finished? Thanks!

@ante,
you can find a basic coding tutorial here:


We do plan to release some new tutorials in a matter of weeks.

I do not know what internet guide you’re talking about…

Thank you for supporting MAKERbuino!

1 Like

Thank you, I was thinking about the pong tutorial on your site.

1 Like

Hum i don’t know, i’m not sure that i don’t make a mistake but i think you are talking about this tutorial: https://gamebuino.com/fr/academy/workshops/pong
This Tutorial isn’t make by Abert team but by the Gamebuino Team. Yes we have two team to support our consoles. Great isn’t it :wink: Ihope it’s the tutorial you was searching and i wish you’ll make some great games soon for the both communauties.

2 Likes

I was thinking about this one:


But I didn’t know there’s one on the Gamebuino forum. Thanks!

1 Like

Great :wink: Yes other is in progress and not yet published but Bl4ckM4ch1n3 make very good tutorial and his version will be very interesting too and i hope he will have some times to complete it soon.

2 Likes

@Jean-Charles_Lebeau, @ante,
In fact, @Bl4ckM4ch1n3’s tutorial is going to be published on the MAKERbuino learning system and is mostly finished, I just need to port it to the web and edit it a little bit (sorry for the wait, I’m working on it…)

1 Like

It’s time to works Albert :wink: No, i was joking. Nice news.

2 Likes

im also searching some beginner tutorials to create your own game. but there is almost nothing.

building the makerbuino was super cool, but programming is frustrating hard.

OK, you can have a look on these tutorials:



Gamebuino Tutorial: How to get new games!: https://www.youtube.com/watch?v=PBBIgyo_PDM
this french tutorial: http://www.open-consoles.com/t7162-tutogamebuino-programmation-gamebuino-mon-1er-programme

I hope you’ll find what you need and i’m sure you can find some other good tutorials to make games.
If you need a specific help on something, just ask us to complete the pages

1 Like

Thank you for the links, but of course i know these official Tutorials.
french tutorials just confuses me more…
The ready to use Examples are not a step by step tutorial how to programm a game…

OK, so the tutorials Hello world and pong are step by step i think but else, you will find maybe something that could help you below:

Program skeleton
Before getting into game development, let’s talk about the basic structure of a program. The library requires a bit more elements than a generic Arduino program.

A Makerbuino program

The basic structure
The basic structure of a Gamebuino program has a few things more:

#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;

void setup()
{
gb.begin();
gb.titleScreen(F(“My game”));
}

void loop()
{
if (gb.update()){
}
}

The 2 required libraries
The 2 first lines with #include are to use the required libraries:
• SPI is a communication bus, which is used for the screen in the case of Gamebuino.
• Gamebuino is the library with all specific functions developed for Gamebuino and Makerbuino. You can see the list on the reference page

The declarations
Next is a list of declaration. It’s here that you will declare all your global names of objects, constants or variables but
The gb object is a handle to the console parts. All the function and variables names starting with gb because you access them through the gb object. You can rename it of course, but I don’t recommend it. You will probably make copy/paste errors when using the reference.

The 2 mandatory functions

The setup function is called once at startup (or reset).
In the setup function, we start with a call to begin, which initializes the handle. Call it before any call to any other function from the library and then call titleScreen to create the… title screen. The parameter of this function is the name of the program, which is displayed. You can add another optional parameter with the name of the picture that you will show on this title page but we’ll explain it later. To show how useful is the reference, please read this page. It answers most of the questions you may have about the title screen. As I will discuss later: it is important to always have a button (usually C) mapped to a call to titleScreen otherwise your program would be trapped without the possibility to return to the Gamebuino main menu.

The loop function is repeated until the device is turned off or reset.
In the loop function we use this condition if (gb.update()) because the logic of the game runs at 20 frames per second, which you can modify with setFrameRate.
The loop function is called more often, because the microcontroler (ATmega 328) runs at 16MHz. This means it runs roughly 16 millions of instructions per second. The actual frequency of the loop function depends on the number of instructions executed in one call, which is unlikely to be the same at each call. Anyway, the thing to remember is to write your code inside this if, unless you know what you are doing.
You can already compile this program, and run it with an emulator, or the console. However beware with the console, there is no return to the menu yet.

Enter the code in the Arduino Software
Launch Arduino Software
In menu File, click on New (or press “Ctrl+N” if you use Windows Windows or “Cmd+N” for Mac OS X) and choose the name of your program. This program will have the extension “ino” on your harddrive when you’ll write it.
You can copy the code of the section “A Makerbuino program” and past it in this new Windows.

Uploading your first program in your Makerbuino
We have five buttons available in Arduino Software:

The first button to the left is « Check code »

This button request to the software to check that the code written is conform as that the compiler can compile. Let’s go, click on it and you will obtain a new text on the bottom of the Windows of your program. This text depend of course of your language.

This mean that there is no error in the code and that the compilation and the transfer to Makerbuino can be done. If you remove a semi colon or an accolade and try to check the code, you will obtain some error message at the bottom of your code windows.

The icone « Upload »

This is the button that points to the right in the Arduino environment. You can also use the keyboard shortcut Ctrl+U for Windows or Cmd+U for Mac OS X.
You’ll have a message like below if you success.

Now, you know how to build an empty program. It’s time to learn how to do something with that

Basics
When you start creating your game, you should have included these file:
#include <SPI.h> (To communicate with the Gamebuino’s screen)
#include <Gamebuino.h> (To get the pre made library)
Gamebuino gb (To create a Gamebuino object named gb)
Then, you’ll need to initialize the Gamebuino object in the setup function using this: gb.begin(); and display the menu using the gb.titleScreen function: gb.titleScreen(F(“The name of your game”));
For now, your code should look like this:
#include <SPI.h>
#include <Gamebuino.h>

Gamebuino gb;

void setup () {
gb.begin();

gb.titleScreen(F(“My game”));
}
Customize the title screen
The function gb.titleScreen display only a title, to display a picture, create an 8x8px up to 64*30px PNG/JPG/etc. file and upload it on the Bitmap encoder in the Download, If you want to edit it later, take the binary with multi-line (Wrap output line = true) or if you want it in one simple line choose hexadecimal with a single line (Wrap output line = false)
Bitmaps
Do you want to create a bitmap? or maybe create a map of them? It’s here
Create a bitmap
Note: If in your game, you enable persistence, you’ll need to draw the bitmap each frame.
First, you need to create the bitmap on a byte array like this: const PROGMEM byte Name[] {
/The size of the bitmap/
8,8,
/The bitmap itself/
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000
}; (You can make it using hexadecimal but it will be harder to modify after.)
0 = a blank pixel/white and 1 = a black pixel
Draw the bitmap
To draw a bitmap, use :
gb.display.drawBitmap(x, y, bitmap, rotation, flip);
First, there’s the coordinate to draw on the screen, x and y. Replace bitmap with the name of the bitmap (It’s “Name” in the exemple above). Rotation and flip are optional, replace rotation with NOROT (Not rotation : 0°), ROTCCW (Rotate counterclockwise: -90° or 270°), ROT180 (180 Rotation : 180°) and ROTCW (Rotate clockwise: 90°). For flip, use NOFLIP (No flip), FLIPH (Flip horizontally), FLIPV (Flip vertically) and FLIPHV (Reverse the bitmap, vertically and horizontally).

to be continued… and at the end

Make your own .HEX
 Start the Arduino software
 Click on File/Preferences and check “Show verbose output during compilation”
 Compile your program (Ctrl+R)
 A lot of text will scroll in the black area at the bottom of the window. The build directory path will be displayed there, and should looke something like:
 Windows: “C:\Users\Username\AppData\Local\Temp\build[random number].tmp\a_Hello.cpp.hex”.
 GNU/Linux: “/tmp/build[random number].tmp/a_Hello.cpp.hex”
 Mac : Type open $TMPDIR in your mac’s terminal to open the folder that is otherwise not accessible. You can then make a shortcut to your desktop.
 You can also change the build path in “arduino/lib/preferences.txt” by changing the line #build.path= to build.path=(directory you want).
 Navigate to this folder and find the .hex file with the name of your program
 Rename it to a 8:3 format: only capitals, 8 characters max for the name and .HEX extension. For example: CRABATOR.HEX or PONG.HEX
Put it on the micro SD card
Put your .HEX file with a 8:3 name on your micro SD card using any micro SD card reader. You can now select the .HEX file on your Gamebuino to load it on the go, without a computer! Do NOT turn off your Gamebuino while flashing.
Add a logo and description

If you want your game to appear with a logo and description in the loader, you have to create an .INF file and put it along the .HEX file on the SD card.
 Get the INF encoder from the Download page (requires Java).
 Put the generated .INF file along with the game’s .HEX file on the SD card. They must have the same name, all in capitals, and 8 characters max. For example CRABATOR.HEX (the game binaries) and CRABATOR.INF (the description file).
 Logo must be 1918px
 Slides must be 84
32px, up to 255 slides is allowed.
 Drag and drop slides to reorganize them
 The first slide is the one shown while the game is loading
 Slides can be used to describe the game, tell the story, explain how to play, etc. By putting this information in the INF you can read it before loading the game, everything that’s in the .INF don’t need to be in the .HEX so it frees some space for your code.

I hope this can help you even it’s a little rustic presentation …

1 Like

Just a quick note: getting the compiled hex can be a lot simpler than that! I’m not by my computer right now, but there’s a menu option called something like “Export compiled HEX” that will put the hex file in the same folder as your project.

Also, for quick tests you can drag the hex file onto your SD card without renaming it to only 8 uppercase characters, it’s just that the rest of the characters will be cut off when viewing it on the Makerbuino (so longfilename.hex will appear as something like LONGFIL~.HEX on the Makerbuino). I’m not sure whether anybody will care about that, but I just wanted to make it clear that if you forget to rename the file it won’t hurt anything. (Although if two different files have the same first 8 characters then you might have a problem)

All tips and trics can be usefull. Any tutorial can be perfected too :wink:

1 Like

That’s the way I mentioned in my Coding your MAKERbuino - getting started :slight_smile: But thanks for pointing out the filename thingy!

1 Like

Yes cool, it’s now alive… We was waiting that Albert termine to code your tuto in this natural location.
It’s will be alot better with the complete tutorial, now we have to wait that Albert code the second part to be able to make a pong :wink:

1 Like