示例#1
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();
}
示例#2
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();
}
示例#3
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();
}