C:/DevKitPro/!MDuel/source/wp_hook.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_hook.h"
00021 #include "player.h"
00022 #include "gameManager.h"
00023 #include "floorTile.h"
00024 
00025 wp_hook::~wp_hook()
00026 {
00027         if (isFiring() || wasFiring())
00028                 pawn->updateAnimation();
00029 }
00030 
00031 void wp_hook::weaponTick()
00032 {
00033         Weapon::weaponTick();
00034         
00035         if (pawn->isOnRope() || pawn->isOnGround() && isFiring())
00036                 stopFiring();
00037         
00038         bWasFiring = bFiring;
00039         
00040         if (!isFiring() && wasFiring())
00041                 pawn->updateAnimation();
00042 }
00043 
00044 void wp_hook::weaponFireAction()
00045 {
00046         if (floorGrabTimer > 0)
00047         {
00048                 pawn->setFrame(38);
00049                 floorGrabTimer--;
00050         } else
00051                 pawn->setFrame(37);
00052         
00053         //rope grabbing first
00054         if (pawn->justTouchingRope())
00055         {
00056                 pawn->climbRope(false);
00057                 pawn->setvx(0);
00058         } else {
00059                 s16 xpos = (pawn->getFlippedh() ? pawn->getLeft() : pawn->getRight());
00060                 s16 ypos = pawn->gety();
00061                 for (vector<spriteObject*>::iterator it = pawn->gm->gameSprites.begin(); it != pawn->gm->gameSprites.end(); ++it)
00062                 {
00063                         if (dynamic_cast<floorTile*>(*it) != NULL &&
00064                                 (*it)->pointCollision(xpos, ypos))
00065                         {
00066                                 pawn->setvy((Player::JUMPIMPULSE>>8)*2/3);
00067                                 floorGrabTimer = spriteObject::TICKSPERFRAME*3;
00068                                 break;
00069                         }
00070                 }
00071         }
00072 }
00073 
00074 void wp_hook::stopFiring()
00075 {
00076         Weapon::stopFiring();
00077         floorGrabTimer = 0;
00078 }

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