How to use directBitmap()?


#41

what you want to do? clear the screen?
draw a rectangle or whatever you want as you base background one time and you golden
just don’t forget to draw the background back where the image was or you are going to get the old windows solitaire effect :smiley:


#42

I was thinking about this issue. Perhaps we could add hardware style sprites to the screen update routines? Basically we could have a hand full of pointers to graphics, they could be 16bit or paletted and add them during the scanline creation in the various render modes. Would it slow down the rendering by much?


#43

you mean a scanline buffer?
thing is we dont realy have a scanline with the direct draw we only update a rectangle sector of the screen

thought eh idea of a rect scanline buffer could still work if you know all the sprites positions


#44

I have several ‘pages’ in my program, and on one of those, I want to draw a picture, but nothing else is drawn except for that picture. Whenever I use game.display.fillScreen(0) or game.display.fillRect(0, 0, 220, 180), however, the image flickers. If I display the image once, then it just flickers. I’m confused because I thought there was some way to direct draw and not have anything draw over what I’ve directly drawn…

I think if I directly draw my 4bit image to the screen and then don’t display anything until the user goes to the next ‘page,’ then nothing should overwrite it. Is there a way to prevent the screen from refreshing until I allow it to?


#45

Game.display.update(1); will update your controls etc but leave the screen alone.


#46

If I understood correctly, you are drawing in two ways, buffered draw and direct draw, within the same frame. That makes it flicker. The buffered draw draws to the whole LCD when you call Update(false). If you after that call direct draw to draw to LCD, it will flicker.

If you use direct drawing, you should do all drawing directly and avoid drawing the same LCD pixels twice.

It is also possible to make a new buffered screen mode (or enhance current modes) so that it skips certain area of the LCD screen, which is reserved for your direct drawing, to avoid flicker.


#47

I did see someone here discuss that.


#48

Use game.display.fillLCD() or game.display.directRectangle() instead.


#49

As expected, this didn’t work. :slightly_frowning_face: Flickers the entire time.


#50

Here’s my current code… :-/

#include "Pokitto.h"
#include <stdint.h>

Pokitto::Core game;

/*
const uint16_t pal_default[] = {
    65535,  //White
    0,      //Black
    9609,   //Green
    34818   //Red
};
*/

const uint16_t pal_default[] = {
    0,      //White
    65535,  //Black
    29582,  //Gray
    32865,  //Dark Red
    47234,  //Red
    54580,  //Light Red
    27554,  //Dark Green
    33989,  //Green
    44693,  //Light Green
    12913,  //Dark Blue
    21527,  //Blue
    38331,  //Light Blue
    22785,  //Dark Brown
    31300,  //Brown
    60973,  //Yellow
    63220   //Tan
};

