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

📄 badflower.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 _BAD_FLOWER_HPP_
#define _BAD_FLOWER_HPP_

class BadFlower: public GameObject
{
private:
	JSprite* mFlower;
	JTexture* mTexture_2;

	float mUpperLimit;
	float mLowerLimit;
	
		
public:
	BadFlower(GameStatePlay* app);
	virtual ~BadFlower();

	virtual void Update(float dt);
	virtual void Render();

	void Spawn(int col, int row);

};


BadFlower::BadFlower(GameStatePlay* app): GameObject(app)
{
	mTexture_2 = mEngine->LoadTexture("Res/mario_1.png", true);	

	mFlower = new JSprite(mTexture_2, 128, 0, 64, 64);
	mFlower->AddFrame(192,0,64,64);
	mFlower->SetHotSpot(32.0f, 64.0f);
	mFlower->SetDuration(200);
	
	mCurrAnimation = mFlower;
	
	mXVelocity = 0.0f;
	mYVelocity = 0.0f;

}


BadFlower::~BadFlower()
{
	
	delete mFlower;
}


void BadFlower::Update(float dt)
{
	mY += (mYVelocity*dt);

	if (mYVelocity < 0.0f)
	{
		if (mY < mUpperLimit)
		{
			mY = mUpperLimit;
			mYVelocity *= -1;
		}
	}
	else
	{
		if (mY > mLowerLimit)
		{
			mY = mLowerLimit;
			mYVelocity *= -1;
		}
	}

	mCurrAnimation->Update(dt);
}


void BadFlower::Render()
{
	float x, y;
	mMap->GetPosition(&x, &y);

	//mCurrAnimation->SetColor(ARGB((int)mAlpha, 255, 255, 255));
	
	//mCurrAnimation->SetScale(0.8f, 0.8f);
	mCurrAnimation->SetPosition(mX-x, mY-y);

	//mEngine->EnableTextureFilter(false);
	mCurrAnimation->Render();
	//mEngine->EnableTextureFilter(true);
}


void BadFlower::Spawn(int col, int row)
{
	mX = (float)(col<<TILE_SHIFT)+32.0f;
	mY = (float)((row+2)<<TILE_SHIFT);
	
	mLowerLimit = mY;
	mUpperLimit = mY - 96.0f;
	mYVelocity = -(BLOCK_SPEED/4);

	mCurrAnimation->StartAnimation();
	
	SetActive(true);
	
}


#endif


⌨️ 快捷键说明

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