I have experience programming but none with C++ except the Arduboy quick start guide.
Main file:
//Sam Sibbens
//November 1st, 2018
#include <Arduboy.h>
Arduboy arduboy;
// Game stuff
#include "Sprites.h"
void setup() {
arduboy.begin();
arduboy.clear();
arduboy.setFrameRate(30);
}
void loop() {
//Prevent the Arduboy from running too fast
if(!arduboy.nextFrame()) {return;}
arduboy.clear();
if(arduboy.pressed(LEFT_BUTTON)) {
playerx = playerx - playerspeed;
}
if(arduboy.pressed(RIGHT_BUTTON)) {
playerx = playerx + playerspeed;
}
if(arduboy.pressed(UP_BUTTON)) {
playery = playery - playerspeed;
}
if(arduboy.pressed(DOWN_BUTTON)) {
playery = playery + playerspeed;
}
arduboy.fillScreen(WHITE);
draw_entity(playerx, playery, Sprites.PLAYER);
arduboy.display();
}
Sprites.h
// Sprites.h
#if !defined(SPRITES)
#define SPRITES 1
/// w stands for "white pixels" and b stands for "black pixels"
const unsigned char spr_player_w[] PROGMEM;
const unsigned char spr_player_b[] PROGMEM;
void draw_entity(byte spr, byte x, byte y);
enum Sprites {
PLAYER,
};
#endif
Sprites.cpp
#include "Sprites.h"
//Player
const unsigned char spr_player_w[] PROGMEM = {
0x00, 0x1e, 0x52, 0x5e, 0x5e, 0x52, 0x1e, 0x00,
};
const unsigned char spr_player_b[] PROGMEM = {
0x3f, 0xe1, 0xad, 0xa1, 0xa1, 0xad, 0xe1, 0x3f,
};
void draw_entity(byte spr, byte x, byte y) {
switch(spr){
case PLAYER:
arduboy.drawBitmap(x, y, spr_player_w, 8, 8, WHITE);
//arduboy.drawBitmap(x, y, spr_player_b, 8, 8, BLACK);
break;
}
}
What am I doing wrong that causes the expected initializer before āPROGMEMā error?