const uint8_t logo[] = {
160,80,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,254,191,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,250,171,255,255,254,170,255,255,255,255,255,250,175,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,234,170,191,255,250,170,175,255,170,191,255,234,175,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,254,170,170,175,255,170,170,171,254,170,170,170,170,175,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,250,170,170,171,254,170,170,170,250,170,170,170,170,191,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,234,171,254,171,250,170,254,170,255,170,170,170,170,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,234,175,254,170,250,171,254,170,191,234,170,170,171,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,234,175,254,170,250,171,255,170,191,250,170,170,175,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,234,171,254,170,190,175,255,170,191,250,170,170,191,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,234,171,254,170,191,255,254,170,191,250,170,170,191,255,255,255,255,255,255,255,255,255,255,255,255,255,250,175,255,255,255,255,255,255,255,255,255,255,255,
255,234,171,254,170,191,255,254,170,191,250,170,170,191,255,255,255,255,255,255,255,255,255,255,255,255,255,234,171,255,255,255,255,255,255,255,255,255,255,255,
255,250,171,250,170,191,255,254,170,191,250,170,170,191,255,255,255,255,255,255,255,255,255,255,255,255,255,234,171,255,255,255,255,255,255,255,255,255,255,255,
255,254,175,250,170,191,255,250,170,191,250,170,170,191,255,255,255,255,255,255,255,255,255,255,255,255,255,234,171,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,234,170,191,255,234,170,191,250,170,170,191,255,255,255,255,255,255,255,255,255,255,255,255,255,254,175,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,170,170,191,255,170,170,255,250,170,170,191,255,255,255,255,255,255,255,255,255,255,255,255,255,254,191,255,255,255,255,255,255,255,255,255,255,255,
255,255,254,170,170,255,254,170,170,255,250,170,170,191,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,254,170,170,255,254,170,170,255,250,170,170,191,255,255,170,255,255,254,191,255,255,250,255,255,255,250,255,255,235,255,175,255,255,255,255,255,255,255,
255,255,250,170,170,255,250,170,170,255,250,170,170,255,255,254,170,175,255,254,171,254,175,250,175,250,191,250,191,255,170,255,171,255,255,255,254,255,255,255,
255,255,250,170,171,255,234,170,171,255,250,170,170,255,255,250,170,170,255,250,170,250,170,234,171,234,171,234,171,255,170,174,170,191,255,255,250,175,255,255,
255,255,234,170,171,255,234,170,171,255,250,170,170,255,255,234,170,170,175,250,170,186,170,170,170,234,171,234,170,255,170,170,170,170,255,255,234,170,255,255,
255,255,170,170,171,254,170,170,171,255,250,170,170,255,255,170,170,170,171,234,170,170,170,170,170,170,171,170,170,254,170,170,170,170,255,254,170,170,175,255,
255,254,170,170,175,254,170,170,175,255,250,170,170,255,254,171,234,170,171,234,170,170,170,170,170,170,171,170,170,250,170,170,170,170,255,170,170,170,171,255,
255,254,170,170,175,250,170,170,175,255,250,170,170,255,254,175,254,170,171,234,170,170,175,170,170,170,191,170,171,254,170,175,234,171,254,170,190,170,171,255,
255,250,170,170,175,250,170,170,175,255,250,170,170,255,254,171,255,170,175,250,170,190,175,234,170,250,191,234,171,255,170,175,250,171,254,170,191,170,175,255,
255,234,170,170,191,234,170,170,191,255,250,170,170,255,254,170,255,170,175,254,170,190,175,250,170,250,191,234,171,255,170,175,250,171,254,170,191,234,175,255,
255,234,170,170,191,234,170,170,191,255,250,170,170,255,255,170,254,170,175,254,170,191,175,250,170,254,191,234,171,255,170,175,234,171,254,170,191,234,175,255,
255,234,170,170,191,234,170,170,191,255,250,170,170,255,255,235,254,170,175,254,170,191,255,250,170,255,255,234,171,255,170,175,234,171,255,170,175,170,175,255,
255,234,170,170,255,170,170,170,255,255,250,170,170,255,255,255,170,170,175,254,170,191,255,250,170,255,255,234,171,255,170,175,234,171,255,170,175,170,175,255,
255,170,170,170,255,170,170,170,255,255,250,170,170,255,255,234,170,170,175,254,170,191,255,250,170,255,255,234,171,255,170,175,234,171,255,170,175,170,175,255,
255,170,170,170,255,170,170,170,255,255,250,170,170,191,254,170,174,170,175,254,170,191,255,250,170,255,255,234,171,255,170,175,234,171,255,170,175,170,175,255,
254,170,170,170,255,170,170,170,255,255,250,170,170,191,254,170,191,170,175,254,170,191,255,250,170,255,255,234,171,255,170,175,234,171,255,170,175,170,175,255,
254,170,170,171,255,170,170,170,255,255,250,170,170,191,254,170,191,170,175,254,170,191,255,250,170,255,255,234,171,255,170,175,234,171,255,170,175,170,175,255,
254,170,170,171,255,170,170,170,255,255,250,170,170,191,254,170,191,170,175,254,170,191,255,250,170,255,255,234,171,255,170,175,234,171,255,170,175,170,175,255,
254,170,170,171,255,170,170,170,250,255,250,170,170,191,254,170,191,170,175,254,170,191,255,250,170,255,255,234,171,255,170,175,234,171,255,170,175,170,175,255,
254,170,170,171,255,170,170,170,234,191,250,170,170,191,254,170,191,170,175,254,170,191,255,250,170,255,255,234,171,255,170,175,234,171,255,170,175,170,175,255,
254,170,170,171,255,234,170,170,170,191,250,170,170,191,254,170,174,170,170,254,170,175,255,250,170,191,255,234,170,255,170,175,234,170,255,170,191,170,171,255,
255,170,170,171,255,234,170,170,170,191,250,170,170,191,254,170,170,170,170,254,170,170,255,250,170,171,255,170,170,255,170,170,234,170,191,170,171,170,171,255,
255,170,170,170,255,234,170,170,170,255,234,170,170,175,250,170,170,170,170,234,170,170,191,170,170,171,255,170,170,254,170,170,234,170,190,170,170,170,170,255,
255,234,170,170,255,234,170,170,170,255,234,170,170,175,250,170,170,170,171,234,170,170,255,170,170,171,254,170,170,254,170,171,234,170,254,170,170,170,170,191,
255,234,170,170,191,250,170,170,171,255,234,170,170,175,254,170,175,170,175,254,170,175,255,250,170,191,255,234,171,255,170,175,234,171,254,170,170,250,170,175,
255,250,170,170,175,250,170,170,175,255,170,170,170,171,255,234,175,234,175,255,170,191,255,254,170,255,255,250,171,255,234,175,254,171,255,234,171,254,170,175,
255,250,170,170,171,250,170,170,171,254,170,170,170,170,255,238,175,250,175,255,250,191,255,255,234,255,255,255,175,255,254,175,255,171,255,254,171,254,170,191,
255,254,170,170,170,170,170,170,171,234,170,170,170,170,171,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,239,254,170,255,
255,255,170,170,170,170,170,170,170,170,170,170,170,170,170,171,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,175,255,254,171,255,
255,255,250,170,170,170,170,170,170,170,170,170,170,170,170,170,255,255,254,191,255,255,255,255,255,255,255,255,255,171,255,255,255,254,170,170,255,254,171,255,
255,255,254,170,170,170,191,170,170,170,170,255,254,170,170,170,191,255,234,175,255,255,255,255,255,255,255,255,254,171,255,255,255,234,170,170,175,250,191,255,
255,255,255,234,170,171,255,254,170,170,255,255,255,255,255,170,191,255,250,175,255,255,255,255,255,255,255,255,255,170,255,255,255,170,170,170,170,171,255,255,
255,255,255,254,170,191,255,255,255,255,255,255,255,255,255,234,191,255,250,175,255,255,255,255,255,255,255,255,255,170,255,255,255,171,234,170,170,175,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,234,191,255,254,175,255,255,255,255,255,255,255,255,255,170,255,255,255,170,254,170,170,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,234,191,255,254,175,255,255,255,255,255,255,255,255,255,170,255,255,255,170,191,170,171,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,254,175,255,255,255,255,255,255,255,255,255,170,255,255,255,234,191,250,171,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,254,175,255,254,191,255,175,250,191,255,254,170,255,254,171,255,255,255,175,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,254,175,255,234,175,254,175,234,191,255,234,170,255,250,171,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,254,175,254,170,171,254,170,170,175,255,170,170,255,170,170,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,254,175,250,191,171,254,170,254,175,250,191,170,254,175,234,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,170,170,171,254,175,234,255,171,254,171,254,175,234,191,170,254,175,251,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,170,170,170,190,175,170,255,171,254,171,254,175,234,191,170,254,175,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,234,170,170,170,175,170,255,171,254,171,254,175,234,191,170,254,171,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,170,175,170,255,171,254,171,254,175,234,191,170,254,170,191,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,250,175,170,255,171,254,171,254,175,234,191,170,255,234,171,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,254,175,170,255,171,254,171,254,175,234,191,170,255,250,170,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,254,175,170,255,171,254,171,254,175,234,191,170,255,255,170,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,254,175,170,255,171,254,171,254,175,234,191,170,255,255,234,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,254,175,170,255,171,254,171,254,175,234,191,170,255,255,250,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,254,175,170,255,171,254,171,254,175,234,191,170,255,175,250,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,254,175,170,255,171,254,171,254,175,234,191,170,255,175,250,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,254,175,234,186,171,255,170,254,171,234,186,170,254,170,235,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,254,175,234,171,170,255,170,254,170,234,171,170,190,170,171,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,254,175,250,191,235,255,171,255,175,254,191,251,255,234,191,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,170,175,255,254,171,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,170,175,255,254,175,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,250,191,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
};

