Hi Folks,
I'm trying to program a video game on a "Gamebuino"-style device that I built using an Arduino Uno and a Nokia 5110.
The problem is, I can't seem to get the tilemap to work. It only reads the first character of the map and won't go to the next line. It also displays the character more times than it needs to. I've included the code below, as well as an image of what the code is displaying.
Just let me know if you have questions, and thanks for the help!
include <Gamebuino.h>
#include <SPI.h>
Gamebuino gb;
int TileCursorX = 0;
int TileCursorY = 0;
int DrawPosX = 0;
int DrawPosY = 0;
const byte Logo[] PROGMEM = {64, 35, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000011, B01100111, B01110111, B01000111, B00011000, B10011101, B00000000, B00000000, B00000011, B01010010, B00100010, B01000100, B00010101, B01001001, B00000000, B00000000, B00000011, B01100010, B00100010, B01000110, B00011001, B11001001, B00000000, B00000000, B00000011, B01010010, B00100010, B01000100, B00010101, B01001000, B00000000, B00000000, B00000011, B01100111, B00100010, B01110111, B00011001, B01001001, B00000000, B00000000, B00000011, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000011, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000011, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000011, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B11100011, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000001, B11110011, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B10100011, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B10100011, B00000000, B00000000, B00000000, B00000000, B00000000, B00000001, B00000000, B10100011, B00000000, B00000000, B00000000, B00000000, B00000000, B00000010, B10000001, B11110011, B00000000, B00000000, B00000000, B00000000, B00000000, B00000101, B01000000, B11100011, B00000000, B00000000, B00000000, B00000000, B00000000, B01111111, B11111111, B11111111, B11000000, B00000000, B00000000, B00000000, B00000000, B01111111, B11111111, B11111111, B11000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B11000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B11000010, B00000000, B00000000, B00000000, B10000000, B00000000, B00000000, B00000000, B11000010, B00000000, B00000000, B00000011, B11100000, B00000000, B00000000, B00000000, B11111111, B11110000, B00000000, B00000010, B00100000, B00000000, B00000000, B00000000, B11111111, B11110000, B00000000, B00000010, B00100000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000010, B00100000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000010, B00100000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000010, B00100000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000010, B00100000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000011, B11100000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000001, B01000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000001, B01000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000001, B11111111, B11111111, B11111111, B00000000, B00000000, B00000000, B00000000, B00000001, B11111111, B11111111, B11111111, B00000000, B00000000, B00000000, B00000000, B00000001, B11111111, B11111111, B11111111, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,};
const byte Player[] PROGMEM = {8, 8, B00011000, B11111111, B11111111, B11000011, B11000011, B11000011, B11111111, B11111111};
const byte Wall1[] PROGMEM = {8, 8, B11111111, B11000011, B10100101, B10011001, B10011001, B10100101, B11000011, B11111111};
const byte Wall2[] PROGMEM = {8, 8, B11111111, B11111111, B11111111, B11100111, B11100111, B11111111, B11111111, B11111111};
const byte Wall3[] PROGMEM = {8, 8, B11011111, B11011111, B00000000, B11111110, B11111110, B00000000, B11011111, B11011111};
const unsigned char Map1[] PROGMEM {
3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0,
2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3, 3, 2, 2, 2, 2, 2, 3, 0, 2, 0,
3, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2,
2, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 2, 0, 3, 0, 2, 2
};
void setup() {
gb.begin();
gb.titleScreen(Logo);
}
void loop() {
gb.update();
if (pgm_read_byte(Map1) == 0) {
TileCursorX ++;
DrawPosX = DrawPosX + 8;
}
if (pgm_read_byte(Map1) == 2) {
TileCursorX ++;
DrawPosX = DrawPosX + 8;
gb.display.drawBitmap(DrawPosX, 0, Wall1);
}
if (pgm_read_byte(Map1) == 3) {
TileCursorX ++;
DrawPosX = DrawPosX + 8;
gb.display.drawBitmap(DrawPosX, 0, Wall2);
}
if (pgm_read_byte(Map1) == 4) {
TileCursorX ++;
DrawPosX = DrawPosX + 8;
gb.display.drawBitmap(DrawPosX, 0, Wall3);
}
if (TileCursorX == 11) {
TileCursorY ++;
TileCursorX = 0;
DrawPosY ++;
}
}
