diff --git a/SDL#2/exe b/SDL#2/exe index 6444a90..fc2517b 100755 Binary files a/SDL#2/exe and b/SDL#2/exe differ diff --git a/SDL#2/main.cpp b/SDL#2/main.cpp index b18c505..70d36d5 100644 --- a/SDL#2/main.cpp +++ b/SDL#2/main.cpp @@ -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; + 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 */ - for( int i = 0 ; i < 7 ; i++ ){ - - animated_coin.add( new Sprite( - "src/coins.jpg", - (SDL_Rect){0, 0, 180, 180}, - (SDL_Rect){57+168*i, 40, 180, 180} - ) ); - - } - + animated_coin.add( new Sprite( + "src/coins.jpg", + (SDL_Rect){0, 0, 180, 200}, + (SDL_Rect){57+200, 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*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 =========================================================*/ - thread* anim = animated_coin.animate(mgr->window(), 1000 ); + thread* anim = animated_coin.animate(mgr->window(), 500 ); anim->detach(); // On laisse le thread tourner delete anim; // On le supprime ensuite diff --git a/SDL#2/main.o b/SDL#2/main.o index 419499c..f2e048e 100644 Binary files a/SDL#2/main.o and b/SDL#2/main.o differ