NEW 6 years ago
J'attend avec impatience la version couleur!!
ça a l'air fun comme tout !!
ps: bonne chance pour le développement :3
NEW 6 years ago
Question pour Stéphane principalement mais bon si d'autres veulent répondre, ils sont les bienvenu.
J'ai lu ton tuto et j'ai compris à peu près, je pense, mais maintenant je voudrais le mettre en pratique en commençant par le plus compliqué et le plus simple en même temps: l'affichage du background. Le truc, c'est je pense que l'on est obligé de découper le fond en 16 bandes pour que ça ne prenne pas trop de place en mémoire ?
J'hésite un peu du coup, j'avais commencé à l'implémenter sur le modèle de la balle. Tu ferais comment toi ? Je ne pense pas que l'on est trop de moyen d'optimiser.
Je mets les images ci dessous: 2 images avec les sprites positionnés juste pour l'aperçu, 2 fonds vides (l'helico peut rester sur le fond) pour que tu puisses tester si tu veux et en dessous une série de 16 bandes correspondant au fond blanc pour si tu veux tester le système à bandes ou me proposer une autre solution que celles des 16 sprites.
Voilà, après les autres sprites, je peux partir sur le même principe que la balle avec un attribut 'actif' booléen pour dire s'il est allumé ou non.
Enfin, je ne vois pas d'autres difficultés particulières mais ça viendra sans doute comme je vais essayer de faire de la POO et que je n'en ai pas l'habitude pour le moment, alors je publiais mon code régulièrement pour m'assurer que je ne pars pas sur de mauvaises voies (Enfin souvent quand j'aurais le temps de programmer ;) )
NEW 6 years ago
Hum dans ton système, du coup, dans Background.h, il faudrait que je déclare ça comme ça ?
#ifndef BACKGROUND_DEFINITION #define BACKGROUND_DEFINITION #include "Renderable.h" class Background : public Renderable { private: // the descriptive parameters of the sprite static const uint8_t FRAME_WIDTH; static const uint8_t FRAME_HEIGHT; static const uint16_t TRANSPARENT_COLOR; // the pixel map obtained with the transcoding tool static const uint16_t BITMAP[16]; // the coordinates of each part of the background, which are constants static const uint8_t X_POS=0; static const uint8_t Y_POS[16]={0,8,16,24,32,40,48,56,64,72,80,88,96,104,112,120}; public: // a destructor must be declared here to avoid potential memory leaks ~Background(); // the famous method of fulfilling the `Renderable` contract void draw(uint8_t sliceY, uint8_t sliceHeight, uint16_t* buffer) override; }; #endif
Et du coup je mets ça dans Background.cpp pour chacune des BITMAP de 1 à 16 ?
#include <Gamebuino-Meta.h>
#include "Background.h"
#include "constants.h"
// we copy the descriptive parameters of our sprite
const uint8_t Background::FRAME_WIDTH = 160;
const uint8_t Background::FRAME_HEIGHT = 128;
const uint16_t Background::TRANSPARENT_COLOR = 0xffff;
const uint8_t Background::X_POS = 0;
const uint8_t Background::Y_POS = 0;
const uint16_t Background::BITMAP[1] = {
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xbef7, 0xbef7, 0xdfff, 0xdfff, 0xdfff, 0xbef7, 0xbef7,
0xbef7, 0xbef7, 0xffff, 0xdfff, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xdfff, 0xbef7, 0xbef7, 0xffff,
0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7,
0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xffff, 0xbef7, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7,
0xbef7, 0xbef7, 0xbef7, 0xdfff, 0xbef7, 0xdfff, 0xbef7, 0xdfff, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7,
0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xdfff, 0xdfff, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7,
0xbef7, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0x7def, 0x5def, 0x5def, 0x5def, 0xbef7, 0xdfff, 0xffff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0x0000, 0x0000, 0x0000, 0x0000, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0x0000, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0x0000, 0x0000, 0x0000,
0x0000, 0xbef7, 0xdfff, 0xbef7, 0xbef7, 0xbef7, 0x0000, 0xdfff, 0xbef7, 0xbef7, 0xbef7, 0xbef7, 0x0000, 0x0000, 0x0000, 0xbef7,
0xbef7, 0x0000, 0x0000, 0xbef7, 0x0000, 0x0000, 0xdfff, 0x0000, 0x0000, 0xbef7, 0xbef7, 0x0000, 0x0000, 0xbef7, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xbef7, 0x0000, 0x0000, 0x8631, 0x0000, 0x0000, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xbef7, 0xbef7, 0x0000, 0x0000, 0x0000, 0xbef7, 0xbef7, 0xbef7, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0xdfff, 0xbef7, 0xbef7, 0x0000, 0x0000, 0x0000, 0xffff, 0xbef7, 0xbef7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xbef7,
0x0000, 0x0000, 0xbef7, 0x0000, 0x0000, 0xdfff, 0x0000, 0x0000, 0xbef7, 0xbef7, 0x0000, 0x0000, 0x9ef7, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xbef7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0x0000, 0x0000,
0xbef7, 0x0000, 0x0000, 0xbef7, 0xbef7, 0x0000, 0x0000, 0x0000, 0xbef7, 0xbef7, 0xbef7, 0x0000, 0x0000, 0xbef7, 0x0000, 0x0000,
0xdfff, 0xbef7, 0xbef7, 0x0000, 0x0000, 0x0000, 0xbef7, 0xbef7, 0xbef7, 0x0000, 0x0000, 0xbef7, 0x0000, 0x0000, 0xbef7, 0x0000,
0x0000, 0xbef7, 0x0000, 0x0000, 0xdfff, 0x0000, 0x0000, 0xbef7, 0xbef7, 0x0000, 0x0000, 0xbef7, 0xdfff, 0xbef7, 0x0000, 0x0000,
0xbef7, 0xbef7, 0xbef7, 0x0000, 0x0000, 0xbef7, 0xbef7, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0x0000, 0x0000, 0xbef7,
0x0000, 0x0000, 0xbef7, 0x0000, 0x0000, 0xbef7, 0x0000, 0x0000, 0xbef7, 0xbef7, 0x0000, 0x0000, 0xdfff, 0x0000, 0x0000, 0xdfff,
0xbef7, 0x0000, 0x0000, 0xbef7, 0x0000, 0x0000, 0xbef7, 0xbef7, 0x0000, 0x0000, 0xbef7, 0xdfff, 0xbef7, 0xbef7, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xdfff, 0x0000, 0x0000, 0xbef7, 0xdfff, 0x0000, 0x0000, 0xbef7, 0xdfff, 0xbef7, 0x0000, 0x0000, 0xbef7,
0xbef7, 0xbef7, 0x0000, 0x0000, 0x0000, 0x0000, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0xbef7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xbef7, 0xbef7, 0x0000, 0x0000, 0x0000, 0x0000, 0xbef7, 0xdfff, 0xbef7,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xbef7, 0xbef7, 0x0000, 0x0000, 0xdfff, 0xdfff, 0xbef7, 0xbef7, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xdfff, 0x0000, 0x0000, 0xdfff, 0xbef7, 0x0000, 0x0000, 0x9ef7, 0xdfff, 0xbef7, 0x0000, 0x0000, 0xbef7, 0xbef7,
0xbef7, 0x0000, 0x0000, 0x0000, 0x0000, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0x0000, 0x0000, 0x0000, 0x0000, 0xbef7,
0xbef7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xdfff, 0xbef7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xdfff, 0xbef7, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xbef7, 0xbef7, 0x0000, 0x0000, 0xbef7, 0x0000, 0x0000, 0xbef7, 0x0000, 0x0000, 0xbef7, 0x0000,
0x0000, 0xdfff, 0x0000, 0x0000, 0xdfff, 0xbef7, 0x0000, 0x0000, 0xffff, 0xdfff, 0xbef7, 0x0000, 0x0000, 0xbef7, 0xdfff, 0xbef7,
0x0000, 0x0000, 0x9ef7, 0xbef7, 0xdfff, 0xffff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff,
0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff, 0xdfff};
// a destructor must be defined here to
// avoid potential memory leaks
Background::~Background() {
// he's not doing anything special here,
// but it's important to think about it!
}
// and we define the method of calculating the rendering of the ball
void Background::draw(uint8_t sliceY, uint8_t sliceHeight, uint16_t* buffer) {
// the portion of the sprite which is located within
// the current slice is determined along the Y axis
int8_t startIndex = Y_POS <= sliceY ? 0 : Y_POS - sliceY;
int8_t endIndex = Y_POS + FRAME_HEIGHT >= sliceY + sliceHeight ? sliceHeight - 1 : Y_POS + FRAME_HEIGHT - sliceY - 1;
// we prepare a variable that will receive in turn the color codes
// of each of the pixels that make up the sprite (in the current slice)
uint16_t value;
// coordinates of the processed pixel
uint8_t x,y;
// now we go through the portion of the sprite that is in the slice
// along the Y axis...
for (y = startIndex; y <= endIndex; y++) {
// and the X axis
for (x = X_POS; x < X_POS + FRAME_WIDTH; x++) {
// we will pick the color of the corresponding pixel
value = BITMAP[x - X_POS + (y + sliceY - Y_POS) * FRAME_WIDTH];
// and if it is not the transparent color
if (value != TRANSPARENT_COLOR) {
// we copy it into the buffer
buffer[x + y * SCREEN_WIDTH] = value;
}
}
}
}
Si ce n'est pas comme ça ou s'il y a des erreurs, je prends les conseils / corrections avant d'implmenter les 16 images