Understanding the language, error messages, etc.
by jac77794 » Fri Aug 01, 2014 10:40 pm
Hi, I don't have much programming experience, so have being looking at others code. I can't work out why when for example from SuperSpaceShooter
- Code: Select all
const byte heart2[] PROGMEM = {
5, 5,
B01010111,
B11111111,
B11111111,
B01110111,
B00100111
};
it says 5,5 so I assume it is 5 pixels by 5 and it has that amount of rows ,but 8 horizontal numbers please explain for a noob. Also any other helpful information about this topic, as it is the hardest for me to understand, would be much appreciated.
Many thanks
-
jac77794
-
- Posts: 5
- Joined: Fri Aug 01, 2014 10:33 pm
by msevilgenius » Sat Aug 02, 2014 11:34 am
Each of the numbers (B010001111) is one byte long (eight binary digits), if you were to only put five e.g. B01010 it would be interpreted as B00001010 so that line of the image would be 00001 instead of the desired 01010.
There are a couple of image encoders available that you can use to create the sprites, such as the one in the
GB toolkit, so you don't have to worry about it too much.
-
msevilgenius
-
- Posts: 12
- Joined: Tue Mar 25, 2014 11:10 am
-
by yodasvideoarcade » Wed Aug 06, 2014 9:06 am
It simply means: Each of the bytes has to have eight numbers (either 0 or 1), otherwise it's not a byte.
If your sprite is only 5 pixels wide, just fill the remaining 3 numbers with 000.
-
yodasvideoarcade
-
- Posts: 102
- Joined: Sat Apr 19, 2014 10:48 am
- Location: Frankfurt/Germany
-
by rodot » Wed Aug 06, 2014 9:48 am
Just in case you missed it: you can convert pictures to the Gamebuino format using the toolkit which is on
github.
-
rodot
- Site Admin
-
- Posts: 1290
- Joined: Mon Nov 19, 2012 11:54 pm
- Location: France
-
Return to Programming Questions
Who is online
Users browsing this forum: No registered users and 62 guests