const uint8_t me[] =
{
80,80,
170,169,170,170,170,154,170,170,170,154,170,170,170,154,170,160,170,160,13,221,221,221,221,221,221,208,170,170,170,170,154,170,170,169,170,170,170,0,34,17,
170,170,154,170,170,169,170,170,170,153,170,170,170,170,170,0,160,13,221,221,221,221,221,221,221,208,0,170,170,169,170,170,170,154,170,170,170,0,34,17,
170,170,169,170,170,169,170,170,170,169,170,170,170,169,160,221,13,221,221,221,221,221,221,221,221,0,192,170,170,169,170,170,170,154,170,170,170,51,68,85,
170,170,169,154,170,170,154,170,170,169,154,170,170,160,13,221,221,221,221,221,221,221,221,221,221,12,208,170,170,154,170,170,169,170,170,170,170,51,68,85,
170,170,170,153,170,170,169,170,170,170,153,170,170,13,221,221,222,237,221,221,221,221,221,221,221,221,208,170,169,154,170,170,154,170,170,170,170,153,170,187,
154,170,170,169,154,170,169,154,170,170,0,0,0,221,221,221,221,238,238,221,237,208,221,221,221,221,10,170,169,170,170,170,154,170,170,170,170,153,170,187,
153,170,170,170,154,170,170,154,170,160,205,221,221,221,221,221,221,221,222,238,237,221,221,237,222,221,10,170,153,170,170,169,170,170,170,170,169,102,119,136,
169,154,170,170,153,170,170,169,170,170,14,237,221,221,221,221,221,221,221,222,221,14,222,237,238,208,170,170,154,170,170,169,170,170,170,170,154,102,119,136,
170,154,170,170,169,154,170,169,154,160,0,238,221,221,221,221,208,221,221,237,208,238,238,238,238,224,170,169,154,170,170,154,170,170,170,169,204,221,238,255,
170,169,170,170,170,153,170,170,153,13,221,221,221,221,221,221,13,221,221,221,0,221,237,222,221,0,10,153,170,170,169,170,170,170,170,154,204,221,238,255,
170,170,154,170,170,169,154,170,169,13,221,221,221,221,221,221,13,221,221,208,13,221,221,13,221,221,10,153,170,170,153,170,170,170,169,170,169,170,170,169,
154,170,169,170,170,169,154,170,169,13,221,221,221,208,12,204,12,205,221,208,221,221,220,0,205,192,169,154,170,169,154,170,170,170,154,170,154,170,170,154,
169,170,170,154,170,170,153,170,170,13,221,221,221,15,240,0,0,0,204,0,204,204,192,255,12,10,153,154,170,169,170,170,170,169,170,169,170,170,169,170,
170,154,170,169,170,170,169,154,170,13,221,221,221,15,255,255,255,255,0,0,0,0,15,255,240,170,153,170,170,153,170,170,170,154,170,154,170,169,154,170,
170,169,170,169,154,170,170,153,170,12,204,205,208,255,255,255,255,255,255,255,255,255,255,255,240,169,153,170,169,154,170,170,169,170,169,170,170,153,170,170,
170,170,154,170,153,170,170,153,154,13,221,220,208,255,255,255,255,255,255,255,255,255,255,255,240,169,154,170,169,154,170,170,154,170,154,170,169,154,170,170,
170,170,169,170,169,154,170,169,154,12,204,205,192,255,255,255,255,204,204,255,254,255,204,204,240,153,154,170,153,170,170,169,154,169,170,170,153,170,170,170,
154,170,170,154,170,153,170,170,153,13,221,220,15,255,255,255,204,204,204,207,239,252,204,204,192,153,170,169,154,170,170,153,170,154,170,169,154,170,170,169,
153,170,170,169,170,169,154,170,169,144,221,208,255,255,255,252,207,255,255,255,255,255,255,255,192,153,170,153,154,170,169,154,169,170,170,153,170,170,169,154,
169,154,170,170,154,170,153,170,169,144,221,15,255,255,255,255,255,255,255,255,255,255,255,255,240,153,153,153,170,170,153,170,154,170,153,154,170,170,154,170,
170,153,154,170,169,170,169,154,170,160,204,15,255,255,255,255,255,255,255,255,255,255,255,255,240,153,153,153,170,169,154,169,170,169,153,170,170,169,170,170,
170,170,153,170,170,154,170,153,170,160,221,15,255,255,255,255,240,0,15,255,255,255,0,0,240,153,153,153,170,153,170,154,170,153,154,170,169,170,170,170,
170,170,169,154,170,169,170,169,154,160,221,15,255,255,255,255,1,17,16,255,255,240,17,17,0,153,153,153,169,154,169,169,153,153,170,170,154,170,170,169,
170,170,170,153,170,170,154,170,153,160,221,15,255,255,255,240,17,17,17,15,255,1,17,17,16,153,153,153,153,170,154,153,153,154,170,153,170,170,169,154,
153,170,170,170,153,170,169,170,153,144,13,208,255,255,255,240,17,0,17,15,255,1,16,1,16,153,153,153,154,169,170,153,153,170,169,170,170,170,154,170,
153,153,170,170,169,154,170,154,169,153,13,208,255,255,255,240,17,0,17,15,255,1,16,1,16,153,153,153,170,154,169,153,153,169,154,170,170,153,170,170,
169,153,153,170,170,153,170,169,170,153,12,192,255,255,255,240,17,17,17,15,255,1,17,17,16,0,9,154,169,170,153,153,153,154,169,153,169,170,170,169,
170,169,153,153,170,170,154,170,154,160,13,208,255,255,255,255,1,17,16,255,255,224,17,17,15,15,240,154,154,169,153,153,153,154,169,153,154,170,170,154,
170,170,153,153,153,170,169,154,169,15,240,221,15,255,255,255,240,0,15,255,255,15,0,0,255,14,240,169,170,153,153,153,153,154,170,154,170,170,154,170,
153,170,170,153,153,153,170,153,160,255,239,13,15,255,255,255,255,255,255,255,255,15,255,255,255,14,240,153,153,154,169,153,153,154,153,170,170,154,170,170,
169,154,170,170,153,153,154,153,144,254,238,240,15,255,255,255,255,255,255,255,255,240,255,255,255,0,240,153,153,153,153,153,153,153,170,170,153,170,170,153,
170,169,153,170,169,153,153,153,144,254,224,240,15,255,255,255,255,255,255,255,255,240,255,255,255,14,240,153,153,153,154,153,153,170,170,169,170,170,153,170,
154,170,169,153,170,153,153,153,144,255,0,255,255,255,255,255,255,255,255,255,255,255,15,255,255,14,9,153,153,153,154,169,154,170,169,170,170,153,170,170,
169,154,170,169,153,170,169,153,153,15,224,255,255,255,255,255,255,255,255,255,255,255,240,255,255,14,9,153,153,153,154,154,170,169,170,170,153,170,170,170,
170,169,154,170,169,153,170,169,154,15,254,239,240,255,255,255,255,255,255,255,255,255,255,15,255,240,9,153,153,153,153,170,169,154,170,153,170,170,170,153,
170,170,169,154,170,169,153,169,153,144,254,240,255,254,255,255,255,255,255,240,255,255,240,255,255,240,153,153,153,153,153,169,154,170,153,170,170,170,153,170,
170,170,170,169,153,153,153,153,153,153,15,240,255,15,255,255,240,0,15,255,14,238,15,255,255,240,153,153,187,153,153,154,169,154,170,170,169,154,170,170,
153,170,170,153,153,153,153,153,153,153,144,0,240,255,15,255,4,1,16,255,255,255,255,255,255,240,153,153,187,185,153,153,154,170,170,169,154,170,170,170,
170,169,153,153,153,153,153,153,153,153,153,153,15,240,255,255,4,64,17,0,255,255,255,255,255,240,153,153,187,187,185,153,170,170,169,154,170,170,170,153,
170,170,169,153,153,153,153,187,185,153,153,153,144,239,240,255,4,68,1,17,0,255,255,255,240,240,185,153,155,187,185,153,170,153,153,154,170,153,153,170,
154,170,169,153,153,153,153,187,187,153,153,187,176,255,15,255,240,68,64,17,17,15,255,255,255,0,187,153,153,187,153,153,153,153,153,153,153,153,170,170,
170,153,153,153,153,153,153,155,187,153,155,187,187,0,255,240,240,68,68,0,0,255,255,240,255,224,187,185,153,153,153,153,153,153,153,153,153,154,170,170,
170,170,170,153,153,153,153,153,153,153,155,187,187,187,0,15,255,4,68,68,15,255,240,255,14,224,187,187,153,153,153,154,169,0,0,153,153,153,170,170,
154,170,170,170,153,153,153,153,153,153,187,187,187,176,0,224,15,240,0,0,255,254,255,15,224,11,187,187,185,153,153,170,160,255,255,9,153,153,169,153,
153,153,153,154,169,153,153,153,153,153,187,187,187,7,96,254,224,15,255,255,254,240,255,0,0,187,187,187,185,153,153,170,15,255,255,9,153,153,154,170,
170,170,153,153,153,153,153,153,0,0,0,0,0,7,15,255,238,224,0,0,0,0,0,6,112,187,176,0,0,9,153,160,255,255,255,9,153,153,154,170,
170,170,170,170,153,153,153,144,7,119,119,119,119,7,15,255,254,238,238,238,238,238,238,7,112,0,7,119,119,0,153,144,255,255,240,153,153,153,153,153,
154,170,170,170,153,153,187,7,7,119,119,119,119,7,15,255,255,254,238,238,238,238,239,7,119,7,119,119,119,7,9,144,238,255,240,153,153,153,154,170,
169,153,170,170,153,155,187,7,7,119,119,119,112,119,112,255,255,255,255,255,255,255,255,7,119,7,119,119,118,119,112,153,14,239,240,153,153,154,170,170,
153,154,153,169,153,155,176,119,7,119,119,119,112,119,119,15,255,255,255,255,255,255,240,119,119,7,119,119,118,119,119,9,15,255,240,153,153,154,170,170,
153,154,170,153,153,153,176,119,103,119,119,119,112,119,119,112,15,240,0,0,255,240,7,119,119,7,119,119,118,112,0,0,0,255,240,153,153,154,153,153,
153,154,153,153,153,153,7,119,112,119,119,119,112,119,119,119,112,0,68,68,15,4,7,119,119,7,119,119,103,15,255,255,255,255,255,9,153,153,154,170,
153,153,153,153,153,153,7,119,119,103,119,119,112,119,119,112,0,6,4,68,64,4,64,0,7,7,119,119,103,15,255,255,255,255,255,9,153,153,153,170,
154,153,153,153,153,144,119,119,119,103,119,119,112,119,0,6,102,0,0,68,68,68,68,6,96,119,119,119,103,15,255,255,255,255,255,9,153,153,153,170,
170,153,153,153,153,144,119,119,119,118,119,119,119,0,102,119,112,68,68,68,64,4,68,7,119,119,119,119,103,0,239,255,255,255,255,240,153,153,153,170,
170,153,153,153,153,7,119,119,119,118,119,119,119,119,119,119,0,0,4,68,12,4,4,64,0,7,119,118,119,15,255,255,255,255,255,240,153,153,153,153,
170,153,153,153,153,7,119,119,119,118,119,119,119,119,119,119,119,0,68,64,208,64,160,68,64,224,119,118,119,15,255,255,255,255,255,240,153,153,153,170,
169,153,153,153,144,119,119,119,119,118,119,119,119,119,119,119,112,68,68,13,208,64,0,68,14,238,7,118,119,0,239,255,255,255,255,255,9,153,153,154,
169,153,153,153,144,119,119,119,119,119,103,119,119,119,119,119,4,68,0,221,221,4,68,64,238,0,7,118,119,15,255,255,255,255,255,255,9,153,153,153,
153,153,153,153,7,119,119,119,119,119,103,119,119,119,119,119,0,0,112,221,221,208,0,12,0,119,119,103,119,15,255,255,255,255,255,255,9,153,153,153,
153,153,153,153,0,119,119,119,119,119,103,119,119,119,119,119,119,119,13,220,221,221,221,220,4,7,119,103,119,112,255,255,255,255,255,255,9,153,153,153,
153,153,153,153,7,7,119,119,119,119,103,119,119,119,119,119,119,119,12,205,221,221,221,208,68,7,119,103,119,112,238,238,239,255,255,255,9,153,153,153,
153,153,153,187,7,112,119,119,119,119,118,119,119,119,119,119,119,112,205,221,221,221,221,4,68,7,119,103,119,119,14,238,238,239,255,255,240,153,153,153,
153,153,155,187,0,119,7,119,119,119,118,119,119,119,119,119,119,112,221,221,221,221,208,68,64,119,119,6,119,119,112,0,0,0,255,255,240,153,153,153,
153,153,155,187,15,7,112,119,119,119,112,119,119,119,119,119,119,13,221,221,221,221,7,4,7,119,118,6,119,119,119,112,15,255,255,255,240,153,153,153,
153,153,155,187,15,240,119,0,119,119,96,119,119,119,119,119,112,221,221,221,221,221,7,112,119,119,118,6,103,119,0,15,15,255,255,255,240,153,153,153,
153,153,155,187,15,255,7,119,0,118,96,103,119,119,119,119,13,221,221,221,221,208,119,119,119,119,118,6,102,112,255,255,240,255,255,255,255,9,153,153,
153,153,153,187,15,255,240,7,119,0,0,0,0,0,0,0,221,221,220,221,221,208,119,119,119,119,118,96,102,15,255,255,240,255,255,255,255,9,153,153,
153,153,153,144,255,255,255,240,7,102,0,205,221,221,221,221,221,221,221,220,221,208,119,119,119,119,118,96,96,239,255,255,240,255,255,255,255,240,153,153,
153,153,153,144,255,255,255,255,240,0,221,13,204,221,221,221,221,221,221,221,221,221,0,119,119,119,119,102,0,238,255,255,240,255,255,255,255,240,153,153,
169,153,153,144,255,255,255,255,254,0,13,221,221,205,221,221,221,221,221,221,221,221,221,7,119,119,119,102,14,238,255,255,240,255,255,255,255,255,9,153,
169,153,153,144,255,255,255,255,0,221,208,221,221,220,221,221,221,221,221,208,13,221,221,208,119,119,119,102,14,238,239,255,240,255,255,255,255,255,9,153,
169,153,153,144,255,255,255,240,205,221,221,208,221,205,220,221,221,221,208,15,240,220,220,14,7,119,119,118,0,238,239,255,15,255,255,255,255,255,224,153,
169,153,153,144,255,255,255,0,204,221,221,221,13,220,205,221,205,0,15,255,240,221,192,238,7,119,119,118,0,238,238,255,15,255,255,255,255,255,224,153,
169,153,153,15,255,255,255,255,0,0,221,221,208,221,221,204,208,255,255,254,13,221,14,255,7,119,119,119,0,238,238,240,255,255,255,255,255,255,238,9,
153,153,153,15,255,255,255,255,255,255,13,221,221,221,221,221,15,255,255,0,221,0,255,255,7,119,119,119,11,14,238,224,255,255,255,255,255,254,238,9,
153,153,153,15,255,255,255,255,255,255,240,12,221,221,221,208,255,255,240,0,0,255,255,255,7,119,119,119,11,176,238,14,255,255,255,255,255,254,238,9,
153,153,144,255,255,255,255,255,255,255,255,240,204,221,221,208,255,255,255,255,255,255,255,240,119,119,119,119,11,176,238,14,255,255,255,255,255,254,238,9,
153,153,144,239,255,255,255,255,255,255,255,255,0,0,0,15,255,255,255,255,255,255,240,14,7,119,119,119,11,153,14,238,239,255,255,255,255,238,224,153,
153,153,153,14,238,238,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,240,15,255,7,119,119,119,9,153,14,238,239,255,255,255,254,238,224,153,

};



