00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _PLAYER_H
00021 #define _PLAYER_H
00022
00023 #include <PA9.h>
00024 #include <dswifi9.h>
00025 #include <vector>
00026 using std::vector;
00027 #include <time.h>
00028 #include "macros.h"
00029 #include "massObject.h"
00030
00031 #include "rope.h"
00032
00033
00034 class gameManager;
00035 class Weapon;
00036
00052 class Player : public massObject
00053 {
00054 public:
00055 Player(gameManager *newgm);
00056 virtual ~Player();
00057
00058 void setControls(u8 nplayerNum);
00059
00061 u8 getPlayerNum() {return playerNum;}
00062
00063 void checkPad();
00064 void basicInput(bool hr, bool hl, bool hu, bool hd, bool nr, bool nl, bool nu, bool nd, bool hf, bool nf);
00065
00067 void resetPlayer() {setPos(startx, starty); setBasePos(starty); setFlipped(startFlipped); setSpeed(0,0); playIdle();}
00068
00070 void freezePlayer() {vx=0;vy=0;playerNum=-1;bStasis=true;setCollision(COL_NONE);setCheckCollision(false);}
00071
00073 void disableControls() {bIgnoreInput=true;}
00074
00079 bool isDisabled() {return (playerNum == -1 && bStasis);}
00080 bool readyForVictory();
00081
00082 virtual void updateSprite();
00083
00091 void setStartPos(s16 x, s16 y) {setPos(x,y); setBasePos(y); startx = x; starty = y;}
00092
00097 void setStartFlipped(bool f) {setFlipped(f); startFlipped = f;}
00098
00099 virtual void collidingWith(spriteObject *other);
00100 virtual bool isColliding(const spriteObject *other, bool checkReverse = true);
00101 void collideNormally(Player *o);
00102
00103
00104 bool jump(bool bootsJump = false);
00105 bool crouch();
00106 void bounce(bool pushedForwards = false);
00107 bool roll(bool backwards = false);
00108 void uncrouch(bool hr, bool hl);
00109 void climbRope(bool hd);
00110 void justlanded(bool hr, bool hl);
00111 void justfell();
00112
00113 void setUnstable(bool unst) {bUnstable = unst;}
00114 bool isUnstable() {return bUnstable;}
00115
00116
00118 void playIdle() {setFrame(0);}
00120 void playRunning() {setAnim(1, 4, ANIMSPEED);}
00121 void playCrouching();
00122 void playRolling();
00123 void playRollingBack();
00124 void playJumpedStanding();
00125 void playJumpedMoving();
00127 void playFalling() {setFrame(21);}
00129 void playPushedForward() {setAnim(26, 27, ANIMSPEED/2);}
00131 void playPushedBackward() {setAnim(28, 29, ANIMSPEED/2);}
00132 void playClimbingUp();
00133 void playClimbingDown();
00134 void playVictory();
00135
00137 void playInvis() {setFrame(66);}
00138 void playSkulled();
00139 void playDisintegrated();
00140
00141 void playWarpEffect();
00142 void playSplashEffect();
00143 void play1000VHitEffect();
00144 void playMineHitEffect();
00145
00146 Weapon* getWeapon() {return currWeapon;}
00147 void setWeapon(Weapon* w) {clearWeapon(); currWeapon = w;}
00148
00155 void setInputInterrupt(u8 frames) {inputInterrupt = frames; forceAnimUpdate = true;}
00157 void updateAnimation() {forceAnimUpdate = true;}
00158
00160 void weaponDestroyed() { if (!weaponJustCleared) weaponChange(); currWeapon = NULL;}
00161
00162 void clearWeapon();
00163
00164 void weaponChange();
00165
00170 bool isCrouched() {return (bCrouching || bRolling);}
00175 bool isOnRope() {return bClimbingRope;}
00176
00182 bool justTouchingRope() {return wasTouchingRope != NULL;}
00183
00185 gameManager* gm;
00186
00188 static const u16 WALKSPEED = 256;
00190 static const u16 CLIMBSPEED = 256;
00192 static const short JUMPIMPULSE = -640;
00194 static const s16 POWERHITSPEED = 2048;
00195
00200 virtual void setPallete(u8 id) {defaultPalleteID = id; palleteID = id;}
00202 u8 defaultPalleteID;
00203
00204
00205 void handleNetted(bool upPressed);
00206 void startNetted();
00207 void stopNetted();
00212 bool isNetted() {return nettedStrength > 0;}
00213
00214
00215 bool has1000V();
00216 bool usingChut();
00217 bool hasShield();
00218 bool hasBoomerang();
00219 bool usingMagnet();
00220 bool usingInvis();
00221
00227 enum collisionState {
00228 CS_NONE, CS_BASICHIT, CS_INVISPLAYER, CS_TNTFALL, CS_GRENFALL,
00229 CS_WARPEDPLAYER, CS_SHIELDPLAYER, CS_BOOMERANG
00230 };
00232 collisionState lastCollision;
00233
00234
00235 void groundDeleted(collisionState newCollState = CS_NONE);
00236
00238 void justWarped() {bJustUnwarped = true;}
00239 protected:
00240 static const s8 standingBounds[];
00241 static const s8 fallingBounds[];
00242 static const s8 crouchingBounds[];
00243
00245 s8 playerNum;
00246
00248 bool bCrouching;
00250 bool bRolling;
00252 bool bUnstable;
00254 bool justJumped;
00255
00257 bool bIgnoreInput;
00258
00259 s16 startx, starty;
00260 bool startFlipped;
00261
00263 Rope* touchingRope;
00265 Rope* wasTouchingRope;
00267 bool bClimbingRope;
00268
00270 Weapon* currWeapon;
00271
00272
00274 u8 inputInterrupt;
00276 bool forceAnimUpdate;
00277
00279 u32 lastWeaponChangeTime;
00281 bool weaponJustCleared;
00282
00283
00285 u8 nettedStrength;
00287 bool bJustUnwarped;
00288
00290 static const s8 NETJUMPIMPULSE = -100;
00292 static const s8 NETSPINSPEED = -20;
00294 static const u8 NETROLLDECEL = 2;
00295
00296 };
00297
00298 #endif