[SOLVED] Blank screen error

Understanding the language, error messages, etc.

[SOLVED] Blank screen error

Postby Montiey » Sun Feb 15, 2015 12:45 am

I seem to be running into a recurring problem with my programs, and not just mine. This is the code for the game I wrote, but I get a blank screen with nothing on it..
Code: Select all
//imports the SPI library (needed to communicate with Gamebuino's screen)
#include <SPI.h>
//imports the Gamebuino library
#include <Gamebuino.h>
//creates a Gamebuino object named gb
Gamebuino gb;

static unsigned char PROGMEM logo[]=
{
  40,12,
  B00111100, B00110000, B11000011, B11000000, B11110000,
  B00111100, B00110000, B11000011, B11000000, B11110000,
  B11000011, B00110000, B11001100, B00110011, B00001100,
  B11000011, B00110000, B11001100, B00110011, B00001100,
  B11000011, B00110000, B11001100, B00000011, B00000000,
  B11000011, B00110000, B11001100, B00000011, B00000000,
  B11111100, B00110000, B11001100, B11000011, B00110000,
  B11111100, B00110000, B11001100, B11000011, B00110000,
  B11000011, B00110000, B11001100, B00110011, B00001100,
  B11000011, B00110000, B11001100, B00110011, B00001100,
  B00111100, B00001111, B00000011, B11000000, B11110000,
  B00111100, B00001111, B00000011, B11000000, B11110000,
};

static unsigned char PROGMEM player[]=
{
  8,8,
  B00111100,
  B01000010,
  B10100101,
  B10000001,
  B10100101,
  B10011001,
  B01000010,
  B00111100,
};

static unsigned char PROGMEM item2[]=
{
  8,8,
  B01111110,
  B11000011,
  B10100101,
  B10011001,
  B10011001,
  B10100101,
  B11000011,
  B01111110,
};

static unsigned char PROGMEM item1[]=
{
  8,8,
  B01111110,
  B10000001,
  B10111101,
  B10111101,
  B10111101,
  B10111101,
  B10000001,
  B01111110,
};

int score = 0; // score
int item1_quantity = 0;
int item2_quantity = 0;
int player_x = LCDWIDTH/2; //set the horizontal position to the middle of the screen
int player_y = LCDHEIGHT/2; //vertical position
int player_vx = 1; //horizontal velocity
int player_vy = 1; //vertical velocity
int player_size = 8; //the size of the player in number of pixels
int item1_size = 6; //SE
int item1_x = 30; //initial X position of item1
int item1_y = 10; //initial Y position of item1
int item2_size = 8; //SE
int item2_x = 40; //initial X position of item2
int item2_y = 2; //initial Y position of item2

// the setup routine runs once when Gamebuino starts up
void setup(){
  // initialize the Gamebuino object
  gb.begin();
  //display the main menu:
  gb.titleScreen(F("Work In Progress"), logo);
}

// the loop routine runs over and over again forever
void loop(){
  if(gb.update()){
    //item1 system
    if(gb.collideBitmapBitmap( player_x,  player_y,  player, item1_x, item1_y, item1)){
      item1_x = random(0, LCDWIDTH - item1_size);
      item1_y = random(0, LCDHEIGHT - item1_size);
      score += 1;
      item1_quantity += 1;
      gb.sound.playOK();
    }
    //item2 system
    if(gb.collideBitmapBitmap( player_x,  player_y,  player, item2_x, item2_y, item2)){
      item2_x = random(0, LCDWIDTH - item2_size);
      item2_y = random(0, LCDHEIGHT - item2_size);
      score -= 3;
      item2_quantity += 1;
      gb.sound.playCancel();
    }
    //move the  player using the buttons
    if(gb.buttons.repeat(BTN_RIGHT,2)){ //every 2 frames when the right button is held down
      player_x =  player_x +  player_vx; //increase the horizontal position by the  player's velocity
    }
    if(gb.buttons.repeat(BTN_LEFT,2)){
      player_x =  player_x -  player_vx;
    }
    if(gb.buttons.repeat(BTN_DOWN,2)){
      player_y =  player_y +  player_vy;
    }
    if(gb.buttons.repeat(BTN_UP,2)){
      player_y =  player_y -  player_vy;
    }
    //speed selection
    if(gb.buttons.pressed(BTN_A)){
      gb.sound.playTick();
      player_vx = 5;
      player_vy = 5;
    }
    if(gb.buttons.pressed(BTN_B)){
      gb.sound.playTick();
      player_vx = 2;
      player_vy = 2;
    }
    //check that the  player is not going out of the screen\

    //if the  player is touching the left side of the screen
    if( player_x < 0){
      //bring it back in the screen
      player_x = 0;
    }
    //if the  player is touching the right side
    if(( player_x +  player_size) > LCDWIDTH){
      player_x = LCDWIDTH -  player_size;
    }
    //if the  player is touching the top side
    if( player_y < 0){
      player_y = 0;
    }
    //if the  player is touching the down side
    if(( player_y +  player_size) > LCDHEIGHT){
      player_y = LCDHEIGHT -  player_size;
    }
    //draw the  player on the screen
    gb.display.print("$ ");
    gb.display.println(score);
    gb.display.drawBitmap(player_x, player_y, player);
    gb.display.drawBitmap(item1_x,item1_y,item1);
    gb.display.drawBitmap(item2_x,item2_y,item2);
  }
}



A problem could easily hide in this program, but even something as simple as this little program doesn't load right:
Code: Select all
#include <SPI.h> //imports the SPI library
#include <Gamebuino.h> //imports the Gamebuino library
Gamebuino gb; //creates a Gamebuino object named gb

static unsigned char PROGMEM sprite[]=
{
  8,6,
  B10101010,
  B01010101,
  B10101010,
  B01010101,
  B10101010,
  B01010101,
};

void setup(){
  gb.begin();
  //display the main menu
  gb.titleScreen(F("It Works!"));
  gb.sound.playTick();
}

//the main loop
void loop(){
  if(gb.update()){
    gb.display.drawBitmap(8,6,sprite);
  }
}


While writing this, I even tested one of the examples, and that failed to do much of anything.
It seems like all the code that fails me is code that was compiled via the arduino IDE, so maybe there is a problem with the way i'm doing it..

Any ideas, problems in the code, or possible fixes? All help is greatly appreciated. :)
Last edited by Montiey on Sun Feb 15, 2015 9:30 pm, edited 1 time in total.
User avatar
Montiey
 
Posts: 68
Joined: Sat Jan 17, 2015 5:38 pm

Re: [help] Blank screen error

Postby Myndale » Sun Feb 15, 2015 6:33 am

Montiey wrote:but even something as simple as this little program doesn't load right


Worked fine for me, so yeah, it sounds like there's something wrong with your setup.

I'd start by downloading HEX games from the site and running them on your hardware to rule out the problemis there. Next I'd take that snippet you wrote and try running it in the Simbuino emulator, if you don't see anything there then the problem is definitely your setup. Are you sure you've selected the correct "Gamebuino" in Tools -> Board?
Myndale
 
Posts: 507
Joined: Sat Mar 01, 2014 1:25 am

Re: [help] Blank screen error

Postby Montiey » Sun Feb 15, 2015 2:12 pm

Whoops! :lol:
Changed the board to my Mega 2560 for a science fair project.. Never changed it back.

I'll test some stuff and see if it works.
User avatar
Montiey
 
Posts: 68
Joined: Sat Jan 17, 2015 5:38 pm


Return to Programming Questions

Who is online

Users browsing this forum: No registered users and 15 guests

cron