The Gameduino library supports both Gameduino 2 and 3 -- it auto-detects the attached board at startup. The library is tested with Arduino, ESP8266 and Teensy controllers.
The current version of the GD2 library is 1.0.0
To install it:
The asset converter is a program that prepares media on your PC for use with the Gameduino 2/3. You can use the asset converter to:
- convert sprite graphics for the Gameduino2
- convert audio samples
- convert TrueType (TTF) fonts
After installation, you can run the asset converter by typing:
gd2asset --help
or:
gd3asset --help
into a command shell. You should see something like:
usage: gd2asset <options> <assets> -o output header file -f output asset file (default is header file) If no output header file is given, then "default_assets.h" is used Each asset is a filename, optionally followed by some var=val assignments. For example: pic1.png image, format ARGB4 pic2.jpg,format=L8 image, format L8 serif.ttf,size=16 font, 16 pixels high The assets are compiled into flash, or if the "-f" option is given into a file. In this case the file should be copied to the microSD card. In either case, calling LOAD_ASSETS() from the program loads all assets.
There are two ways of storing assets. The first is to use an array in Arduino flash memory. This works well for small sized assets, up to around 20K. The second way is to load the assets from SDcard memory.
If you run it like this:
gd2asset -o myassets.h pic1.png pic2.png pic3.png
then it creates a file myassets.h. Add it to your Arduino sketch, and in your sketch do:
#include "myassets.h"
and after GD.begin(), do:
LOAD_ASSETS();
and you can use the assets pic1, pic2, pic3, for example:
GD.Begin(BITMAPS); GD.Vertex2ii(10, 100, 0); // pic1 GD.Vertex2ii(10, 200, 1); // pic2 GD.Vertex2ii(10, 300, 2); // pic3
If you run gd2asset like this:
gd2asset -f myassets.gd2 -o myassets.h pic1.png pic2.png pic3.png
then it creates two files:
- myassets.gd2 - copy this onto your microSD
- myassets.h - include this from your program
Copy myassets.gd2 to the SDcard, and the sketch can use the assets as above. The only difference is that the data is stored on the SDcard instead of taking up flash memory.
The Gameduino 2 asset converter is available at https://pypi.python.org/pypi/gameduino2.
If your system does not already have easy_install and PIL:
sudo apt-get install python-setuptools python-imaging
then you can install the asset converter with:
sudo easy_install -U gameduino2
and run it by typing:
gd2asset
For Windows, your need to install several packages:
- Python27, http://www.python.org/getit/windows/
- easy_install from https://pypi.python.org/pypi/setuptools#windows-powershell-3-or-later
- The Python Imaging Library, http://www.pythonware.com/products/pil/. Choose the version for Python 27.
After this you can open a command windows and type:
\Python27\Scripts\easy_install -U gameduino2
You should see something like this:
This installs the Python package gameduino2 and the command-line utility gd2asset.
After setup you can run it with a command-line like this:
\Python27\python \Python27\Scripts\gd2asset
For general help about setting up Python tools on Windows, see http://docs.python.org/2/faq/windows