SDL#4 Premier rendu propre
|
@ -30,6 +30,10 @@ int main(int argc, char* argv[]) {
|
||||||
btmleft.push();
|
btmleft.push();
|
||||||
|
|
||||||
|
|
||||||
|
xMarioGrass floattcenter(mgr, (SDL_Rect){10, 10, 5, 5} );
|
||||||
|
floattcenter.push();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [3] Gestion des animations (blocs animes)
|
/* [3] Gestion des animations (blocs animes)
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -41,6 +45,9 @@ int main(int argc, char* argv[]) {
|
||||||
xMarioMysteryBloc mb(mgr, 5, 20-5);
|
xMarioMysteryBloc mb(mgr, 5, 20-5);
|
||||||
mb.start(150, SPRITE_ANIM_INFINITE);
|
mb.start(150, SPRITE_ANIM_INFINITE);
|
||||||
|
|
||||||
|
// On cree un bloc normal
|
||||||
|
// xMarioBloc bl(mgr, (SDL_Rect){0, 20-2, 10, 3});
|
||||||
|
// bl.push();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
BIN
SDL#4/main.o
BIN
SDL#4/src/01.jpg
Before Width: | Height: | Size: 8.5 MiB |
BIN
SDL#4/src/1.bmp
Before Width: | Height: | Size: 257 KiB |
After Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 725 KiB After Width: | Height: | Size: 400 KiB |
Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 140 KiB |
After Width: | Height: | Size: 2.0 MiB |
Before Width: | Height: | Size: 213 KiB |
Before Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 53 KiB |
|
@ -16,6 +16,7 @@
|
||||||
#include "xMario/xMarioGrass.h"
|
#include "xMario/xMarioGrass.h"
|
||||||
#include "xMario/xMarioGreenShell.h"
|
#include "xMario/xMarioGreenShell.h"
|
||||||
#include "xMario/xMarioMysteryBloc.h"
|
#include "xMario/xMarioMysteryBloc.h"
|
||||||
|
#include "xMario/xMarioBloc.h"
|
||||||
|
|
||||||
|
|
||||||
/* [BODIES] Inclusion des .cpp des sous-libs
|
/* [BODIES] Inclusion des .cpp des sous-libs
|
||||||
|
@ -23,5 +24,6 @@
|
||||||
#include "xMario/xMarioGrass.cpp"
|
#include "xMario/xMarioGrass.cpp"
|
||||||
#include "xMario/xMarioGreenShell.cpp"
|
#include "xMario/xMarioGreenShell.cpp"
|
||||||
#include "xMario/xMarioMysteryBloc.cpp"
|
#include "xMario/xMarioMysteryBloc.cpp"
|
||||||
|
#include "xMario/xMarioBloc.cpp"
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -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++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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
|
|
@ -1,4 +1,4 @@
|
||||||
/* [CONSTRUCTOR] Construction d'un xSMarioGrass
|
/* [CONSTRUCTOR] Construction d'un xMarioGrass
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){
|
xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){
|
||||||
_manager = m;
|
_manager = m;
|
||||||
|
@ -13,7 +13,7 @@ xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){
|
||||||
|
|
||||||
|
|
||||||
/* (1) On charge la texture */
|
/* (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;
|
int index = 0;
|
||||||
|
@ -29,7 +29,7 @@ xMarioGrass::xMarioGrass(xManager *m, SDL_Rect rect){
|
||||||
if( x == xMin && y == yMin ){
|
if( x == xMin && y == yMin ){
|
||||||
this->get(index)->dimensions(
|
this->get(index)->dimensions(
|
||||||
(SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE},
|
(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 ){
|
else if( x == xMax && y == yMin ){
|
||||||
this->get(index)->dimensions(
|
this->get(index)->dimensions(
|
||||||
(SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE},
|
(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 ){
|
else if( x == xMin && y == yMax ){
|
||||||
this->get(index)->dimensions(
|
this->get(index)->dimensions(
|
||||||
(SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE},
|
(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 ){
|
else if( x == xMax && y == yMax ){
|
||||||
this->get(index)->dimensions(
|
this->get(index)->dimensions(
|
||||||
(SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE},
|
(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 ){
|
else if( x == xMin ){
|
||||||
this->get(index)->dimensions(
|
this->get(index)->dimensions(
|
||||||
(SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE},
|
(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 ){
|
else if( x == xMax ){
|
||||||
this->get(index)->dimensions(
|
this->get(index)->dimensions(
|
||||||
(SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE},
|
(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 ){
|
else if( y == yMin ){
|
||||||
this->get(index)->dimensions(
|
this->get(index)->dimensions(
|
||||||
(SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE},
|
(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 ){
|
else if( y == yMax ){
|
||||||
this->get(index)->dimensions(
|
this->get(index)->dimensions(
|
||||||
(SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE},
|
(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{
|
else{
|
||||||
this->get(index)->dimensions(
|
this->get(index)->dimensions(
|
||||||
(SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE},
|
(SDL_Rect){BLOC_SIZE*x, BLOC_SIZE*y, BLOC_SIZE, BLOC_SIZE},
|
||||||
(SDL_Rect){18, 17, 16, 16}
|
(SDL_Rect){137, 167, 16, 16}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|