00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
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;
00064 }
00065 if (getx() < -16 || getx() > 271)
00066 {
00067 destroy();
00068 return;
00069 } else if (y >= (s32)SCREENH+4096)
00070 {
00071 #ifdef __WITHSOUND
00072 playSound(&owner->gm->smallSplash);
00073 #endif
00074
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))
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 }