Drawing Bitmaps when x < 0 doesn't seems to work

Advice on general approaches or feasibility and discussions about game design

Drawing Bitmaps when x < 0 doesn't seems to work

Postby Valden » Tue Jul 07, 2015 2:49 pm

It seems there is a problem with the drawBitmap (at least in the beta branch) : if the X position of the image is negative, nothing is displayed at all. At first I thought it wasn't supported (the function would simply return if X < 0), but after a quick look in the function source code, it appears that it should work. See here https://github.com/Rodot/Gamebuino/blob/beta/libraries/Gamebuino/Display.cpp#L514-538

I have a solution for this problem, but it would be better if the function didn't have this bug.

Has anyone encountered the same problem as me ?
User avatar
Valden
 
Posts: 31
Joined: Mon Jun 08, 2015 5:33 pm

Re: Drawing Bitmaps when x < 0 doesn't seems to work

Postby rodot » Tue Jul 07, 2015 4:53 pm

Hey,

Can you provide an example ? I just tried and it seems to work fine :

Code: Select all
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;

//bitmap encoded using the Bitmap Encoder which can be found here : http://gamebuino.com/wiki/index.php?title=Download
const byte pointerBitmap[] PROGMEM = {16,22,0xC,0x0,0x12,0x0,0x12,0x0,0x12,0x0,0x12,0x0,0x13,0x80,0x12,0x70,0x12,0x4C,0x12,0x4A,0xD2,0x49,0xB0,0x9,0x90,0x1,0x90,0x1,0x40,0x1,0x40,0x1,0x20,0x1,0x20,0x2,0x10,0x2,0x10,0x2,0x8,0x4,0x8,0x4,0xF,0xFC,};
void setup(){
  gb.begin();
  gb.titleScreen(F("Bitmap example"));
}

void loop(){
  if(gb.update()){
    gb.display.drawBitmap(-3, -3, pointerBitmap);
    gb.display.drawBitmap(20, 20, pointerBitmap);
   
    //don't forget to allow the user to get back to the title screen when C is used :
    if(gb.buttons.pressed(BTN_C)){
      gb.titleScreen(F("Bitmap example"));
    }
  }
}
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Drawing Bitmaps when x < 0 doesn't seems to work

Postby Valden » Tue Jul 07, 2015 5:25 pm

I'm sorry, the bug was on my side :oops:

I still don't know why it didn't worked the first time, but now it does.
User avatar
Valden
 
Posts: 31
Joined: Mon Jun 08, 2015 5:33 pm


Return to Project Guidance & Game development

Who is online

Users browsing this forum: No registered users and 115 guests