//const uint8_t ex_sprite[] = { 0, 0, 0, 0 };
//const uint16_t ex_pal[] = { 35599, 20147, 15921, 51309 };
//rand() % 50
//game.display.load565Palette(pallette);
//game.display.setColor(3, 0);
//game.display.setCursor(0, 0);
//game.display.print("crait");
//game.buttons.pressed(BTN_A)
//game.display.drawBitmap(0, 0, ex_sprite);

bool cansave = true;
short state = -10;
short alert = 0;
unsigned int coins = 0;
short mainmenu_index = 0;
bool drawn = false;
short x = 0;
short y = 0;

bool next(short to) {
    if(game.buttons.pressed(BTN_A)) {
        state = to;
        game.display.load565Palette(pal_default);
        game.display.clear();
        game.display.setColor(0, 3);
        game.display.setCursor(0, 0);
        drawn = false;
        game.display.update();
        return true;
    }
    return false;
}

bool dismiss() {
    if(game.buttons.pressed(BTN_B)) {
        alert = 0;
        return true;
    }
    return false;
}

void saveerror() {
    game.display.print("Save Error!");
    dismiss();
}

void preventsave() {
    game.display.print("Saving Disabled!");
    dismiss();
}

void savedone() {
    game.display.print("Saving Done!");
    dismiss();
}

