⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 turtle.hpp

📁 超级玛丽
💻 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 _TURTLE_HPP_
#define _TURTLE_HPP_

class Turtle: 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:
	Turtle(GameStatePlay* app);
	virtual ~Turtle();

	//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 tur;
};


Turtle::Turtle(GameStatePlay* app): MoveableObject(app)
{
	tur = true;

	mTexture_2 = mEngine->LoadTexture("Res/mario_1.png", true);	

	mRun = new JSprite(mTexture_2, 32, 72, 32, 56);
	mRun->SetHotSpot(0.0f, 64.0f);
	mRun->AddFrame(64,72,32,56);
	mRun->SetDuration(200.0f);
	mRun->StartAnimation();

	mDead = new JSprite(mTexture_2, 0,104, 32, 24);
	mDead->SetHotSpot(0.0f, 32.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 = 6.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 = 60;
}


Turtle::~Turtle()
{
	
	delete mRun;
	delete mDead;
//	delete mIdle;
//	delete mDuck;
//	delete mJump;

}


void Turtle::Spawn(int col, int row)
{
	
	mX = (float)(col<<TILE_SHIFT);
	mY = (float)((row+1)<<TILE_SHIFT) - 1.0f;

	SetActive(true);

}

void Turtle::Dead(){
	if(isDead){
		mApp->PlaySfx(SFX_CRUSHED);
		mCurrAnimation = mDead;
		//SetActive(false);
		isDead = false;
		mCurrAnimation->StartAnimation();
		
		
	}
}

void Turtle::HitLeft()
{

	mXVelocity = DEFAULT_WALK_SPEED/2;
	//mFlipped = true;
	mCurrAnimation->SetFlip(true);
}


void Turtle::HitRight()
{

	mXVelocity = -DEFAULT_WALK_SPEED/2;
	//mFlipped = false;
	mCurrAnimation->SetFlip(false);
}

void Turtle::Update(float dt)
{
	
	if(mCurrAnimation==mRun)
		MoveableObject::Update(dt);
	else
	{
		mY += 0.8f;
		
	}
}



#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -