C:/DevKitPro/!MDuel/source/wp_puck_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_puck_proj.h"
00021 #include "player.h"
00022 #include "wp_mine_proj.h"
00023 #include "floorTile.h"
00024 #include "gameManager.h"
00025 #include "wp_weasel_proj.h"
00026 
00027 wp_puck_proj::wp_puck_proj(spriteManager* newsm, Player* p) : massObject(newsm), owner(p)
00028 {
00029         #ifdef __MDDEBUG
00030         className = "wp_puck_proj";
00031         macros::debugMessage(className, "constructor");
00032         #endif
00033         gameManager *gm = dynamic_cast<gameManager*>(sm);
00034         setPallete(gm->pickupSprite.palleteID);
00035         //GFX warning!
00036         giveSprite(gm->pickupSprite.spriteData, OBJ_SIZE_16X16, 8, 8, 60);
00037         setBounds(6, 2, 7, -2);
00038         setAnim(24, 25, ANIMSPEED);
00039         setCollision(COL_SOLID);
00040         setCheckCollision(true);
00041         setLayer(2);
00042 }
00043 
00044 wp_puck_proj::~wp_puck_proj()
00045 {
00046         gameManager *gm = dynamic_cast<gameManager *>(sm);
00047         
00048         if (gm->isResetting())
00049                 return;
00050         
00051         u8 dieAnim[3] = {10, 11, 12};
00052         vector<u8> temp(dieAnim, dieAnim+3);
00053         #ifdef __WITHSOUND
00054         playSound(&owner->gm->mineExp);
00055         #endif
00056         owner->gm->createSingleFireSprite(owner->gm->FXSprite.palleteID, (owner == owner->gm->player1 ? owner->gm->spawnGFX[3] : owner->gm->spawnGFX[2]), temp, TICKSPERFRAME*2, getx(), getBottom()-16, OBJ_SIZE_32X32, 16, 16);
00057 }
00058 
00059 void wp_puck_proj::updateSprite()
00060 {
00061         if (!isOnGround() && wasOnGround())
00062         {
00063                 vy = -150;      //jump up to clear a small gap
00064         }
00065         if (getx() < -16 || getx() > 271)       //out of the screen now, dont wanna see the death FX either
00066         {
00067                 destroy();
00068                 return;
00069         } else if (y >= (s32)SCREENH+4096)      //fell out of bottom so make a splash, go low enough to hide death FX
00070         {
00071                 #ifdef __WITHSOUND
00072                 playSound(&owner->gm->smallSplash);
00073                 #endif
00074                 //GFX warning!
00075                 u8 f[3] = {13, 14, 15};
00076                 vector<u8> temp(f, f+3);
00077                 sm->createSingleFireSprite(owner->gm->FXSprite.palleteID, owner->gm->FXSprite.spriteData, temp, TICKSPERFRAME*2, getx(), gameManager::MALLOWYPOS, OBJ_SIZE_32X32, 16, 16);
00078                 destroy();
00079                 return;
00080         }
00081         
00082         massObject::updateSprite();
00083 }
00084 
00085 void wp_puck_proj::collidingWith(spriteObject *other)
00086 {
00087         if (dynamic_cast<Player*>(other) != NULL)
00088         {
00089                 Player *o = dynamic_cast<Player*>(other);
00090                 if (o->hasShield() && o->isFacing(this))                //shield reflects!
00091                 {
00092                         vx *= -1;
00093                 } else {
00094                         o->gm->playerPucked(o);
00095                         destroy();
00096                 }
00097         } else if (dynamic_cast<wp_mine_proj*>(other) != NULL)
00098         {
00099                 other->destroy();
00100         } else if (dynamic_cast<wp_weasel_proj*>(other) != NULL)
00101         {
00102                 other->destroy();
00103                 destroy();
00104         }
00105         
00106         massObject::collidingWith(other);
00107 }

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