2016-03-13 13:53:39 +00:00
|
|
|
/* [CONSTRUCTOR] Construction d'un xMarioGreenShell
|
|
|
|
=========================================================*/
|
|
|
|
xMarioGreenShell::xMarioGreenShell(xManager *m, int x, int y)
|
|
|
|
: xSpriteAnimation(
|
|
|
|
m,
|
2016-03-17 09:17:21 +00:00
|
|
|
"src/koopa.png",
|
2016-03-16 09:17:28 +00:00
|
|
|
(SDL_Rect){
|
|
|
|
(int)( BLOC_SIZE*x+BLOC_SIZE*.1 ),
|
|
|
|
(int)( BLOC_SIZE*y+BLOC_SIZE*.3 ),
|
|
|
|
(int)( BLOC_SIZE*.8 ),
|
|
|
|
(int)( BLOC_SIZE*.7 )
|
|
|
|
}
|
2016-03-13 13:53:39 +00:00
|
|
|
){
|
2016-03-18 07:55:50 +00:00
|
|
|
/* (1) Initialisation des attributs */
|
2016-03-17 09:17:21 +00:00
|
|
|
this->setType("green-shell");
|
|
|
|
_active = false;
|
|
|
|
_intouch = false;
|
2016-03-13 13:53:39 +00:00
|
|
|
|
|
|
|
/* (2) On definit les clip de chaque frame */
|
2016-03-17 09:17:21 +00:00
|
|
|
this->addFrame( (SDL_Rect){62, 90, 16, 15} );
|
|
|
|
this->addFrame( (SDL_Rect){62, 90, 16, 15} );
|
|
|
|
this->addFrame( (SDL_Rect){62, 90, 16, 15} );
|
|
|
|
this->addFrame( (SDL_Rect){62, 90, 16, 15} );
|
2016-03-18 07:55:50 +00:00
|
|
|
|
2016-03-17 09:17:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-03-18 07:55:50 +00:00
|
|
|
/* [AUTOMOVE] Gestion du mouvement
|
|
|
|
=========================================================*/
|
|
|
|
void xMarioGreenShell::autoMove(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-03-17 09:17:21 +00:00
|
|
|
|
|
|
|
/* [ACTIVE] Retourne l'etat du bouton
|
|
|
|
=========================================================*/
|
|
|
|
bool xMarioGreenShell::active(){
|
|
|
|
return _active;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* [ACTIVE] Gestion du caractere "actif" du bouton
|
|
|
|
=========================================================*/
|
|
|
|
void xMarioGreenShell::active(bool active){
|
|
|
|
_active = active;
|
|
|
|
|
|
|
|
|
|
|
|
if( active ){
|
|
|
|
|
|
|
|
|
|
|
|
this->pull();
|
|
|
|
this->clear();
|
|
|
|
|
|
|
|
|
|
|
|
this->addFrame( (SDL_Rect){62, 90, 16, 15} );
|
|
|
|
this->addFrame( (SDL_Rect){83, 90, 16, 15} );
|
|
|
|
this->addFrame( (SDL_Rect){104, 90, 16, 15} );
|
|
|
|
this->addFrame( (SDL_Rect){125, 90, 16, 15} );
|
|
|
|
|
|
|
|
// On ajoute au rendu
|
|
|
|
this->push(_index);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
this->pull();
|
|
|
|
this->clear();
|
|
|
|
|
|
|
|
this->addFrame( (SDL_Rect){62, 90, 16, 15} );
|
|
|
|
this->addFrame( (SDL_Rect){62, 90, 16, 15} );
|
|
|
|
this->addFrame( (SDL_Rect){62, 90, 16, 15} );
|
|
|
|
this->addFrame( (SDL_Rect){62, 90, 16, 15} );
|
|
|
|
|
|
|
|
// On ajoute au rendu
|
|
|
|
this->push(_index);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* [ONCOLLIDE] Gestion des collisions
|
|
|
|
=========================================================*/
|
|
|
|
void xMarioGreenShell::onCollide(vector<int> from, xSprite* by){
|
|
|
|
/* (1) Mario par le cote */
|
2016-03-18 07:55:50 +00:00
|
|
|
if( by->getType() == "Mario" && (from[0]||from[1]) && !_intouch ){
|
2016-03-17 09:17:21 +00:00
|
|
|
|
|
|
|
// si en mvt
|
|
|
|
if( this->active() ){
|
|
|
|
this->manager()->state = 2; // mario meurt
|
|
|
|
|
|
|
|
// si immobile, on met en mvt
|
|
|
|
}else{
|
|
|
|
this->active(true); // sinon on fait tourner
|
|
|
|
_intouch = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* (2) Mario par le haut */
|
2016-03-18 07:55:50 +00:00
|
|
|
if( by->getType() == "Mario" && from[2] ){
|
2016-03-17 09:17:21 +00:00
|
|
|
if( !this->active() ) // a l'arret, on met en mvt
|
|
|
|
this->active(true);
|
|
|
|
else // si en mouvement, met a l'arret
|
|
|
|
this->active(false);
|
|
|
|
}
|
2016-03-13 13:53:39 +00:00
|
|
|
}
|