C:/DevKitPro/!MDuel/source/wp_gren_proj.cpp

Go to the documentation of this file.
00001 /*
00002  * Marshmallow Duel DS v2
00003  * Copyright © 2007 Sam Pospischil http://pospi.spadgos.com
00004  * 
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00018  */
00019 
00020 #include "wp_gren_proj.h"
00021 #include "player.h"
00022 #include "floorTile.h"
00023 #include "gameManager.h"
00024 
00025 wp_gren_proj::wp_gren_proj(spriteManager* newsm, Player* p) : massObject(newsm), owner(p)
00026 {
00027         #ifdef __MDDEBUG
00028         className = "wp_gren_proj";
00029         macros::debugMessage(className, "constructor");
00030         #endif
00031         gameManager* gm = dynamic_cast<gameManager*>(sm);
00032         setPallete(gm->pickupSprite.palleteID);
00033         //GFX warning!
00034         giveSprite(gm->pickupSprite.spriteData, OBJ_SIZE_16X16, 8, 8, 60);
00035         setBounds(2, 2, 5, -1);
00036         setAnim(26, 27, ANIMSPEED);
00037         setCollision(COL_SOLID);
00038         setCheckCollision(true);
00039         setLayer(2);
00040 }
00041 
00042 wp_gren_proj::~wp_gren_proj()
00043 {
00044         gameManager *gm = dynamic_cast<gameManager *>(sm);
00045         
00046         if (gm->isResetting())
00047                 return;
00048         
00049         u8 dieAnim[4] = {0, 1, 2, 3};
00050         vector<u8> temp(dieAnim, dieAnim+4);
00051         #ifdef __WITHSOUND
00052         playSound(&owner->gm->platformExplode);
00053         #endif
00054         owner->gm->createSingleFireSprite(owner->gm->FXSprite.palleteID, (owner == owner->gm->player1 ? owner->gm->spawnGFX[2] : owner->gm->spawnGFX[3]), temp, TICKSPERFRAME*2, getx(), getBottom(), OBJ_SIZE_32X32, 16, 16);
00055 }
00056 
00057 void wp_gren_proj::updateSprite()
00058 {
00059         if (isOnGround())
00060         {
00061                 setBounds(2, 8, 5, -4); //bigger collision to take out neighbouring platforms
00062                 for (vector<spriteObject*>::iterator it = sm->gameSprites.begin(); it != sm->gameSprites.end(); ++it)
00063                 {
00064                         if (dynamic_cast<floorTile*>(*it) != NULL &&
00065                                 isColliding(*it))
00066                         {
00067                                 //check if the destroyed floor was under a player
00068                                 gameManager *gm = dynamic_cast<gameManager *>(sm);
00069                                 if (gm->player1->isStandingOn(*it))
00070                                         gm->player1->groundDeleted(Player::CS_GRENFALL);
00071                                 if (gm->player2->isStandingOn(*it))
00072                                         gm->player2->groundDeleted(Player::CS_GRENFALL);
00073                                 
00074                                 (*it)->destroy();
00075                         }
00076                 }
00077                 destroy();
00078                 return;
00079         }
00080         if (getx() < -16 || getx() > 271)       //out of the screen now, dont wanna see the death FX either
00081         {
00082                 destroy();
00083                 return;
00084         } else if (y >= (s32)SCREENH+4096)      //fell out of bottom so make a splash, go low enough to hide death FX
00085         {
00086                 #ifdef __WITHSOUND
00087                 playSound(&owner->gm->smallSplash);
00088                 #endif
00089                 //GFX warning!
00090                 u8 f[3] = {13, 14, 15};
00091                 vector<u8> temp(f, f+3);
00092                 sm->createSingleFireSprite(owner->gm->FXSprite.palleteID, owner->gm->FXSprite.spriteData, temp, TICKSPERFRAME*2, getx(), gameManager::MALLOWYPOS, OBJ_SIZE_32X32, 16, 16);
00093                 destroy();
00094                 return;
00095         }
00096         
00097         massObject::updateSprite();
00098 }

Generated on Tue Mar 13 23:27:53 2007 for MDuel DS by  doxygen 1.5.1-p1