diff --git a/SDL#4/exe b/SDL#4/exe index 19ee9fb..43b654f 100755 Binary files a/SDL#4/exe and b/SDL#4/exe differ diff --git a/SDL#4/main.cpp b/SDL#4/main.cpp index dc8615f..633c183 100644 --- a/SDL#4/main.cpp +++ b/SDL#4/main.cpp @@ -30,6 +30,10 @@ int main(int argc, char* argv[]) { btmleft.push(); + xMarioGrass floattcenter(mgr, (SDL_Rect){10, 10, 5, 5} ); + floattcenter.push(); + + /* [3] Gestion des animations (blocs animes) =========================================================*/ @@ -41,6 +45,9 @@ int main(int argc, char* argv[]) { xMarioMysteryBloc mb(mgr, 5, 20-5); mb.start(150, SPRITE_ANIM_INFINITE); + // On cree un bloc normal + // xMarioBloc bl(mgr, (SDL_Rect){0, 20-2, 10, 3}); + // bl.push(); diff --git a/SDL#4/main.o b/SDL#4/main.o index 6b77791..45fbeec 100644 Binary files a/SDL#4/main.o and b/SDL#4/main.o differ diff --git a/SDL#4/src/01.jpg b/SDL#4/src/01.jpg deleted file mode 100644 index a286e6c..0000000 Binary files a/SDL#4/src/01.jpg and /dev/null differ diff --git a/SDL#4/src/1.bmp b/SDL#4/src/1.bmp deleted file mode 100644 index 5641e75..0000000 Binary files a/SDL#4/src/1.bmp and /dev/null differ diff --git a/SDL#4/src/bg1.gif b/SDL#4/src/bg1.gif new file mode 100644 index 0000000..42b2d3c Binary files /dev/null and b/SDL#4/src/bg1.gif differ diff --git a/SDL#4/src/bg1.png b/SDL#4/src/bg1.png index 83b53e2..bb0f983 100644 Binary files a/SDL#4/src/bg1.png and b/SDL#4/src/bg1.png differ diff --git a/SDL#4/src/blocs.png b/SDL#4/src/blocs.png index be0d152..f43171b 100644 Binary files a/SDL#4/src/blocs.png and b/SDL#4/src/blocs.png differ diff --git a/SDL#4/src/ground.png b/SDL#4/src/ground.png new file mode 100644 index 0000000..0e4a4b3 Binary files /dev/null and b/SDL#4/src/ground.png differ diff --git a/SDL#4/src/mario_crop.png b/SDL#4/src/mario_crop.png deleted file mode 100644 index f93e285..0000000 Binary files a/SDL#4/src/mario_crop.png and /dev/null differ diff --git a/SDL#4/src/mario_ground.jpg b/SDL#4/src/mario_ground.jpg deleted file mode 100644 index 89c691a..0000000 Binary files a/SDL#4/src/mario_ground.jpg and /dev/null differ diff --git a/SDL#4/src/walking.png b/SDL#4/src/walking.png deleted file mode 100644 index 1938f51..0000000 Binary files a/SDL#4/src/walking.png and /dev/null differ diff --git a/SDL#4/xMario.h b/SDL#4/xMario.h index 13e0c0e..a5fe68b 100644 --- a/SDL#4/xMario.h +++ b/SDL#4/xMario.h @@ -16,6 +16,7 @@ #include "xMario/xMarioGrass.h" #include "xMario/xMarioGreenShell.h" #include "xMario/xMarioMysteryBloc.h" + #include "xMario/xMarioBloc.h" /* [BODIES] Inclusion des .cpp des sous-libs @@ -23,5 +24,6 @@ #include "xMario/xMarioGrass.cpp" #include "xMario/xMarioGreenShell.cpp" #include "xMario/xMarioMysteryBloc.cpp" + #include "xMario/xMarioBloc.cpp" #endif \ No newline at end of file diff --git a/SDL#4/xMario/xMarioBloc.cpp b/SDL#4/xMario/xMarioBloc.cpp new file mode 100644 index 0000000..0e52bbe --- /dev/null +++ b/SDL#4/xMario/xMarioBloc.cpp @@ -0,0 +1,36 @@ +/* [CONSTRUCTOR] Construction d'un xMarioBloc +=========================================================*/ +xMarioBloc::xMarioBloc(xManager *m, SDL_Rect rect){ + _manager = m; + + // Note: le rect correspond a un nombre de bloc + // On convertit le tout en blocs reels + int xMin = rect.x; + int xMax = rect.w + rect.x - 1; + + int yMin = rect.y; + int yMax = rect.h + rect.y - 1; + + + /* (1) On charge la texture */ + _spritesheet = IMG_LoadTexture(_manager->renderer(), "src/blocs.png"); + + + int index = 0; + + /* (2) On cree les plans (layers) */ + for( int y = yMin ; y <= yMax ; y++ ){ + for( int x = xMin ; x <= xMax ; x++ ){ + // On cree une copie du spritesheet + this->add( new xSprite(_manager, _spritesheet) ); + + this->get(index)->dimensions( + (SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE}, + (SDL_Rect){0, 153, 16, 16} + ); + + index++; + } + } + +} \ No newline at end of file diff --git a/SDL#4/xMario/xMarioBloc.h b/SDL#4/xMario/xMarioBloc.h new file mode 100644 index 0000000..f24572a --- /dev/null +++ b/SDL#4/xMario/xMarioBloc.h @@ -0,0 +1,18 @@ +#ifndef DEF_XMARIOBLOC_H + + #define DEF_XMARIOBLOC_H + + /* [DEF] Definition de la classe + =========================================================*/ + class xMarioBloc : public xSpriteGroup{ + + public: + xMarioBloc(xManager *m, SDL_Rect rect); + + private: + xManager *_manager; + SDL_Texture *_spritesheet; // Contiendra la texture + + }; + +#endif \ No newline at end of file diff --git a/SDL#4/xMario/xMarioGrass.cpp b/SDL#4/xMario/xMarioGrass.cpp index 3479bbb..2935f88 100644 --- a/SDL#4/xMario/xMarioGrass.cpp +++ b/SDL#4/xMario/xMarioGrass.cpp @@ -1,4 +1,4 @@ -/* [CONSTRUCTOR] Construction d'un xSMarioGrass +/* [CONSTRUCTOR] Construction d'un xMarioGrass =========================================================*/ xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){ _manager = m; @@ -13,7 +13,7 @@ xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){ /* (1) On charge la texture */ - _spritesheet = IMG_LoadTexture(_manager->renderer(), "src/mario_ground.jpg"); + _spritesheet = IMG_LoadTexture(_manager->renderer(), "src/ground.png"); int index = 0; @@ -29,7 +29,7 @@ xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){ if( x == xMin && y == yMin ){ this->get(index)->dimensions( (SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE}, - (SDL_Rect){1, 0, 16, 16} + (SDL_Rect){137, 99, 16, 16} ); } @@ -37,7 +37,7 @@ xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){ else if( x == xMax && y == yMin ){ this->get(index)->dimensions( (SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE}, - (SDL_Rect){35, 0, 16, 16} + (SDL_Rect){171, 99, 16, 16} ); } @@ -45,7 +45,7 @@ xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){ else if( x == xMin && y == yMax ){ this->get(index)->dimensions( (SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE}, - (SDL_Rect){1, 34, 16, 16} + (SDL_Rect){137, 133, 16, 16} ); } @@ -53,7 +53,7 @@ xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){ else if( x == xMax && y == yMax ){ this->get(index)->dimensions( (SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE}, - (SDL_Rect){35, 34, 16, 16} + (SDL_Rect){171, 133, 16, 16} ); } @@ -61,7 +61,7 @@ xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){ else if( x == xMin ){ this->get(index)->dimensions( (SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE}, - (SDL_Rect){1, 17, 16, 16} + (SDL_Rect){137, 116, 16, 16} ); } @@ -69,7 +69,7 @@ xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){ else if( x == xMax ){ this->get(index)->dimensions( (SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE}, - (SDL_Rect){35, 17, 16, 16} + (SDL_Rect){171, 116, 16, 16} ); } @@ -77,7 +77,7 @@ xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){ else if( y == yMin ){ this->get(index)->dimensions( (SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE}, - (SDL_Rect){18, 0, 16, 16} + (SDL_Rect){154, 99, 16, 16} ); } @@ -85,7 +85,7 @@ xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){ else if( y == yMax ){ this->get(index)->dimensions( (SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE}, - (SDL_Rect){18, 34, 16, 16} + (SDL_Rect){137, 184, 16, 16} ); } @@ -93,7 +93,7 @@ xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){ else{ this->get(index)->dimensions( (SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE}, - (SDL_Rect){18, 17, 16, 16} + (SDL_Rect){137, 167, 16, 16} ); }