lab.cpp/SDL#4/xMario/BreakableBloc/xMarioMysteryBloc.cpp

60 lines
1.2 KiB
C++
Raw Normal View History

/* [CONSTRUCTOR] Construction d'un xMarioGreenShell
=========================================================*/
xMarioMysteryBloc::xMarioMysteryBloc(xManager *m, int x, int y, int nb)
: xMarioBreakableBloc(
m,
"src/myst_bloc.png",
x,
y,
nb
){
this->setType("mystery-bloc");
/* (2) On definit les clip de chaque frame */
this->addFrame( (SDL_Rect){0, 0, 16, 16} );
this->addFrame( (SDL_Rect){0, 16, 16, 16} );
this->addFrame( (SDL_Rect){0, 32, 16, 16} );
this->addFrame( (SDL_Rect){0, 48, 16, 16} );
2016-03-13 23:06:33 +00:00
}
/* [ACTIVE] Gestion du caractere "actif" du bouton
=========================================================*/
void xMarioMysteryBloc::active(bool active){
_active = active;
if( active ){
2016-03-14 12:14:35 +00:00
this->pull();
this->clear();
2016-03-14 12:14:35 +00:00
2016-03-13 23:06:33 +00:00
this->addFrame( (SDL_Rect){0, 0, 16, 16} );
this->addFrame( (SDL_Rect){0, 16, 16, 16} );
this->addFrame( (SDL_Rect){0, 32, 16, 16} );
this->addFrame( (SDL_Rect){0, 48, 16, 16} );
2016-03-14 12:14:35 +00:00
// On ajoute au rendu
this->push(_index);
2016-03-14 12:14:35 +00:00
2016-03-13 23:06:33 +00:00
}else{
this->pull();
this->clear();
2016-03-13 23:06:33 +00:00
this->addFrame( (SDL_Rect){0, 64, 16, 16} );
2016-03-14 12:14:35 +00:00
this->addFrame( (SDL_Rect){0, 64, 16, 16} );
this->addFrame( (SDL_Rect){0, 64, 16, 16} );
this->addFrame( (SDL_Rect){0, 64, 16, 16} );
// On ajoute au rendu
this->push(_index);
2016-03-13 23:06:33 +00:00
}
}