示例#1
0
void BOSSbase::move(float dt)
{
	HGE *hge = hgeCreate(HGE_VERSION);
	if (move_delay == 0)
	{
		target_y = hge->Random_Int(70, SCREEN_HEIGHT - 20);
		target_x = hge->Random_Int(12, SCREEN_WIDTH - 15);
		move_delay = hge->Random_Int(100, 500);//1s~5s切换移动方向
	}
	else
	{
		move_delay--;
		BALLbase::move(target_x, target_y, dt);
	}
	if (HP >= max)
	{
		HP = max;
		masure = true;
	}
	if(HP<max)masure = false;

	float add = HP / (float)max;
	if (alive && HP>0)
	{
		scale = 0.1 + 0.9*add;
		damage = 5 + 0.01*HP;
	}
}
示例#2
0
void MUTI_SKILL_MANAGER::BornWithNumber(int number,float x,float y,float angle,int speed,bool lianfa, bool foe1,int damage1)
{
	HGE *hge = hgeCreate(HGE_VERSION);
	SKILL->born(0, 0, 0, 0);
	if (lianfa)
	{
		SKILL->setCD(5);
		lianfale = true;
	}
	else lianfale = false;
	if (number > 1)
	{
		BASE_ARROW *arrow = new BASE_ARROW[number];
		for (int i = 0; i < number; i++)
		{
			arrow[i].Init(x, y, angle-(i-0.5*number)*0.314, speed, foe1,damage1);// need test
			arrows.push_back(arrow[i]);
		}
		arrow_count += number;
	}
	else
	{
		BASE_ARROW *arrow = new BASE_ARROW;
			arrow->Init(x, y, angle, speed,foe1,damage1);
			arrows.push_back(*arrow);
		arrow_count += 1;
	}
	hge->Effect_Play(SKILL->sound);
	arrows.shrink_to_fit();
	//arrows.resize(arrow_count);
}
示例#3
0
文件: hgegui.cpp 项目: FrostHand/TiGa
	void Object::callRender(const hgeRect & clipRect)
	{
		if(!visible)
			return;
		if( layoutChanged )
			updateLayout();
		HGE * hge = getHGE();
		
		hgeRect clip = hgeRect::Intersect(getRect(),clipRect);
		// if avialable area is zero - return
		if(clip.IsClean())
			return;
		// craw self
		const bool uiDebug = false;
		// draw children
		if( clipChildren )
			hge->Gfx_SetClipping(clip.x1, clip.y1, clip.x2 - clip.x1, clip.y2 - clip.y1);
		if(uiDebug)
			drawRect(hge, getRect(), ARGB(255,64,255,64));
		onRender();
		// turn off clipping
		if( clipChildren )
			hge->Gfx_SetClipping();
				
		//clip = hgeRect::Intersect(getClientRect(),clipRect);
		// render children
		for(Children::iterator it = children.begin(); it != children.end(); ++it)
		{
			Object * object = it->get();
			if(object)
				object->callRender(clip);
		}		
	}