void showcard() {
    game.display.setCursor(0, 0);
    game.display.print("Showing A Card!\n\nB) Dismiss");
}

void showcredits() {
    game.display.setCursor(0, 0);
    game.display.setColor(0, 3);
    game.display.print("Credits Screen");
    if(!drawn) {
        //game.display.load565Palette(pal_me);
        //game.display.drawRect(0, 0, 220, 180);
        game.display.fillLCD(0);
        game.display.directBitmap(80, 80, me, 4, 1);
        drawn = true;
    }
    
    next(0);
}

void mainmenu() {
    game.display.setCursor(0, 100);
    //game.display.print("Warring Hands\n\n");
    
    game.display.drawBitmap(30, 10, logo);
    
    game.display.setColor(0, 3);
    game.display.println("         Battle Tower");
    game.display.println("         Free Battle");
    game.display.println("         Deck Editor");
    game.display.println("         Card Catalog");
    game.display.println("         Shop");
    game.display.println("         Link Battle");
    game.display.println("         Settings");
    
    game.display.setCursor(0, mainmenu_index * 9 + 100);
    game.display.print("     >");
    if(game.buttons.pressed(BTN_UP) && mainmenu_index > 0) {
        mainmenu_index--;
    }
    if(game.buttons.pressed(BTN_DOWN) && mainmenu_index < 6) {
        mainmenu_index++;
    }
    next(mainmenu_index + 1);
}

