This is probably a really simple thing but I'm new to C++ so need help.
I am trying to make a simple snake game, written in C++ and meant to run on a MBED MCU. In order to keep the code as tidy as possible, I have created a class to store all the bitmaps (i.e. 2D arrays of 1s and 0s) that will be printed as settings and interaction icons on the Menu screen of th game.
The header file (Menu.h) looks like this:
#ifndef MENU_H
#define MENU_H
#include "mbed.h"
#include "N5110.h" //lcd screen
#include "Gamepad.h" //board on which the MBED is mounted, with leds etc.
class Menu {
public:
Menu();
~Menu();
static const char snake_title[24][70]; //This is the first of several
// arrays that I want to include in the struct
void init_array();
void welcome(N5110 &lcd, Gamepad &pad);
private:
};
#endif
And this is the implementation file (Menu.cpp)
#include "Menu.h"
Menu::Menu()
{
}
Menu::~Menu()
{
}
void Menu::init_array()
{
const char snake_title[24][70] = {
//Massive array of bitmaps e.g. {0,0,0,0,0,0,1,1,0,1,1,1,1.....0,0,0},
......
......
......
};
}
void Menu::welcome(N5110 &lcd, Gamepad &pad)
{
lcd.drawSprite(7,12,24,70,(int *)snake_title); //draw sprite, position 68,12
lcd.printString("Press Start",10,5);
lcd.refresh();
// wait flashing LEDs until start button is pressed
while ( pad.check_event(Gamepad::START_PRESSED) == false) {
pad.leds_on();
wait(0.1);
pad.leds_off();
wait(0.1);
}
}
I haven't tried to make a struct to encapsulate all the 2D arrays yet because at this stage the code is already not working, and I would like to know why and what I can do to fix it.
The two errors I get make no sense to me:
Error: "/tmp/CLhdO7", line 124 (column 3): Warning: L6312W: Empty Execution region description for region RW_IRAM1
Error: Undefined symbol Menu::snake_title (referred from /build/Menu/Menu.K64F.o).
Thanks for your help!