Beispiel #1
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;
}
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();
}
Beispiel #3
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);
}
Beispiel #4
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;
}
Beispiel #5
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();
}
Beispiel #6
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;

}
Beispiel #7
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();
}
Beispiel #8
0
Missile::~Missile()
{
	HGE* hge = hgeCreate(HGE_VERSION);
	hge->Texture_Free(tex_);
	hge->Release();
}
Beispiel #9
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();
}