void battletower() {
    game.display.setCursor(0, 0);
    game.display.print("Battle Tower");
    next(0);
    
}

void freebattle() {
    game.display.setCursor(0, 0);
    game.display.print("Free Battle");
    next(0);
}

void deckeditor() {
    game.display.setCursor(0, 0);
    game.display.print("Deck Editor");
    next(0);
}

void cardcatalog() {
    game.display.setCursor(0, 0);
    game.display.print("Card Catalog");
    next(0);
}

void shop() {
    game.display.setCursor(0, 0);
    game.display.print("Shop");
    next(0);
}

void linkbattle() {
    game.display.setCursor(0, 0);
    game.display.print("Link Battle");
    next(0);
}

void settings() {
    game.display.setCursor(0, 0);
    game.display.print("Settings");
    next(0);
}

/*
-10:Credits
0:Main Menu
    1:Battle Tower
        Deck Select
            Battle
    2:Free Battle/Opponent Select
        Deck Select
            Battle
    3:Deck Editor
        Deck List
            Select Deck
                Editing
    4:Card Catalog
        Card List
    5:Shop
        Booster List
    6:Link Battle
        Deck Select
            Battle
    10:Settings
        About
        Unlock All Cards (Cannot Save)
        Delete Data
*/

void savedeck() {
    if(cansave) {
        
    } else {
        alert = -2;
    }
}

