Error 2 / Adding images to game

harpotpl

5 years ago

Hi i wanted to write chess game for Gamebuino meta. I created chess board, saved it as png file than converted to 24-bit-depth BMP file, put it on sd card and he is code i used to display it on a screen: 

#include <Gamebuino-Meta.h> 
void setup() {
  gb.begin();
}
void loop() {
  while (gb.update());
  gb.display.clear();
  // INPUTS //
  // LOGIC //
  // DRAW //
  Image chessBoard("chess/chessBoard.bmp");
  gb.display.drawImage (0,0,chessBoard);
}

But when i try to compile this code i get : HARD FAULT RAM OVERFLOW? MEMORY ALIGNMENT? UNDEFINED INSTRUCT? EXEC IN ADDRESS?

And here is my question : what am I doing wrong. It is my first time when i add images to game and i would like to add that what "academy" says about adding images to code is very unclear for me.

jicehel

NEW 5 years ago

remove chess/ in the name of your picture. The path is from where is your game (so in your case from the repository chess). As your pictue is in this directory, you have nothing to add before the name of your picture

deeph

NEW 5 years ago

I think the main problem is that you're continuously loading your image because you put Image chessBoard("chess/chessBoard.bmp"); in the loop() function, while you should put it before the setup() to initialize it as a global variable.

jicehel

NEW 5 years ago

True deeph, its not useful but its don't explain why he don't show it. For me the problem is that the path is wrong, after the fact he load the picture each time is an optimisation to have a better speed and a better view.

Sorunome

NEW 5 years ago

depending on how large the BMP is, it could also be simply....ram overflowing, as the error suggests