I had a closer look at @crait’s “completed code” and now know what you’re trying to do.
The spite that you’ve created for the player is just data. You need to draw it with one of the Sprites
functions. Since the bitmap array you’ve provided doesn’t include a mask, the drawOverwrite() function is likely the best to use.
You need to put your noname array in the sketch as “global” data. For my testing, I put it before the tiles array
[...]
int mapx = 0;
int mapy = 0;
const unsigned char PROGMEM noname[] = {
// width, height,
16, 16,
// TILE 00
0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xb9, 0xb1, 0xb1, 0xb9, 0x83, 0x1f, 0xff, 0xff, 0xff, 0xff,
0xff, 0x07, 0x73, 0x7b, 0x7b, 0x78, 0x3f, 0x9f, 0xdf, 0x9f, 0xbf, 0x38, 0x79, 0x39, 0xb3, 0x87,
};
const unsigned char tiles[] PROGMEM = {
// width, height,
16, 16,
[...]
Then, you need to replace the fillRect() function in drawplayer() with the function to draw the sprite
#define PLAYER_SIZE 16
#define PLAYER_X_OFFSET WIDTH / 2 - PLAYER_SIZE / 2
#define PLAYER_Y_OFFSET HEIGHT / 2 - PLAYER_SIZE / 2
void drawplayer() {
// arduboy.fillRect(PLAYER_X_OFFSET, PLAYER_Y_OFFSET, PLAYER_SIZE, PLAYER_SIZE, BLACK);
Sprites::drawOverwrite(PLAYER_X_OFFSET, PLAYER_Y_OFFSET, noname, 0);
}
You should now have your noname sprite drawn instead of a black rectangle.
Without masking, all of the pixels in your sprite are drawn over the background. So, the next thing you’ll probably want to do is create a sprite with a mask and use drawPlusMask() to draw it.
Edit:
Here’s the array (I renamed it to player) and drawplayer() functions with the outside of the image masked
// player in drawPlusMask() format (mask included in image)
const unsigned char PROGMEM player[] = {
// width, height,
16, 16,
// FRAME 00
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xb8, 0xfe, 0xb4, 0xfe,
0xb4, 0xfe, 0xb8, 0xfe, 0x80, 0xfc, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xf8, 0x70, 0xfc, 0x78, 0xfc, 0x78, 0xfc, 0x78, 0xff, 0x3f, 0xff, 0x1f, 0x7f,
0x1f, 0x3f, 0x1f, 0x7f, 0x3f, 0x7f, 0x38, 0xff, 0x78, 0xfe, 0x38, 0xfe, 0x30, 0x7c, 0x00, 0x78
};
void drawplayer() {
Sprites::drawPlusMask(PLAYER_X_OFFSET, PLAYER_Y_OFFSET, player, 0);
}
NoobGeek2.hex (26.5 KB)