flower.cpp

来自「过程的c++编译器 里面有超级玛丽的源代码 还有一个 管理系统的源代码」· C++ 代码 · 共 58 行

CPP
58
字号
/*********************************************
程序设计:罗穆峰  2008-11-20
http://lmf.biaotian.com
E-mail: lmf@biaotian.com
QQ: 16324942 [模范英雄]
*********************************************/

#include "Flower.h"
#include "图像数据.h"
#include "Game.h"
#include "Mario.h"

CFlower::CFlower(CGame * Game,int x, int y):CObject(Game,5,x,y,16,16,-1)//花位于背景层后(可被砖块遮挡)
{
	m_Game->PlaySound(CSoundMan::FLOWERRISE);
	m_OriPos=y;
	m_VertSpeed=-1;//花刚出现时向上升起
	m_Action=0;
}

const int * CFlower::GetImage(bool * HInv,bool * VInv)
{
	*HInv=false;
	*VInv=false;
	return FlowerImage[m_Action];
}

void CFlower::Clock()
{
	m_Action=!m_Action;//改变当前的动作状态

	if(m_OriPos)
	{
		if(m_OriPos-YPos==16)
		{//已完全升起,则停止上升
			m_OriPos=0;
			m_VertSpeed=0;
		}
	}

	if(m_VertSpeed)
	{//有速度则要移动
		m_Game->Move(this,0,m_VertSpeed);
	}
}

void CFlower::Attack(CObject * Other,int Mode)
{//被玛莉吃掉
	m_Game->PlaySound(CSoundMan::EATFLOWER);
	LiveState=3;
	static_cast<CMario*>(Other)->AddPower();
}

bool CFlower::Block(CObject * Other)
{//不受任何阻挡
	return false;
}

⌨️ 快捷键说明

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