void savecatalog() {
    if(cansave) {
        
    } else {
        alert = -2;
    }
}

void unlockallcards() {
    cansave = false;
}

void deletedata() {
    
}

void update() {
    if(alert != 0) {
        switch(alert) {
            case -3:
                savedone();
                break;
            case -2:
                preventsave();
                break;
            case -1:
                saveerror();
                break;
            default:
            case 0:
                break;
            case 1:
                showcard();
                break;
        }
    } else {        
        switch(state) {
            default:
            case -10:
                showcredits();
                break;
            case 0:
                mainmenu();
                break;
            case 1:
                battletower();
                break;
            case 2:
                freebattle();
                break;
            case 3:
                deckeditor();
                break;
            case 4:
                cardcatalog();
                break;
            case 5:
                shop();
                break;
            case 6:
                linkbattle();
                break;
            case 7:
                settings();
                break;
        }
    }
}

int main() {
    game.begin();
    game.display.persistence = true;
    game.display.load565Palette(pal_default);
    game.display.clear();
    game.display.bgcolor = 0;
    game.display.directbgcolor = 0;
    game.display.setColor(0, 3);
    while(game.isRunning()) {
        if(game.update(true)) {
            update();
        }
    }
    
    return 1;
}

#51

…because in your main() you are using game.update(true) to specify direct mode (ie. does not call display.update()), but then you are always manually calling display.update() anyway in next()?

