I’m new to Pokitto and getting familiar with the API right now.
What’s the best way to display a sprite on the screen? I tried to convert an image with the img2pok.exe tool (4 bit, 16 colors) to an uint8_t array, but the picture is displayed on the Pokitto in strange colors. I used the display.drawBitmap function from the API.
You can only use 1 palette at a time in almost all screen modes. If your colours are wrong, then either your palette isn’t loaded, or your image used a different palette.
You will need to know the colour number of your transparent part after it’s converted using img2pok, then use mygame.display.setInvisibleColor(x); to set it. Once done, that will be your transparent colour.
I want to make a simple test project, where I have a background and a character which moves around. So I have a image of the background, the character in different positions. But I heard I can only load one pallet at the same time, so how to do that with various images? An in the picture above: Can someone explain me what the numbers of the pallet and the numbers of the character itself represent? How does the program come for example from pink (245, 0, 87) to 61450? And what mean the numbers from the character(21, 17, 0, 0…)?
The palette is converted from RGB to pokitto format that should be 565 (5 bit for Red 6 for Green and 5 for Blue). If you ask why, Green is the color our eyes sense better and so the display is tailored to offer a better feel in that range.
21 and 17 is the size of the image (Width and Height) the following number are the indexes of the color used for the pixels.
You should use even sizes or you’ll get glitches for the way the data is stored.
My suggest is to build a palette with all the colors you want to use and then convert the images you need.
Sorry for the short answer. Maybe someone can integrate better.
Edit:
If source image have transparent color (loading from PNG for example) the transparent color is mapped to the first color in palette. Then you have to setInvisibleColor(0);
Because if the images are restricted to certain sizes then the code for displaying them can be made faster.
Allowing odd-sized images would require the drawing code to do more work and thus run slower.
So it’s not that it can’t be done, it’s just that there’s a penalty for doing so, and for the moment the consensus is that it’s better to have the restriction. In a future version of the API there might be a drawOddSizedImage function with a warning about using odd sized images being slower, but for now that’s how things are.