SDL#2 Animations gestion du fond (effacage) a faire

This commit is contained in:
xdrm-brackets 2016-03-11 01:25:46 +01:00
parent 1dcbae6a14
commit 7a43c382a5
3 changed files with 42 additions and 13 deletions

BIN
SDL#2/exe

Binary file not shown.

View File

@ -25,31 +25,60 @@ int main(int argc, char* argv[]) {
/* [4] On ajoute une sprite /* [4] On ajoute Une animation
=========================================================*/ =========================================================*/
/* (1) On met un fond */
int white[] = {255, 255, 255};
Sprite *coin_background = new Sprite(
white,
(SDL_Rect){0, 0, 180, 200}
);
/* (2) On enregistre les frames de l'animation */
SpriteGroup animated_coin; SpriteGroup animated_coin;
animated_coin.add( new Sprite(
"src/coins.jpg",
(SDL_Rect){0, 0, 180, 200},
(SDL_Rect){57, 50, 180, 200}
) );
// On ajoute un fond entre chaque pour cacher si chgt taille
animated_coin.add( coin_background );
/* (1) On enregistre les frames de l'animation */ animated_coin.add( new Sprite(
for( int i = 0 ; i < 7 ; i++ ){ "src/coins.jpg",
(SDL_Rect){0, 0, 180, 200},
animated_coin.add( new Sprite( (SDL_Rect){57+200, 50, 180, 200}
"src/coins.jpg", ) );
(SDL_Rect){0, 0, 180, 180}, animated_coin.add( coin_background );
(SDL_Rect){57+168*i, 40, 180, 180}
) );
}
animated_coin.add( new Sprite(
"src/coins.jpg",
(SDL_Rect){30, 0, 150, 200},
(SDL_Rect){57+200*2, 50, 180, 200}
) );
animated_coin.add( coin_background );
animated_coin.add( new Sprite(
"src/coins.jpg",
(SDL_Rect){80, 0, 100, 200},
(SDL_Rect){57+200*3-30, 50, 180, 200}
) );
animated_coin.add( coin_background );
animated_coin.add( new Sprite(
"src/coins.jpg",
(SDL_Rect){30, 0, 150, 200},
(SDL_Rect){57+200*4+10, 50, 180, 200}
) );
animated_coin.add( coin_background );
/* [5] On lance l'animation en parallele /* [5] On lance l'animation en parallele
=========================================================*/ =========================================================*/
thread* anim = animated_coin.animate(mgr->window(), 1000 ); thread* anim = animated_coin.animate(mgr->window(), 500 );
anim->detach(); // On laisse le thread tourner anim->detach(); // On laisse le thread tourner
delete anim; // On le supprime ensuite delete anim; // On le supprime ensuite

Binary file not shown.