And you are trying to use buffered and direct mode together on the one screen:

void showcredits() {
    game.display.setCursor(0, 0);
    game.display.setColor(0, 3);
    game.display.print("Credits Screen");
    if(!drawn) {
        //game.display.load565Palette(pal_me);
        //game.display.drawRect(0, 0, 220, 180);
        game.display.fillLCD(0);
        game.display.directBitmap(80, 80, me, 4, 1);
        drawn = true;
    }
    next(0);
}

I think you’d need to use directChar() instead? or just make “Credits Screen” part of the bitmap?


#52

You can also call game.display.enableDirectPrinting(true); when initializing the game. I tried your code on HW and noticed there is still somewhat flicker in the text rendering even if direct text rendering is used. I do not know why. The direct bitmap looks to work fine.


#53

I begin also to like about the idea of sprites. I hit to the performance problems in HW with my Mars Attack game. I used to reconstruct the whole background for each frame because there is no memory for storing the full background image, but in 220x176 mode it is just too slow. So I swiched display.persistence on, and do not draw the background each frame, but now I have to store the background dirty rect for each moving object.

With sprites there would not be any need to store bg dirty rects, as the screen buffer can be considered as a “background” for sprites. Also especially for the Hires mode (4 colors), multicolor sprites would bring very welcome extra colors to the game.


#54

Hi!!! I have some question in the pic, please tell me.
And how to display transparent points?
Thank you!!!


#55

#the pallet:
pallet is a array of unsigned 16 bit integers. the rgb patern is in 565.
so 5 bits for red 6 for green and 5 for blue
thats then combined into a single decimal number (see bit shifting)
dont forget to enable your pallet in the game game.display.load565Palette(nameOfYourPallet);
#the sprite:
sprite are arrays of 8 bit unsigned integers and start of with its width and height after that is 2 pixels per byte which index what color to use in the pallet
its easier to see and edit the sprite in hex (0xFF) then decimal

#the transparency:
transparency is not handled by the sprite or pallet at all
you can set which color of the pallet is going to be transparent
i usualy take the last one
game.display.invisiblecolor = 15;


#56

Just wondering: fillLcd with color is bassicly the same as setting bgcolor ? Or does fillLcd allow for a color that is not in the color pallete ?


#57

Thanks, adekto!!!
I have using what you tell me to display it successfully.

But I have some questions.

(1) I found if I used game.display.update(), my craft looks like twinkling.
but if I dont used it, moving craft’s old display still here.
aircraft.zip (1.5 KB)

(2) img2pok has a tiny bug, it cause array[][num], this num is wrong.


#58

@79859899 I see what’s going on its doing floor(width /2)×14 +2

I’m not sure how sprites react with an odd widths

@Rakkachi its similar but bgcoler is more in use for the display buffer wen filllcd is a direct call to screen


#59

I want to describe the odd img still in screen if I use game.display.directBitmap(xaxis,yaxis,aircraft_bmp[2],4,1);
How to resolve this problem ?


#60

Ive solved this problem, but why :joy:
and I found the screen resolution ratio decreased.