http://legacy.gamebuino.com/wiki/index.php?title=Special:NewPages&feed=atom&hideredirs=1&limit=50&offset=&namespace=0&username=&tagfilter=&size-mode=max&size=0Gamebuino Wiki - New pages [en]2024-03-29T09:15:52ZFrom Gamebuino WikiMediaWiki 1.29.1http://legacy.gamebuino.com/wiki/index.php?title=Start_to_codeStart to code2016-11-27T14:06:07Z<p>Studiocraftapps: Added the bitmap section</p>
<hr />
<div>==Starting page==<br />
<br />
===Basics===<br />
When you start creating your game, you should have included these file:<br />
<br />
<code>#include <SPI.h></code><br />
(To communicate with the Gamebuino's screen)<br />
<br />
<code>#include <Gamebuino.h></code><br />
(To get the pre made library)<br />
<br />
<code>Gamebuino gb</code><br />
(To create a Gamebuino object named gb)<br />
<br />
Then, you'll need to initialize the Gamebuino object in the '''setup''' function using this:<br />
<code>gb.begin();</code><br />
and display the menu using the gb.titleScreen function:<br />
<code>gb.titleScreen(F("The name of your game"));</code><br />
<br />
For now, your code should look like this:<br />
<code><br />
#include <SPI.h><br />
#include <Gamebuino.h><br />
<br />
Gamebuino gb;<br />
<br />
void setup () {<br />
gb.begin();<br />
<br />
gb.titleScreen(F("My game"));<br />
}<br />
</code><br />
<br />
===Customize the title screen===<br />
The function <code>gb.titleScreen</code> 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]],<br />
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)<br />
<br />
==Bitmaps==<br />
Do you want to create a bitmap? or maybe create a map of them?<br />
It's here<br />
<br />
===Create a bitmap===<br />
Note: If in your game, you enable persistence, you'll need to draw the bitmap each frame.<br />
<br />
First, you need to create the bitmap on a byte array like this:<br />
<code><br />
const PROGMEM byte Name[] {<br />
/*The size of the bitmap*/<br />
8,8,<br />
/*The bitmap itself*/<br />
B00000000,<br />
B00000000,<br />
B00000000,<br />
B00000000,<br />
B00000000,<br />
B00000000,<br />
B00000000,<br />
B00000000<br />
};<br />
</code><br />
(You can make it using hexadecimal but it will be harder to modify after.)<br />
<br />
0 = a blank pixel/white and 1 = a black pixel<br />
<br />
===Draw the bitmap===<br />
To draw a bitmap, use :<br />
[[gb.display.drawBitmap]](x, y, bitmap, rotation, flip); <br />
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).<br />
<br />
===Draw a map===<br />
(Work in progress)</div>Studiocraftappshttp://legacy.gamebuino.com/wiki/index.php?title=EEPROM.updateEEPROM.update2016-11-26T22:44:15Z<p>Studiocraftapps: Fix a minor bug</p>
<hr />
<div>__NOTOC__<br />
== Description ==<br />
Write the value corresponding to the address. This function clear the current value<br />
<br />
== Syntax ==<br />
<pre>EEPROM.update(address, value);</pre><br />
<br />
== Parameters ==<br />
* address: the location to read from, starting from 0 (int)<br />
* value: the value to write, from 0 to 255 (byte)<br />
<br />
== Returns ==<br />
none<br />
<br />
== Example ==<br />
<code><br />
#include <EEPROM.h><br />
#include <SPI.h><br />
#include <Gamebuino.h><br />
<br />
Gamebuino gb;<br />
<br />
byte levels_unlocked = 0;<br />
<br />
void setup()<br />
{<br />
gb.begin();<br />
gb.titleScreen(F("Read EEPROM"));<br />
EEPROM.update(0, levels_unlocked);<br />
}<br />
</code><br />
<br />
== See also ==<br />
* [[EEPROM.read]]<br />
* [[EEPROM.write]]<br />
* [[EEPROM.put]]<br />
* [[EEPROM.get]]</div>Studiocraftappshttp://legacy.gamebuino.com/wiki/index.php?title=EEPROM.writeEEPROM.write2016-11-26T22:42:37Z<p>Studiocraftapps: Minor edit</p>
<hr />
<div>__NOTOC__<br />
== Description ==<br />
Write the value corresponding to the address if the address is empty<br />
<br />
== Syntax ==<br />
<pre>EEPROM.write(address, value);</pre><br />
<br />
== Parameters ==<br />
* address: the location to read from, starting from 0 (int)<br />
* value: the value to write, from 0 to 255 (byte)<br />
<br />
== Returns ==<br />
none<br />
<br />
== Example ==<br />
<code><br />
#include <EEPROM.h><br />
#include <SPI.h><br />
#include <Gamebuino.h><br />
<br />
Gamebuino gb;<br />
<br />
byte levels_unlocked = 0;<br />
<br />
void setup()<br />
{<br />
gb.begin();<br />
gb.titleScreen(F("Read EEPROM"));<br />
EEPROM.write(0, levels_unlocked);<br />
}<br />
</code><br />
<br />
== See also ==<br />
* [[EEPROM.read]]<br />
* [[EEPROM.update]]<br />
* [[EEPROM.put]]<br />
* [[EEPROM.get]]</div>Studiocraftappshttp://legacy.gamebuino.com/wiki/index.php?title=EEPROM.readEEPROM.read2016-11-26T22:31:51Z<p>Sutchig: /* Returns */ byte</p>
<hr />
<div>__NOTOC__<br />
== Description ==<br />
Read the value corresponding to the adress<br />
<br />
== Syntax ==<br />
<pre>EEPROM.read(address);</pre><br />
<br />
== Parameters ==<br />
* address: the location to read from, starting from 0 (int)<br />
<br />
== Returns ==<br />
The value stored in that location (Byte)<br />
<br />
== Example ==<br />
<code><br />
#include <EEPROM.h><br />
#include <SPI.h><br />
#include <Gamebuino.h><br />
<br />
Gamebuino gb;<br />
<br />
byte levels_unlocked = 0;<br />
<br />
void setup()<br />
{<br />
gb.begin();<br />
gb.titleScreen(F("Read EEPROM"));<br />
levels_unlocked = EEPROM.read(0);<br />
}<br />
</code><br />
<br />
== See also ==<br />
* [[EEPROM.write]]<br />
* [[EEPROM.update]]<br />
* [[EEPROM.put]]<br />
* [[EEPROM.get]]</div>Studiocraftappshttp://legacy.gamebuino.com/wiki/index.php?title=MemoryMemory2016-11-26T22:19:21Z<p>Studiocraftapps: Removed the NOTOC</p>
<hr />
<div>Here is listed and explained of some useful Arduino storage keyword, classes, and function.<br />
<br />
See [http://gamebuino.com/wiki/index.php?title=Reference Reference] for all Gamebuino specific functions.<br />
<br />
== EEPROM ==<br />
EEPROM persists after the Gamebuino has been shut down, making it perfect for game saves. There are 1024 bytes of EEPROM.<br />
<br />
There are no special Gamebuino libraries for reading from or writing to EEPROM, because these functions come from the standard Arduino libraries. You need to use <code>#include <EEPROM.h></code> for these functions.<br />
<br />
Here are a few useful functions for working with EEPROM:<br />
<code><br />
* [[EEPROM.read]](address) //int<br />
* [[EEPROM.write]](address, value) //int, byte<br />
* [[EEPROM.update]](address, value) //int, byte<br />
* [[EEPROM.get]](address, data) //int, primitive type (eg. float) or a custom struct<br />
* [[EEPROM.put]](address, data) //int, primitive type (eg. float) or a custom struct<br />
</code><br />
<br />
For more information on EEPROM, refer to the [https://www.arduino.cc/en/Reference/EEPROM Arduino library reference].<br />
<br />
=== How Game Switching Works ===<br />
You may notice that saved data for a game works even when you switch games with the loader, and yet games have access to the entire EEPROM! How is saved data preserved even when another game can write to EEPROM?<br />
<br />
The answer lies in the Gamebuino [https://github.com/Rodot/Gamebuino/tree/master/examples/4.Utilities/Loader loader]. When the loader starts, it checks to see whether there are any bytes in EEPROM that are not zero. If so, it saves the contents of EEPROM into a <GAME NAME>.SAV file on the SD card. Later, when a game is about to be loaded, it checks for a <GAME NAME>.SAV file, and writes the contents to EEPROM if it is found. If not, it clears the EEPROM.<br />
<br />
This approach allows games to use the entire contents of EEPROM without worrying about corrupting other games' save data, and without worrying about writing save data to the SD card.</div>Studiocraftappshttp://legacy.gamebuino.com/wiki/index.php?title=MAKERbuino:_build_guideMAKERbuino: build guide2016-11-19T13:19:27Z<p>Albertinjo: edit</p>
<hr />
<div>[[File:MAKERbuino-buildGuide-1.bmp]]<br />
<br />
[[File:MAKERbuino-buildGuide-2.bmp]]<br />
<br />
[[File:MAKERbuino-buildGuide-3.png|800px]]<br />
<br />
==General description==<br />
<br />
--------------------<br />
<br />
'''IMPORTANT: this is an outdated version of the MAKERbuino build guide. Find the new version here:<br />
'''<br />
[http://makerbuino.com/build NEW MAKERbuino build guide]<br />
<br />
--------------------</div>Albertinjo