示例#4
0
int CTextAction::execute( CGameState * )
{
	HGE *hge = hgeCreate(HGE_VERSION);
	float dt = hge->Timer_GetDelta();
	int ret = m_textbox->Update(dt);
	//DebugMsg("textbox ret: %d\n", ret);
	bool lbtndown = hge->Input_KeyDown(HGEK_LBUTTON);
	bool spacedown = hge->Input_KeyDown(HGEK_SPACE);

	if (ret > 0)
	{
		if (m_showText && lbtndown)
		{
			return m_textbox->GetID();
		}
		if (spacedown)
		{
			m_showText = !m_showText;
			m_textbox->Show(m_showText);
		}
	}
	else
	{
		if (lbtndown)
		{
			//m_textbox->SpeedUpLine();
			m_textbox->SpeedUpAll();
		}
	}
	hge->Release();
	return 0;
}
示例#5
0
void Robot::UseSkill()
{
	if (!startattack)
	{
		HGE *hge = hgeCreate(HGE_VERSION);
		float x, y;
		hge->Input_GetMousePos(&x, &y);
		backx = GetX();
		backy = GetY();
		switch (coretype)
		{
			//攻击型
			//开始攻击
		case Attack:
			if (x<ACT_START_X || x>ACT_END_X || y<ACT_START_Y || y>ACT_END_Y)
			{
				if (!tremble)
					tremble = 20;
				return;
			}
			else
			{
				SetCollisionRange(40);
				SetPos(x, y);
			}
			break;
			//触发技能型
			//跟hero做intercation将自身赋给hero然后自杀
		case Magic:
			break;
			//BUFF型
			//施放技能 
		case Buff:
		{
					 int count = 0;
					 Hero *a = dynamic_cast<Hero*>(ObjectPool::GetObjPool().GetOurHero(GetType()));
					 for (int i = 0; i < STD_CORES; i++)
					 {
						 Robot *b = dynamic_cast<Robot*>(a->GetCOREs(i));
						 if (b && b->IsActive())
						 {
							 if (b->GetInnerCode() == GetInnerCode())
							 {
								 b->Suicide();
								 a->Interaction(b);
							 }
							 else
							 if (b->GetCoreType() == Buff)
								 count++;
						 }

					 }
					 SetSpeed(1500);
					 SetAim(25 + count * 50, 175);
		}
			break;
		}
		startattack = true;
	}
}
void Projectile::Init(Ship* owner, PROJECTILE_TYPE type, float x, float y, float w, bool active)
{
	GameObject::Init(x, y, w, active);
	this->type = type;
	this->owner = owner;

	HGE* hge = hgeCreate(HGE_VERSION);

	switch (type)
	{
	case PROJ_BULLET:
		{
			tex = hge->Texture_Load("missile.png");
			sprite.reset(new hgeSprite(tex, 0, 0, 40, 20));
			sprite.get()->SetHotSpot(20, 10);
		}
		break;
	case PROJ_SEEKING_MISSLE:
		{
			tex = hge->Texture_Load("missile.png");
			sprite.reset(new hgeSprite(tex, 0, 0, 40, 20));
			sprite.get()->SetHotSpot(20, 10);
		}
		break;
	}

	hge->Release();
}
示例#7
0
void AnimObject::Render()
{
	if (anim)
	{
		HGE *hge = hgeCreate(HGE_VERSION);
		if (!anim->IsPlaying())
			anim->Play();
		if (anim->GetFrame() < anim->GetFrames() - 1)
		{
			if (anim->GetFrame()>0)alreadyplayed = true;
			anim->RenderEx(imgx, imgy, angle, size, size);
			anim->Update(hge->Timer_GetDelta());
		}
		else
		{
			dead = true;
			SAFE_DELETE(anim);
		}
		if (!dead && alreadyplayed && anim->GetFrame() == 0)
		{
			dead = true;
			SAFE_DELETE(anim);
		}
	}
}
示例#8
0
MUTI_POOL::MUTI_POOL(const char *flie,int nframes, float w, float h, float centerx, float centery)
{
	HGE *hge = hgeCreate(HGE_VERSION);
	HTEXTURE pic = hge->Texture_Load(flie);
	boom = new hgeAnimation(pic, nframes, 30, 0, 0, w, h);
	boom->SetZ(SKILL_LAYER);
	boom->SetHotSpot(centerx, centery);
}
示例#9
0
void TKShellMenu::Render()
{
    _hge->Gfx_BeginScene();
    _bg->Render(0,0);
    _font->SetColor(0xFFFFFFFF);
    hgeGUI::Render();
    _hge->Gfx_EndScene();
}
示例#10
0
文件: Game.cpp 项目: doveiya/isilme
bool	HGEGame::FrameFunction()
{
	HGE* hge = ((HGEGame*)mInstance)->mHGE;
	float elapsedTime = hge->Timer_GetDelta();
	bool result = mInstance->GetStateManager()->Update(elapsedTime);
	mInstance->GetScheduler()->Update(elapsedTime);
	return result;
}
示例#11
0
void TKShellMenu::Show(bool show)
{
    static HCHANNEL h;
    if(show)
    {
        h = _hge->Effect_PlayEx(_hBgMusic, 100, 0, 1.0f, true);
    }
    else
    {
        _hge->Channel_Stop(h);
    }
}
示例#12
0
void BOSSbase::absorb(BLUEBALL &ball)
{
	if (masure == false)
	{
		HGE *hge = hgeCreate(HGE_VERSION);
		ball.dehealth = hge->Random_Int(min_sorb, max_sorb);
		ball.font = true;
		int copy = ball.HP;
		ball.HP -= ball.dehealth;
		if (ball.HP < 0)HP += copy;
		else HP += ball.dehealth;
	}
}
示例#13
0
void StaticMapObj::CollisionEntity::onCollision(iCollisionEntity &o, const iContactInfo &ci)
{
    HGE *hge = hgeCreate(HGE_VERSION);
    float deltaTime = hge->Timer_GetDelta();
    hge->Release();
    
    TankContactInfo &tci = (TankContactInfo &)ci;
    Point2f contactPos = tci.getData()->GetContact(0);
    Point2f dir = o.getBody().GetPointVelocity(contactPos, deltaTime);
    Point2f impulse = dir * 0.001f;// * o.getBody().getMass();
    Point2f force = impulse / deltaTime;
    getBody().AddForce(force, contactPos);
}
示例#14
0
HGE *HGEInit()
{
	HGE *h = hgeCreate(HGE_VERSION);
	h->System_SetState(HGE_SCREENWIDTH, WWID);
	h->System_SetState(HGE_SCREENHEIGHT, WHEI);
	h->System_SetState(HGE_FRAMEFUNC, FrameFunc0);
	h->System_SetState(HGE_RENDERFUNC, RenderFunc0);
	h->System_SetState(HGE_WINDOWED, true);
	h->System_SetState(HGE_USESOUND, false);
	h->System_SetState(HGE_HIDEMOUSE, false);
	h->System_SetState(HGE_TITLE, "HGE BWChess - Dates Call Back");
	h->System_SetState(HGE_SHOWSPLASH, false);
	return h;
}
示例#15
0
bool UIWindow::IsOnControl()
{
	if (m_bShow && m_pBackGround)
	{
		float x,y;
		HGE* hge = hgeCreate(HGE_VERSION);
		hge->Input_GetMousePos(&x,&y);
		if (x>=m_fPosX && x<=(m_fPosX+m_pBackGround->GetWidth()) && y>=m_fPosY && y<=(m_fPosY+m_pBackGround->GetHeight()))
			return true;

		hge->Release();
	}
	return false;
}
示例#16
0
AnimObject::AnimObject(const char *name, int nframes, int fps, float w, float h, float centerx, float centery, int aID,bool infinite, float x1, float y1)
{
	HGE* hge = hgeCreate(HGE_VERSION);
	tex = hge->Texture_Load(name);
	anim = new hgeAnimation(tex, nframes, fps, 0, 0, w, h);
	anim->SetHotSpot(centerx, centery);
	ID = aID;
	imgx = x1;
	imgy = y1;
	dead = false;
	angle = 0.0f;
	size = 1.0f;
	Isinfinite = infinite;
}
示例#17
0
HPBAR::HPBAR(const char* hp_tex, const char* shield_tex, const char* delay_tex)
{
	HGE *hge = hgeCreate(HGE_VERSION);
	tex1 = hge->Texture_Load(hp_tex);
	tex2 = hge->Texture_Load(shield_tex);
	tex3 = hge->Texture_Load(delay_tex);
	spr1 = new hgeSprite(tex1, 0, 0, 100, 17);
	spr2 = new hgeSprite(tex2, 0, 0, 100, 17);
	spr3 = new hgeSprite(tex3, 0, 0, 100, 17);
	spr3->SetColor(ARGB(255, 255, 0, 0));
	spr1->SetColor(ARGB(255, 0, 255, 0));
	spr2->SetColor(ARGB(255, 200, 200, 200));
	font = new hgeFont("font1.fnt");
	font->SetZ(SKILL_LAYER);
	font->SetScale(0.75);

}
示例#18
0
Ship* Missile::Update(std::vector<Ship*> &shiplist, float timedelta)
{
	HGE* hge = hgeCreate(HGE_VERSION);
	float pi = 3.141592654f*2;
	float oldx, oldy;

	w_ += angular_velocity * timedelta;
	if (w_ > pi)
		w_ -= pi;

	if (w_ < 0.0f)
		w_ += pi;

	oldx = x_;
	oldy = y_;
	x_ += velocity_x_ * timedelta;
	y_ += velocity_y_ * timedelta;

	for (std::vector<Ship*>::iterator thisship = shiplist.begin();
		thisship != shiplist.end(); thisship++)
	{
		if( HasCollided( (*(*thisship)) ) )
		{
			return (*thisship);
		}
	}

	
	float screenwidth = static_cast<float>(hge->System_GetState(HGE_SCREENWIDTH));
	float screenheight = static_cast<float>(hge->System_GetState(HGE_SCREENHEIGHT));
	float spritewidth = sprite_->GetWidth();
	float spriteheight = sprite_->GetHeight();
	if (x_ < -spritewidth/2)
		x_ += screenwidth + spritewidth;
	else if (x_ > screenwidth + spritewidth/2)
		x_ -= screenwidth + spritewidth;

	if (y_ < -spriteheight/2)
		y_ += screenheight + spriteheight;
	else if (y_ > screenheight + spriteheight/2)
		y_ -= screenheight + spriteheight;

	return nullptr;
}
示例#19
0
void MUTI_POOL::render()
{
	HGE *hge = hgeCreate(HGE_VERSION);
	float dt = hge->Timer_GetDelta();
	for (int i = 0; i < pool.size(); i++)
	{
		pool[i].anim->Update(dt);
		pool[i].anim->RenderEx(pool[i].GetX(), pool[i].GetY(), 0, pool[i].GetSize(), pool[i].GetSize());
		pool[i].lifespan--;
		if (pool[i].lifespan <= 0)
		{
			delete pool.cbegin()->anim;
			pool.erase(pool.cbegin());
		}

	}


}
示例#20
0
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    HGE* hge = hgeCreate(HGE_VERSION);
    try
    {
        hge::init();
        action::init();
        hge::run();
        action::halt();
        hge::halt();
    }
    // Catch all Guichan exceptions.
    catch (gcn::Exception e)
    {
        MessageBox(NULL,  
                   e.getMessage().c_str(),
                   "Guichan exception",
                   MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
        return 1;
    }
    // Catch all Std exceptions.
    catch (std::exception e)
    {
        MessageBox(NULL, 
                   e.what(),
                   "Std exception",
                   MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
        return 1;
    }
    // Catch all unknown exceptions.
    catch (...)
    {
       MessageBox(NULL, 
                  hge->System_GetErrorMessage(), 
                  "Unknown exception", 
                  MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
        return 1;
    }

    return 0;
}
示例#21
0
void Bullet::render(int time)
{
    HGE *hge = hgeCreate(HGE_VERSION);
    hgeVector dir = target - pos;
    hgeVector up(0, -1);
    if (dir.Length() < 0.5f)
    {
        dir = up;
    }
    else
    {
        dir.Normalize();
    }
    float angle = dir.Angle(&up);
    if (dir.x > 0)
        angle = -angle;
    hge->Gfx_SetTransform(0, 0, pos.x, pos.y, angle, 1, 1);
    anim->render(time, 0);

    hge->Release();
}
示例#22
0
void MUTI_SKILL_MANAGER::Render_Alive()
{
	HGE* hge = hgeCreate(HGE_VERSION);
	
	for (int i = 0; i != arrows.size(); ++i)
	{
		
		
		if (arrows[i].alive == false)
		{
			if (arrows[i].boomed == false)
			{
				MUTIBOOM *boomfish = new MUTIBOOM(boom, arrows[i].x, arrows[i].y, arrows[i].delta);
				boomfish->Play();
				boom_pool.push_back(*boomfish);
				delete boomfish;
				boomfish = NULL;
				arrows[i].boomed = true;
				hge->Effect_Play(effect);
			}
		}
		else
			SKILL->render(arrows[i].x, arrows[i].y, arrows[i].angle);
	}

	for (int i = 0; i < boom_pool.size(); ++i)
	{
	
		   boom_pool[i].anim->RenderEx(boom_pool[i].GetX(), boom_pool[i].GetY(), 0, boom_pool[i].GetSize(), boom_pool[i].GetSize());
		if (boom_pool[i].lifespan<=0)
		{
			delete boom_pool.cbegin()->anim;
			boom_pool.erase(boom_pool.cbegin());
		}
	}
	boom_pool.shrink_to_fit();



}
示例#23
0
Missile::Missile(char* filename, float x, float y, float w, int shipid, int _damage)
	: angular_velocity(0)
	, deleted(0)
	, damage(_damage)
{
	HGE* hge = hgeCreate(HGE_VERSION);
	tex_ = hge->Texture_Load(filename);
	hge->Release();
	sprite_.reset(new hgeSprite(tex_, 0, 0, 40, 20));
	sprite_->SetHotSpot(20,10);
	x_ = x;
	y_ = y;
	w_ = w;
	ownerid = shipid;

	velocity_x_ = 200.0f * cosf(w_);
	velocity_y_ = 200.0f * sinf(w_); 

	x_ += velocity_x_ * 0.5;
	y_ += velocity_y_ * 0.5;

}
示例#24
0
void ObjectPool::SetBWbools(const char* filename, int NumOfObject)
{
	HGE *hge = hgeCreate(HGE_VERSION);
	HTEXTURE pic = hge->Texture_Load(filename);
	int width = hge->Texture_GetWidth(pic);
	int height = hge->Texture_GetHeight(pic);
	BWpic bwpic;
	bwpic.width = width;
	bwpic.height = height;
	bwpic.bools = (bool**)malloc(sizeof(bool*)*width);
	for (int i = 0; i < width; i++)
		bwpic.bools[i] = (bool*)malloc(sizeof(bool)*height);
	DWORD *color = hge->Texture_Lock(pic);
	for (int i = 0; i < width; i++)
	for (int j = 0; j < height;j++)	
	if (GETR(color[j*width + i]) == 0 && GETG(color[j*width + i]) == 0 && GETB(color[j*width + i]) == 0)
		bwpic.bools[j][i] = true;
	else bwpic.bools[j][i] = false;
	bwpic.number = NumOfObject;
	hge->Texture_Unlock(pic);
	hge->Texture_Free(pic);
	BWpics.push_back(bwpic);
	BWpics.shrink_to_fit();
}
示例#25
0
BuffManager::BuffManager()
{
	HGE *hge = hgeCreate(HGE_VERSION);
	HTEXTURE f = hge->Texture_Load("freeze.png");
	HTEXTURE v = hge->Texture_Load("vertigo.png");
	HTEXTURE t = hge->Texture_Load("toxic.png");
	HTEXTURE m = hge->Texture_Load("MPrecover.png");
	HTEXTURE e = hge->Texture_Load("extraattack.png");
	toxicdebuff = new hgeSprite(t, 0, 0, BUFFSIZE, BUFFSIZE);
	vertigodebuff = new hgeSprite(v, 0, 0, BUFFSIZE, BUFFSIZE);
	freezedebuff = new hgeSprite(f, 0, 0, BUFFSIZE, BUFFSIZE);
	mprecover = new hgeSprite(m, 0, 0, BUFFSIZE, BUFFSIZE);
	extraattack = new hgeSprite(e, 0, 0, BUFFSIZE, BUFFSIZE);
	extraattack->SetHotSpot(1, 1);
	mprecover->SetHotSpot(1, 1);
	toxicdebuff->SetHotSpot(1, 1);
	vertigodebuff->SetHotSpot(1, 1);
	freezedebuff->SetHotSpot(1, 1);
	font = new hgeFont("font.fnt");
	m_bHasInitialized = true;
}
示例#26
0
void Ant::render(int time)
{
    time;

    HGE* hge = hgeCreate(HGE_VERSION);
    hge->Gfx_SetTransform(0, 0, (float)(int) this->pos.x, (float)(int) this->pos.y, -this->angle, 1, 1);
	this->anim->render((int) this->moveMeter, 0);
	if (this->carryCake)
	{
		this->cakeAnim->render(time, 0);
	}
    hge->Gfx_SetTransform(0, 0, (float)(int) this->pos.x, (float)(int) this->pos.y, 0, 1, 1);
    this->hpAnim->render(int(100.0f * this->hp / this->getMaxHp()), 0);
    hge->Gfx_SetTransform();
    float alpha = (dest - pos).Length() / 50;
    DWORD color = int(255 * alpha);
    if (color > 255)
        color = 255;
    color = color << 24 | 0xffffff;
    hge->Gfx_RenderLine(this->pos.x, this->pos.y, this->dest.x, this->dest.y, color);
	
    hge->Release();
}
示例#27
0
文件: Button.cpp 项目: Hiseen/HGE1
void Button::action()
{
	if (countdelay != 50)
		countdelay++;
	else
		SetDelayrender(false);
	if (!IsDelayrender())
	{
		HGE *hge = hgeCreate(HGE_VERSION);
		float mousex, mousey;
		hge->Input_GetMousePos(&mousex, &mousey);
		if (countalpha<255)
		{
			countalpha += 5;
			SetChangeColor(countalpha, 0, 0, 0);
		}
		else
			SetChangeColor(255, 0, 0, 0);
		if (state != MouseDown)
		if (mousex > GetX() && mousex<GetX() + width && mousey>GetY() && mousey < GetY() + height)
		{
			state = MouseOver;
			if (!playsound)
			{
				playsound = true;
				SFXManager::GetSFXManager().PlaySFX(BUTTONSFX);
			}
			if (state == MouseOver && hge->Input_KeyDown(HGEK_LBUTTON))
			{
				state = MouseDown;
				SFXManager::GetSFXManager().PlaySFX(BUTTONSFX2);
			}
		}
		else
		{
			state = MouseOff;
			playsound = false;
		}
		if (state == MouseDown)
		{
			if (!finishchangecolor)
			{
				if (!colorreverse)
					count += 50;
				else
					count -= 50;
				if (count == 250)
					colorreverse = true;
				SetChangeColor(count + 5, 255, 255, 255);
				if (count == 0 && colorreverse)
				{
					finishchangecolor = true;
					SetChangeColor(255, 0, 0, 0);
					finishmove = false;
				}
			}
			else
			{
				switch (buttonnum)
				{
				case BUTTON_1_OFF:
					if (!flag)
					{
						SceneManager::GetSceneManager().SetMenuStage(1);
						flag = true;
					}
					if (!finishmove && ObjectPool::GetObjPool().ChangeAllPos(Left, 853))
					{
						finishmove = true;
						flag = false;
						state = MouseOff;
						finishchangecolor = false;
						buttondown = false;
						colorreverse = false;
					}
					break;
				case BUTTON_2_OFF:
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					break;
				case BUTTON_3_OFF:
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					break;
				case BUTTON_4_OFF:
					SceneManager::GetSceneManager().ExitGame();
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					break;
				case BUTTON_5_OFF:
						if (!flag && SceneManager::GetSceneManager().ReturnMenuStage() == 2)
						{
							SceneManager::GetSceneManager().SetMenuStage(0);
							flag = true;
						}
						if (!finishmove &&SceneManager::GetSceneManager().ReturnMenuStage() == 0 && ObjectPool::GetObjPool().ChangeAllPos(Right, 853))
						{
							flag = false;
							finishmove = true;
							state = MouseOff;
							finishchangecolor = false;
							buttondown = false;
							colorreverse = false;
						}
					break;
				case BUTTON_6_OFF:
						if (!flag&&SceneManager::GetSceneManager().ReturnMenuStage() == 2)
						{
							SceneManager::GetSceneManager().SetMenuStage(4);
							flag = true;
						}
						if (!finishmove&&SceneManager::GetSceneManager().ReturnMenuStage()==4 && ObjectPool::GetObjPool().ChangeAllPos(Left, 853))
						{
							flag = false;
							finishmove = true;
							state = MouseOff;
							finishchangecolor = false;
							buttondown = false;
							colorreverse = false;
						}
					break;
				case BUTTON_7_OFF:
					if (!flag && SceneManager::GetSceneManager().ReturnMenuStage() == 2)
					{
						SceneManager::GetSceneManager().SetMenuStage(3);
						flag = true;
					}
					if (!finishmove &&SceneManager::GetSceneManager().ReturnMenuStage()==3 && ObjectPool::GetObjPool().ChangeAllPos(Left, 853))
					{
						flag = false;
						finishmove = true;
						state = MouseOff;
						finishchangecolor = false;
						buttondown = false;
						colorreverse = false;
					}
					break;
				case BUTTON_8_OFF:
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					break;
				case BUTTON_9_OFF:
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					break;
				case BUTTON_10_OFF:
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					break;
				case BUTTON_11_OFF:
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					break;
				case BUTTON_12_OFF:
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					SceneManager::GetSceneManager().GoToOneScene(GameScene, false, true);
					break;
				case BUTTON_13_OFF:
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					SceneManager::GetSceneManager().GoToOneScene(GameScene);
					break;
				case BUTTON_14_OFF:
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					SceneManager::GetSceneManager().GoToOneScene(MenuScene);
					break;
				case BUTTON_15_OFF:
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					break;
				case BUTTON_16_OFF:
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					break;
				case BUTTON_17_OFF:
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					if (Hero::GetHero().AddStats(ADD_ATK))
						SceneManager::GetSceneManager().GoToOneScene(GameScene, false, true);
					break;
				case BUTTON_18_OFF:
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					if (Hero::GetHero().AddStats(ADD_DEX))
						SceneManager::GetSceneManager().GoToOneScene(GameScene, false, true);
					break;
				case BUTTON_19_OFF:
					state = MouseOff;
					finishchangecolor = false;
					buttondown = false;
					colorreverse = false;
					if (Hero::GetHero().AddStats(ADD_INT))
						SceneManager::GetSceneManager().GoToOneScene(GameScene, false, true);
					break;
				}
			}
		}

	}
}
示例#28
0
Missile::~Missile()
{
	HGE* hge = hgeCreate(HGE_VERSION);
	hge->Texture_Free(tex_);
	hge->Release();
}
示例#29
0
void RenderQueue::flush()
{
    HGE *hge = hgeCreate(HGE_VERSION);
    const Point2f viewerPos = getViewerPos();
    const Rectf viewRange = getWindowViewer();
    const Rectf windowRange(0, getWindowSize().x, 0, getWindowSize().y);


    //Rect clip;
    //clip.leftTop = Point2s(100, 100);
    //clip.rightBottom = Point2s(200, 200);
    hge->Gfx_SetTransform();
    for (int i = MaxLayers - 1; i >= 0; --i)
    {
        vector<GfxObj> &go = gfxobjs[i];
        for (size_t j = 0; j < go.size(); ++j)
        {
            const GfxObj &obj = go[j];
            switch(obj.type)
            {
            case GfxObj::T_Anim:
                {
                    const GfxObj::Data::Anim &anim = obj.data.anim;

                    Point2f pos = gfxParams.getPoint2f(anim.iA);
                    if (!anim.screenPos)
                        pos -= viewerPos;
                    // FIXME: 100 is magic number, remove it by anim clip range
                    if (pos.x > windowRange.rightBottom.x + 100 || pos.x < windowRange.leftTop.x - 100 ||
                        pos.y < windowRange.leftTop.y - 100 || pos.y > windowRange.rightBottom.y + 100)
                        break;
                    //hge->Gfx_SetTransform();
                    hge->Gfx_SetTransform(0, 0, pos.x, pos.y, anim.direction/* - viewerOrientation*/, 1, 1);
                    anim.anim->render(anim.frame, 0);//&clip);
                    hge->Gfx_SetTransform();
                }
                break;
            case GfxObj::T_Line:
                {
                    const GfxObj::Data::Line &line = obj.data.line;

                    const Point2f &posA = gfxParams.getPoint2f(line.iA);
                    const Point2f &posB = gfxParams.getPoint2f(line.iB);
                    Rectf objRange(
                        min(posA.x, posB.x + .1f),
                        max(posA.x, posB.x + .1f),
                        min(posA.y, posB.y + .1f),
                        max(posA.y, posB.y + .1f));
                    if (line.screenPos)
                    {
                        Rectf x = objRange & windowRange;
                        if (x.Visible())
                        {
                            hge->Gfx_RenderLine(posA.x, posA.y,
                                posB.x, posB.y, line.color);
                        }
                    }
                    else
                    {
                        Rectf x = objRange & viewRange;
                        if (x.Visible())
                        {
                            hge->Gfx_RenderLine(posA.x - viewerPos.x, posA.y - viewerPos.y,
                                posB.x - viewerPos.x, posB.y - viewerPos.y, line.color);
                        }
                    }
                }
                break;
            case GfxObj::T_Text:
                {
                    const GfxObj::Data::Text &text = obj.data.text;
                    
                    Point2f posA = gfxParams.getPoint2f(text.iA);
                    if (!text.screenPos)
                    {
                        posA -= viewerPos;
                    }
                    posA = SnapNearestInteger(posA);
                    //text.font->Render(posA.x, posA.y, text.align, gfxParams.getString(text.iStr).c_str());
                    renderFontWithBk(*text.font, posA.x, posA.y, ~text.color & 0x00ffffff | 0x40000000, text.color, text.align, gfxParams.getString(text.iStr).c_str());

                }
                break;
            case GfxObj::T_Triple:
                {
                    const GfxObj::Data::Triple &triple = obj.data.triple;
                    const Point2f &posA = gfxParams.getPoint2f(triple.iA);
                    if (triple.screenPos)
                        hge->Gfx_SetTransform(0, 0, posA.x, posA.y, 0, 1, 1);
                    else
                        hge->Gfx_SetTransform(0, 0, posA.x - viewerPos.x, posA.y - viewerPos.y, 0, 1, 1);

                    hge->Gfx_RenderTriple(&gfxParams.getTriple(triple.iTriple));
                    hge->Gfx_SetTransform();
                }
                break;
            case GfxObj::T_Quad:
                {
                    const GfxObj::Data::Quad &quad = obj.data.quad;
                    hge->Gfx_RenderQuad(&gfxParams.getQuad(quad.iQuad));
                }
                break;
            }
        }
        go.clear();
    }
    hge->Gfx_SetTransform();
    hge->Release();
    gfxParams.clear();
}
示例#30
0
void Robot::Action()
{
	switch (GetType())
	{
	case Left:
		if (!startattack)
		{
			if (!trigger)
			{
				if (coretype != Eternity)
				{
					HGE *hge = hgeCreate(HGE_VERSION);
					float x, y;
					hge->Input_GetMousePos(&x, &y);
					int dis = GetDistance(x, y);
					if (dis < 20)
					{
						if (hge->Input_KeyDown(HGEK_LBUTTON))
						{
							trigger = true;
							backx = GetX();
							backy = GetY();
						}
						else
						{
							if (hge->Input_KeyDown(HGEK_RBUTTON))
								Suicide(true);
						}
					}
				}
			}
			else
			{
				ObjectPool::GetObjPool().LockOnGameObject(this);
				if (runback)
				{
					if (GoToAnotherPos(backx,backy))
					{
						trigger = false;
						runback = false;
						SetSpeed(0);
					}
				}
				else
				{
					HGE *hge = hgeCreate(HGE_VERSION);
					float x, y;
					hge->Input_GetMousePos(&x, &y);
					SetPos(x, y);
					if (hge->Input_KeyUp(HGEK_LBUTTON))
					{
     					if (x<ACT_START_X || x>ACT_END_X || y<ACT_START_Y || y>ACT_END_Y)
						{
							runback = true;
							SetSpeed(1200);
						}
						else
						{
							switch (coretype)
							{
								//攻击型
								//开始攻击
							case Attack:
								SetCollisionRange(40);
								SetSolid(true);
								SetBlock(true);
								break;
								//触发技能型
								//跟hero做intercation将自身赋给hero然后自杀
							case Magic:
								dynamic_cast<Hero*>(ObjectPool::GetObjPool().GetOurHero(GetType()))->SetSkill(GetInnerCode() + 300);
								Suicide();
								break;
								//BUFF型
								//施放技能 
							case Buff:
							{
										 int count = 0;
										 Hero *a = dynamic_cast<Hero*>(ObjectPool::GetObjPool().GetOurHero(GetType()));
										 for (int i = 0; i < STD_CORES; i++)
										 {
											 Robot *b = dynamic_cast<Robot*>(a->GetCOREs(i));
											 if (b && b->IsActive())
											 {
												 if (b->GetInnerCode() == GetInnerCode())
												 {
													 b->Suicide();
													 a->Interaction(b);
												 }
												 else
												 if (b->GetCoreType() == Buff)
													 count++;
											 }

										 }
										 SetSpeed(1500);
										 SetAim(25+count * 50, 175);
							}
								break;
							}
							startattack = true;
						}
					}
				}
			}
		}
		else
		{
			switch (coretype)
			{
			case Attack:
				if (GetAim())
					GetAngle(GetAim());
				if (shootdelay)
					shootdelay--;
				else
				{
					if (!GetAim())
						SetAim(ObjectPool::GetObjPool().GetRandomEnemyUnit(GetType()));
					else
					{
						Skill *skill = new Skill(this, CORESKILL);
						ObjectPool::GetObjPool().InsertObject(skill, true);
					}
					shootdelay = std_shootdelay;
				}
				break;
			case Buff:
				if (GoToAim())
				{
					if (!buffstart)
					{
						ObjectPool::GetObjPool().GetOurHero(GetType())->Interaction(this);
						buffstart = true;
					}
					if (shootdelay)
						shootdelay--;
					else
					{
						Suicide();
						if (host)
							host->Interaction(this);
					}
				}
				break;
			}
			HGE *hge = hgeCreate(HGE_VERSION);
			if (hge->Input_KeyDown(HGEK_RBUTTON))
			{
				float x, y;
				hge->Input_GetMousePos(&x, &y);
				if (GetDistance(backx, backy, x, y) < 20)
				{
					Suicide(true);
				}
			}
		}
		break;
	case None:
		if (!GetSpeed())
		{
			HGE *hge = hgeCreate(HGE_VERSION);
			float x, y;
			hge->Input_GetMousePos(&x, &y);
			int dis = GetDistance(x, y);
			if (dis < 50)
			{
				ObjectPool::GetObjPool().GetEnemyHero(GetType())->Scilence();
				if (dis < 40)
				{
					if (hge->Input_KeyDown(HGEK_LBUTTON))
						ObjectPool::GetObjPool().GetEnemyHero(GetType())->Interaction(this);
					else
					{
						if (hge->Input_KeyDown(HGEK_RBUTTON))
						{
							Suicide(true);
							tremble = 0;
						}
					}
				}
			}
			else
				ObjectPool::GetObjPool().GetEnemyHero(GetType())->UnScilence();
		}
		else
			ObjectPool::GetObjPool().GetEnemyHero(GetType())->UnScilence();
		break;
	}
	if (tremble)
	{
		tremble--;
		int a = tremble / 5;
		int b = tremble % 5;
		if (a % 2)
			SetX(GetX() + (3 - b) * 2);
		else
			SetX(GetX() - (3 - b) * 2);
	}
}