Professional Documents
Culture Documents
3
Apr 2017
Contents:
PLAY
New games out this month!
The story behind the 1010 game
Mr Arduboy: Kevin Bates
Community Polls: What makes an Arduboy game great?
LEARN
Tips & Tricks with Team a.r.g (Vol 3)
Squeezing Bits to maximise your code with JO3RI (Vol 2)
Arduboy graphics with Gaveno112
Game design with crait
Using tunes and tones with Cronck
Notes from a new user - Scribbled Notes
EXPLORE
10 Questions with Game Developer Mike McRoberts
Pixel Page with Davit Masia
Cover page game index
Page 2 of 40
A welcome note:
-@widehaslet
Page 3 of 40
Thank you to this month’s contributors!
@crait: Creator of various Arduboy games such as Circuit
Dude and Train Dodge, crait has written tutorials on how to
get started with creating your own game, and developed
Arduboy Manager; an easy way to upload games to your
Arduboy without using the Arduino IDE. http://www.crait.net/
Page 4 of 40
Arduboy Company news:
What’s happening at headquarters?
@Celinebins
The Arduboy Blog is up! Updates on
what’s been happening on social
media and the community pages.
New!
New!
New!
That will
get you
hooked
FR
ARD DRIVIN
@remz & @LouisP
Boris goes
Skiing
@sones
Made at the Arduboy Workshop in
We’re digging the custom tee! Medway, guide Boris down the slopes
So highest score wins one? :p through the flags to score points, and
avoid the trees!
kemono_patrol
@metalidol
This month we take a closer look at one of the games - 1010, written as a
Christmas gift for his mother in 2016.
Mike Meyer (@mwm) gave his mother How to play:
an Arduboy for Christmas 2016. As well Moving mode
as the Arduboy, he wrote a game for it Once you’ve selected a shape, the arrow
specifically for her. keys will move it around on the board. The
A button will drop it in that position and
1010 - described switch back to selection mode.
as “2-dimensional
Tetris” - was one The LED color indicates if the shape will fit
of her favorite games during the months where it is: green for yes or go ahead and
leading up to Christmas, so seemed like a place, red for no.
perfect game to have on the Arduboy for
her. It took a couple of weeks to write and Selection mode
get working properly. You start the game in selection mode,
choosing from up to three shapes. The
The features unique to the Arduboy are current shape is show on the left side
using the right arrow key to shift from piece of the screen. Each available shape is
selection to piece placement, and the indicated by a - to the left of the displayed
green and red LED’s to show whether or shape, with the current shape being a
not the piece fits in it’s current position. +. Once a shape is placed, it’s symbol is
gone.
Page 11 of 40
Community
POLLs!
by @Celinebins
Simplicity of gameplay
“Simplicity is good because it means there’s no #1
pressure on people to make something fantastic and
because (let’s be honest) something complicated
isn’t likely to get played much on a tiny screen and 55%
will always be limited by hardware restrictions.”
-@Pharap
#2
Pixel art
If you want some ideas for pixel art, check out our
new Pixel page (page 30) to check out work from
Pixel artist Davit Masia. 48%
“Visibility- I think Arduboy games need to be easily
seen on the screen. Even though some games are
fun, they are hard to look at for a long period of time.
Great graphics and animations usually really help the
long-term playability of games on the system. There
really are some beautiful games for the system.”
-@crait
40%
#3
Amount of levels
“Replayability- This includes things like... Randomness
to each game, or maybe a lot of levels to hold you
over, or something that changes so that you aren’t
bored each time you play.” -@crait
Page 12 of 40
What makes an
arduboy game great?
#10 bullets
#9 Original story line
6%
6%
#86%Ability to load saved games
3% 7%
14% #7 Sound Effects
Effective sound can elevate a solid game to
18% something even more fun and entertaining. Find out
how to use Tunes and Tones on page 28!
33%
Page 13 of 40
LEARN:
In this topic we would like to present
you some tips & tricks to help you
code your games for Arduboy.
What we present doesn’t intend to
be the absolute truth, it’s just a way
we at TEAM a.r.g. code.
So always remember,
these are not golden rules.
ricks
T
Tips & by TEAM
A.R.G
Arduboy2 arduboy;
void setup() {
arduboy.begin();
arduboy.setFrameRate(60); // set the frame rate at 60 fps
}
void loop() {
if (!(arduboy.nextFrame())) return; // wait for the next frame (60/s)
arduboy.pollButtons(); // check button input
arduboy.clear(); // clear the screen
arduboy.display(); // update the display
}
This will show the Arduboy logo, clear the a beginning, a middle and an ending.
screen and do nothing more. Now, before Probably a lot more, but for our example
we continue, it is best to understand that we’ll stick to these 3.
a game, like a book, has at least 3 parts:
to be continued next page >>
Page 14 of 40
To help ourselves we are going to create a We are going to name our parts too.
variable to keep track of what part we are Add the next part in your code, before:
currently executing code. Remember the Arduboy2Base arduboy;
#define explanation in the previous issue?
#define STATE_GAME_INTRO 0
#define STATE_GAME_PLAY 1
#define STATE_GAME_OVER 2
if (gameState == STATE_GAME_INTRO)
{
arduboy.setCursor(0, 10);
arduboy.println(“Welcome”);
arduboy.println(“Press A to START”);
if (arduboy.justPressed(A_BUTTON)) gameState = STATE_GAME_PLAY;
}
if (gameState == STATE_GAME_PLAY)
{
arduboy.setCursor(0, 10);
arduboy.println(“The Game is on”);
arduboy.println(“Press A to END”);
if (arduboy.justPressed(A_BUTTON)) gameState = STATE_GAME_OVER;
}
if (gameState == STATE_GAME_OVER)
{
arduboy.setCursor(0, 10);
arduboy.println(“GAME OVER”);
arduboy.println(“Press A”);
if (arduboy.justPressed(A_BUTTON)) gameState = STATE_GAME_INTRO;
}
Now if we try out our little “game”, you you press the button, it will immediately
will notice something is wrong. It is like the check the next “if”. But because there
game just loops through all “if” statements hasn’t been enough time passed, the
and doesn’t stop, once we pressed a button still seems to be pressed and so
button, although we used justPressed. The our gameState changes again and once
reason? Well, if we only use “if” statements, more with the third “if” statement.
our code will check the first “if” and if
to be continued next page >>
Page 15 of 40
If you change the button to “B” in the difference between only “if” and “else if”.
second “if” statement, you’ll notice that You can use this for example, when you
the problem is solved. But this isn’t the want a sprite to walk only in 4 directions
solution we are looking for. We want to be and in not 8 (diagonal).
able to use the same button for all actions.
Here is where we need “if” and “else if”. Once we have more than 3 “else if”
This will make the code execute only one statements, it might be better to have a
of the successive “if” statements. So add look at switch cases. Again the Arduino
“else” in front of the second and third Reference Page is a good starting point.
“if”. You can read more about it on the Well, now that we know, we can replace
Arduino Reference Page. Remember the “if … else”. Let’s give it a try (showing the
replaced code part):
switch (gameState)
{
case STATE_GAME_INTRO:
arduboy.setCursor(0, 10);
arduboy.println(“Welcome”);
arduboy.println(“Press A to START”);
if (arduboy.justPressed(A_BUTTON)) gameState = STATE_GAME_PLAY;
break;
case STATE_GAME_PLAY:
arduboy.setCursor(0, 10);
arduboy.println(“The Game is on”);
arduboy.println(“Press A to END”);
if (arduboy.justPressed(A_BUTTON)) gameState = STATE_GAME_OVER;
break;
case STATE_GAME_OVER:
arduboy.setCursor(0, 10);
arduboy.println(“GAME OVER”);
arduboy.println(“Press A”);
if (arduboy.justPressed(A_BUTTON)) gameState = STATE_GAME_INTRO;
break;
}
void gamePlay()
{
arduboy.setCursor(0, 10);
arduboy.println(“The Game is on”);
arduboy.println(“Press A to END”);
if (arduboy.justPressed(A_BUTTON)) gameState = STATE_GAME_OVER;
}
void gameOver()
{
arduboy.setCursor(0, 10);
arduboy.println(“GAME OVER”);
arduboy.println(“Press A”);
if (arduboy.justPressed(A_BUTTON)) gameState = STATE_GAME_INTRO;
}
switch (gameState)
{
case STATE_GAME_INTRO:
gameIntro();
break;
case STATE_GAME_PLAY:
gamePlay();
break;
case STATE_GAME_OVER:
gameOver();
break;
}
It looks like our main loop is getting a clean Now that our game has been split out over
look, doesn’t it :) It’s time to re-read our different functions, it’s time to talk about
first article on multiple tabs/files. In our functions by pointers in an array indexed
example, each function isn’t very big, but by gameState, our last step in the process
you can imagine they will grow fast when of getting a clean easy readable loop.
adding game play. You probably add Nope, there isn’t an Arduino reference
more cases in your switch case, holding page on this one; I’ll do my best to explain
different parts of the game, like: NEXT_ myself.
LEVEL, PAUSE, ... putting each function in
a different .h file will help you to keep the
overview.
Next time, we’ll talk about how we can pass variables into
a function and how we can receive a variable back from
a function. Have fun coding your games.
BIT
In this “small” part of
the magazine I would
like to tell you about the
possibilities you have to
reduce coding size when
creating your app/game.
by JO3RI
SQ
U EEZ ER
In this issue let’s see how you can reduce But even combining different booleans
size when combining multiple booleans for keeping track of enemy statuses, like
into a byte, or even multiple bytes into “alive”, “visible”, “dying”, “invincible”,
1 byte. First you need to understand the “jumping” … could become byte saving,
difference of bits and bytes. Now that when you have a certain amount of
you’re into coding, you should know that enemies.
on an 8-bit system, you have 8 bits in 1
byte. If you look at this in Binary, you’ll Another place where this could become
“see” the bits. 0B11111111 equals to 255 in useful for is with tiles and maps. If you have
Decimals and 0xFF in Hexadecimals. Keep a map using different tiles and you only
this in mind, because it will always help use 16 (or less) different tiles, you could
you, when working in bits. use “half” a byte to store map data. Look
at a byte in hexadecimals and you’ll
If you create a boolean and compile your understand. In 0xFF, you have a “right”
code, the boolean will take the place of F and a “left” F (upper and lower), this
1 byte, although 1 bit would suffice. The means you can use both for storing a
compiler can’t combine those booleans number from 0-15 and so combine 2 half
into 1 byte itself, so we have to do this on bytes into one. If want this more explained
our own. Of course you might think, what have a look at the technical page of our
is the gain in having 1 byte instead of 8 game Virus LQP-79. There we combined 2
bytes ? Let’s assume you have a game map parts in 1 byte, but it comes down to
with 256 levels and each level has for the same thing. Enough about the talking,
example 8 items. To keep track of those here are some examples in the next page.
8 items being picked up, you can use a
“flag” (a boolean). That would mean,
you’ll need 2048 bytes in RAM ... , so here
the gain of stuffing 8 “flags” in 1 byte
becomes more obvious.
Indeed, we used an array of bytes. The 2 bytes( for 16 chets). Now let’s open en
size of the array is limited to the size of close the same chests as in the previous
RAM you have available. Here the size is example. And then have the same “if “
statement.
bitClear(allChests[0], 4);
bitClear(allChests[1], 1);
bitSet(allChests[0], 6);
bitSet(allChests[1], 4);
bitSet(allChests[1], 7);
While the “if” statement is shorter, Because this is an 8-bit system, we can
changing the state of the chests at the toggle 8 bits in 1 cycle and less cycles
beginning isn’t any shorter. Here we can means increasing speed. We have to set 2
show you how bit toggling can be used. bytes in total:
allChests[0] ^= 0B01010000;
allChests[1] ^= 0B10010010;
Doing this means we toggled bits, bits One final thing I want to show you is bit
that were on, will be off and visa versa. shifting, again Arduino has a very good
I know this isn’t easy to understand by webpage on this. shifting bits does exactly
just looking at it, but like I said before, I what it says. It moves bits in a byte left
find the reference page for bit math by or right. The bits get lost if they fall out of
Arduino very helpful. Just take a pencil the byte, which is an advantage we can
and some paper and write out the bytes use. Remember I started with asking you
in Binary with the mask under it, so you having to remember HEX notation of a
can write down the result. In our chests byte (0xFF) ?
example, you might not find it useful to set
8 bits at the same time, but if you have 8 Well let’s assume you have to store 4
characteristic flags in a byte for enemies, numbers with a max of 16 into 1 byte,
you’ll find it very helpful to be able to set for example 9 and 4, in BIN those are
those all at once. 0B0001001 and 0B00000100. Here is how:
byte halfBytes = 0B0001001 << 4; // move and store 4 bits to the left (=
0B10010000)
halfBytes += 0B00000100; // add the other byte (= 0B10010100)
byte firstByte = halfBytes & 0b00001111; // only copy over the 4 most right
bits
byte SecondByte = halfBytes >> 4; // move the 4 most left bits to the
right and copy
Page 22 of 40
Arduboy
Graphics
by @Gaveno112
Understand how making graphics for the Arduboy works with Team a.r.g’s
Gaveno, and find links to useful tools in the article.
With the Arduboy having moved on to it’s To really understand how it all works, we’ll
new library, Arduboy 2 (update available start with explaining how the graphics
through Arduino IDE library manager), actually work. As you know by now the
it’s time to explain how to use the sprite screen size is 128x64 pixels. Also good to
functions. remember is that a byte holds 8 bits (true/
false flags) OR 8 pixels.
The second thing to keep in mind is: the An image can be just black & white. In the
way you create your pixel art should example above we set the transparent
always use 100% black, 100% white and pixels to pink to make it clear. Even
100% transparent pixels for tiles and sprites. if you’re not going to use masks, use
transparent pixels as your “background
color”.
Third important thing is: naming. Give your And finally don’t forget to arrange your
graphics a name, but don’t use numbers tiles and sprites vertically in one column.
— with one exception in a moment — Now we know how we have to name
or special characters. Converters don’t and create our images. Time to convert
like them. Then postfix the name with an them into code. For each type we use
underscore and the dimensions of the a different converter. You probably can
asset. For an image, it’s the total width find other converters on the internet, but
and height. For the tiles it’s the width and we will show you how to use the online
height of one tile (note that tiles should converters TEAM a.r.g. created. All these
to be square). And for sprites, we use the are based on Josh Goebel’s work, you can
dimensions of one sprite. Remember for find on his github repository img2ard.
every case, height must still be a multiple
of 8.
And finally for a sprite sheet use Team This array is compatible with the
a.r.g’s sprite sheet converter. A sprite sheet drawSelfMasked function to display the
is a collection of smaller images, each image on screen. (If you want to use
representing a frame of an animated drawBitmap, you’ll have to comment the
image, vertically arranged into one dimensions in the array).
column as one big image.
Sprites sprites;
The tile converter will also give you just one And this is the function you will normally
array, including the size of one tile (not the use for tiles. Remember, tiles are used for
entire tilesheet). You will also see you’re background and normally will never need
tilesheet with every tile nicely ordered in masking.
rows and columns, for you to check if it
was divided correctly. This array is perfect
for use with the sprite function.
Imagine your tileSheet uses tiles of 8x8 function that will draw this map, according
pixels, well now we need to create a the numbers in the array, using the tiles
from your tileSheet.
void drawMap()
{
for (byte y = 0; y < 5; y++)
{
for (byte x = 0; x < 5; x++)
{
sprites.drawSelfMasked (x * 8, y * 8, tileSheet, pgm_read_
byte(&tileMap[x + (5 * y)]));
}
}
}
To learn more about tile maps and ways If you don’t care about your sprite being
to compress them for the Arduboy, check “look through” (meaning you’ll see
out the technical pages for Mystic Balloon, anything else behind the sprite too), you
Virus LQP-79, and Dungeons on the TEAM can use the drawSelfMasked function and
a.r.g. website. use the “sprite” array. If you don’t want
this behaviour, you’ll need a masked sprite
The sprite converter will give you not one which doubles the amount of bytes used
but three arrays. In all three arrays the by the sprite.
size of one sprite will be included. Again
you’ll see an image, but this time it will be Use the drawPlusMask function and use
the sprite looping through all of its frames. the “Sprite + Mask” array. If you only
Now depending on what you’re going to want a small mask behind your sprite,
do with the sprite, you can use a different you can use the drawErase function
function. and the “mask” array, followed by the
drawSelfMasked function and the “sprite”
array.
The latter is different. It takes two separate the dimensions because it uses the same
arrays to draw a masked sprite, whereas values from the sprite, so you’ll have to
drawPlusSelf only uses one array to do this. comment out those numbers yourself.
Using two arrays gives the developer a This means that the dimensions of your
chance to use a mask created separately special mask have to be exactly the same
from the original sprite. For example if you as the dimensions of the sprite you use.
want to mask only a part of your sprite. drawExternalMask also allows using a
different frame number for the mask than
There is one thing you should remember what is used for the sprite.
though; the mask you’ll be using doesn’t
need the first two bytes in its array to be
Page 27 of 40
game design tips
by crait
Programming a video game can be fun, but once you create a few games,
sometimes you can feel burnt out and not really know what to do next.
Maybe you’re a beginner and you don’t really know how to come up with
your own game. Either way, you can follow this guide to help come up with
a game concept.
In last month’s article, I rambled on about One thing I loved doing as a kid was
a lot of stuff... I hate that I did that, but it’s catching lizards. Where I lived, they were
really important to take away these three all over the place in the summer. I would
things from that article: try to find them behind bushes or climbing
on people’s houses. In fact, I would even
1) Work on games that you will finish so tresspass in order to find and catch them.
that you don’t have an excuse to give up. I remember having a lot of fun doing this...
Anytime I got close to one, it would run
2) A game’s theme can be removed from along the wall really fast and I’d have to
a game and it should still be fun. chase it, trying to cup my hand over it so it
can’t leave.
3) A game’s theme can be thought up
during the ideation phase of planning.
This is one of my favorite ways of coming I don’t know what I’ll write in next month’s
up with game ideas because the games article, but be sure to take a read when it
I tend to come up with really mean a lot comes out.
to me. When they do, I feel like I have
a lot higher chance of actually finishing
them and feeling proud about what I’ve
made. In fact, many popular games have
stemmed from this kind of creative thinking
and your game can be next.
Page 29 of 40
Scribbled notes
by @celinebins
I’ve started with little programming experience, so I decided to make a
game to better understand all the users that are trying to do so, prove that
if I can do it, then anyone can too, and of course have something cool to
show off. This series is going to summarize some of the lessons I’ve learnt as I
try to create my own game. Hope it will help and inspire other users!
Different languages
So when I first started my journey to learn
programming, I realized there are a TON
of programming languages, as existing
languages constantly evolve to fit new
problems that need to be solved. Ruby
and Python are great languages for writing
code used for web applications, and C++
is used in most packaged software; for
games, office applications and operating Arduino Leonardo
Image taken from Robotshop
systems.
If you want to play sounds on the Arduboy To use this with the Arduboy2 library, you
when using the standard Arduboy2 library, would include it after Arduoby2.h:
you need to pick a compatible sound #include <Arduboy2.h>
library, include it in your sketch, and then #include <ArduboyPlaytune.h>
use the particular functions that it provides
to produce sound. and create an object for it after the
There are a number of sound libraries that Arduboy2 object:
can be used with the Arduboy, including:
Arduboy2 arduboy;
- ArduboyTones ArduboyPlaytune tunes(arduboy.audio.
- ArduboyPlaytune enabled);
- ArdVoice
- ATMlib You then need to initialise the library in
your setup() function:
You can even just use the Arduino tone()
function, but there’s really no need since // audio setup
the ArduboyTones library can do the same tunes.initChannel(PIN_SPEAKER_1);
thing (and more) and produces less code. #ifndef AB_DEVKIT
Which library you choose depends on // if not a DevKit
what features you want and the amount tunes.initChannel(PIN_SPEAKER_2);
of program memory that you can afford to #else
have it use. // if it’s a DevKit
The ArduboyTones library is generally the tunes.initChannel(PIN_SPEAKER_1);
simplest to use and produces the smallest // use the same pin for both channels
code. tunes.toneMutesScore(true);
ArduboyPlaytune provides the same // mute the score when a tone is
features that were available in the original sounding
Arduboy library. #endif
ArdVoice is intended to produce crude
speech. The PlayTune example sketch included in
ATMlib (Arduboy Tracker Music library) the Arduboy2 library is an example of using
plays sophisticated multichannel ChipTune ArduboyPlaytune.
type music and effects. File > Examples > Arduboy2 > PlayTune
Copyright By @DavitMasia
Twitter: https://twitter.com/DavitMasia
Patreon: https://www.patreon.com/davitmasia
Note: These
screenshots are
Arduboy sized:
128 x 64 pixels
EXPLORE:
Questions
In this section we’ll ask
the same 10 questions to with game
a different developer in developers
every new issue.
by @widehaslet
1. Where did you find out about 5 . What do you read to learn how to
Arduboy the first time? code for Arduboy ?
From my mate @sones who brought one I already knew how to code in C so read
along to a Medway Makers meeting one the library documentation.
Saturday.
6 . What app/game do you have
2. What is the first program/game you currently on your Arduboy ?
created for Arduboy ? The current game I am working on.
Jet Pac - A recreation of the classic ZX
Spectrum game.
7. What Arduboy app/program is your
3. Did you have app/game developer favorite ?
experience before Arduboy ?
Circuit Dude by @crait is a great puzzle
Yes, I’ve been programming since I game. For graphics I love Sirene by
was about 12 years old. In my younger TeamARG.
years I wrote games for the ZX81 and ZX
Spectrum. Some of which got published
in the computer magazines of the day. 8. What is the next app/program for
Today I write mainly in C for the Arduino Arduboy from your hand we can
based devices but also use Lua, Python expect ?
and Javascript. I’m currently working on an isometric view
survival horror game.
4. What programs do you use for
creating Arduboy apps/games ? 9. What app/game would you love to
Pyxel for sprite creation. TeamARG tools see on the Arduboy ?
for the HEX conversion. I use Atom with the Rebelstar! Maybe i’ll do it myself one day.
PlatformIO plug-in for my IDE. Good old
pen and paper for everything else.
to be continued next page >>
Page 36 of 40
10.What is your best tip for other
people who want to start creating e.g. Space Invaders : Just start by learning
how to draw the alien Sprites to the
apps/games for Arduboy ?
screen. Then make them move left and
Just do it! The only thing worse than trying right. Then add the ability for them to
and failing is not trying at all. Get your drop down one line when they reach the
game idea and just make it. edges. Then make them drop random
bombs, and so on. Break every large
Learn as you go along. Break your idea problem down into simple sub-problems,
down into simple sub-components and do get them working then move onto the
those one at a time. next.
日本のユーザーに叫ぶ:
私たちは日本語フォーラムを持っています
この公式カテゴリは日本語を書くことができます。
私たちはプログラミングの質問や、ゲームやアプリケーション
の投稿を歓迎します。
もちろん、他のカテゴリで、あなたは英語で話すことができま
す。
を楽しんでください。(^_^)
ありがとうございました!
東京2016
Page 37 of 40
#arduboy:
Page 38 of 40
Thank you!
Thank you for reading the Magazine!
Hope you enjoyed it as much as we did putting it together.