Weasel.hpp
上传用户:zhj2929
上传日期:2022-07-23
资源大小:28772k
文件大小:2k
- #ifndef _WEASEL_HPP
- #define _WEASEL_HPP
- class Weasel: public MoveableObject
- {
- private:
-
- JSprite* mRun;
- JSprite* mDie;
- TileMap* mMap;
- int dead;
- u8 mTileInfo;
-
- public:
- Weasel(GameStatePlay* app);
- virtual ~Weasel();
- virtual void Update(float dt);
- virtual void HitLeft();
- virtual void HitRight(int left, int right, int row);
- void Spawn(int col, int row);
- void die();
- int aLive();
- };
- void Weasel::die()
- {
- mCurrAnimation = mDie;
- dead = 1 ;
- }
- int Weasel::aLive()
- {
- if(dead==0)
- return 1;
- else
- return 0;
- }
- Weasel::Weasel(GameStatePlay* app): MoveableObject(app)
- {
- mMap = mApp->GetTileMap();
- mRun = new JSprite(mTexture, 225,160,80,85);
- mRun->SetHotSpot(0.0f, 80.0f);
- mRun->AddFrame(300,160,80,85);
- mRun->AddFrame(380,160,80,85);
- mRun->SetDuration(200.0f);
- mRun->StartAnimation();
- mDie = new JSprite(mTexture,225,160,80,85);
- mDie->SetHotSpot(0.0f, 77.0f);
-
- mDie->AddFrame(225,251,71,80);
- mDie->AddFrame(330,224,93,100);
- mDie->SetDuration(300.0f);
- mDie->StartAnimation();
- mCurrAnimation = mRun;
- mYRenderOffset = 6.0f;
- mXVelocity = -DEFAULT_WALK_SPEED/2;
- mFlipped = false;
- mHScale = 0.80f;
- mVScale = 0.80f;
- mLeftAdjustment = 23;
- mRightAdjustment = 47;
- mHitLeftAdjustment = 2;
- mHitRightAdjustment = 46;
- mFallLeftAdjustment = -20;
- mFallRightAdjustment = -10;
- mRealHeight = 60;
- dead = 0;
- }
- Weasel::~Weasel()
- {
-
- delete mRun;
- delete mDie;
- }
- void Weasel::Update(float dt)
- {
- if(dead)
- dead++;
- if(dead<350)
- MoveableObject::Update(dt);
- else
- mActive = false;
- }
- void Weasel::Spawn(int col, int row)
- {
- mX = (float)(col<<TILE_SHIFT);
- mY = (float)((row+1)<<TILE_SHIFT) - 1.0f;
- SetActive(true);
- }
- void Weasel::HitLeft()
- {
- mXVelocity = DEFAULT_WALK_SPEED/2;
- mCurrAnimation->SetFlip(true);
- }
- void Weasel::HitRight(int left, int right, int row)
- {
- mXVelocity = -DEFAULT_WALK_SPEED/2;
- mCurrAnimation->SetFlip(false);
- }
- #endif