[SOLVED] total newbie problems

Understanding the language, error messages, etc.

Re: total newbie problems

Postby Montiey » Sun Feb 08, 2015 11:27 pm

Thats very weird..
User avatar
Montiey
 
Posts: 68
Joined: Sat Jan 17, 2015 5:38 pm

Re: total newbie problems

Postby Montiey » Sun Feb 08, 2015 11:28 pm

I'm going to start chopping things off until it works, so I can see what killed it. :)
Last edited by Montiey on Sun Feb 08, 2015 11:32 pm, edited 2 times in total.
User avatar
Montiey
 
Posts: 68
Joined: Sat Jan 17, 2015 5:38 pm

Re: total newbie problems

Postby Jamish » Sun Feb 08, 2015 11:29 pm

To answer your other questions, while 1 is the same as while true. And your program isn't using too much memory (looks like it's using 800 out of 2000 bytes, most of which is used up by the gamebuino library)
User avatar
Jamish
 
Posts: 73
Joined: Wed Dec 17, 2014 6:52 pm
Location: California

Re: total newbie problems

Postby Montiey » Sun Feb 08, 2015 11:41 pm

I even chopped it down to this and it still doesn't work:
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[]=
{
  38,12,
  B00111100, B00110000, B11000011, B11000000, B111100,
  B00111100, B00110000, B11000011, B11000000, B111100,
  B11000011, B00110000, B11001100, B00110011, B000011,
  B11000011, B00110000, B11001100, B00110011, B000011,
  B11000011, B00110000, B11001100, B00000011, B000000,
  B11000011, B00110000, B11001100, B00000011, B000000,
  B11111100, B00110000, B11001100, B11000011, B001100,
  B11111100, B00110000, B11001100, B11000011, B001100,
  B11000011, B00110000, B11001100, B00110011, B000011,
  B11000011, B00110000, B11001100, B00110011, B000011,
  B00111100, B00001111, B00000011, B11000000, B111100,
  B00111100, B00001111, B00000011, B11000000, B111100,
};

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[]=
{
  6,6,
  B011110,
  B100001,
  B101101,
  B101101,
  B100001,
  B011110,
};

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; //the size of the ball in number of pixels
int item1_x = 30; //initial X position of item1
int item1_y = 10; //initial Y position of item1
int item2_size = 8;
int item2_x = 40;
int item2_y = 2;

// 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;
    }
    //bonus : play a preset sound when A and B are pressed
    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.drawBitmap(player_x, player_y, player);
    gb.display.drawBitmap(item1_x,item1_y,item1);
    gb.display.drawBitmap(item2_x,item2_y,item2);
    gb.display.print("$"); gb.display.print(score);
    // timer and endgame system removed for bug testing :(
  }
}


After I load the game, the backlight cuts off while it is finishing loading (Loading text still visible), and then the screen clears and stays blank.
Maybe there is a problem with my libraries or the way the gb.begin and # include functions are working, because the backlight is never activated?
User avatar
Montiey
 
Posts: 68
Joined: Sat Jan 17, 2015 5:38 pm

Re: [SOLVED] total newbie problems

Postby Montiey » Mon Feb 16, 2015 2:01 pm

Eventually I figured out my problems with some "help" from Myndale. :P

All the problems in this thread have been solved.
User avatar
Montiey
 
Posts: 68
Joined: Sat Jan 17, 2015 5:38 pm

Previous

Return to Programming Questions

Who is online

Users browsing this forum: No registered users and 15 guests

cron