📄 badmush.hpp
字号:
//-------------------------------------------------------------------------------------
//
// This is part of MarioDemo, a platformer demo for JGE++
//
// Copyright (C) 2006 James Hui (a.k.a. Dr.Watson)
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or (at your option) any
// later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program; if not, write to the Free Software Foundation, Inc., 59 Temple
// Place, Suite 330, Boston, MA 02111-1307 USA
//
// Bugs and comments can be forwarded to jhkhui@yahoo.com.
//
//-------------------------------------------------------------------------------------
#ifndef _BADMUSH_HPP_
#define _BADMUSH_HPP_
class BadMush: public MoveableObject
{
private:
// TileMap* mMap;
//
// bool mFlipped;
// bool mJumping;
JSprite* mRun;
JSprite* mDead;
// JSprite* mIdle;
// JSprite* mJump;
// JSprite* mDuck;
JTexture* mTexture_2;
// float mTall;
bool isDead;
u8 mTileInfo;
public:
BadMush(GameStatePlay* app);
virtual ~BadMush();
//virtual void Update(float dt);
//virtual void Render(float xOffset, float yOffset);
virtual void HitLeft();
virtual void HitRight();
virtual void Dead();
virtual void Update(float dt);
void Spawn(int col, int row);
bool mush;
};
BadMush::BadMush(GameStatePlay* app): MoveableObject(app)
{
mush = true;
mTexture_2 = mEngine->LoadTexture("Res/mario_1.png", true);
mRun = new JSprite(mTexture_2, 96, 64, 32, 32);
mRun->SetHotSpot(0.0f, 32.0f);
mRun->AddFrame(96,96,32,32);
mRun->SetDuration(200.0f);
mRun->StartAnimation();
mDead = new JSprite(mTexture_2, 32, 64, 32, 8);
mDead->SetHotSpot(0.0f, 8.0f);
//mRun->AddFrame(288,96,64,64);
mDead->SetDuration(200.0f);
//mRun->StartAnimation();
isDead = true;
mCurrAnimation = mRun;
// mX = 32.0f;
// mY = VIRTUAL_HEIGHT - 64.0f - 1.0f;
mYRenderOffset = 0.0f;
mXVelocity = -DEFAULT_WALK_SPEED/2;
mFlipped = false;
mHScale = 1.0f;
mVScale = 1.0f;
mLeftAdjustment = 23;
mRightAdjustment = 47;
mHitLeftAdjustment = 2;
mHitRightAdjustment = 46;
mFallLeftAdjustment = -20;
mFallRightAdjustment = -10;
mRealHeight = 32;
}
BadMush::~BadMush()
{
delete mRun;
delete mDead;
// delete mIdle;
// delete mDuck;
// delete mJump;
}
void BadMush::Spawn(int col, int row)
{
mX = (float)(col<<TILE_SHIFT);
mY = (float)((row+1)<<TILE_SHIFT) - 1.0f;
SetActive(true);
}
void BadMush::Dead(){
if(isDead){
mApp->PlaySfx(SFX_CRUSHED);
mCurrAnimation = mDead;
//SetActive(false);
isDead = false;
}
}
void BadMush::HitLeft()
{
mXVelocity = DEFAULT_WALK_SPEED/2;
//mFlipped = true;
mCurrAnimation->SetFlip(true);
}
void BadMush::HitRight()
{
mXVelocity = -DEFAULT_WALK_SPEED/2;
//mFlipped = false;
mCurrAnimation->SetFlip(false);
}
void BadMush::Update(float dt)
{
if(mCurrAnimation==mRun)
MoveableObject::Update(dt);
else
mY += 0.8f;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -