Exemple #1
0
static void DrawThing(DrawBuffer *b, const TTileItem *t, const Vec2i offset)
{
	const Vec2i picPos = Vec2iNew(
		t->x - b->xTop + offset.x, t->y - b->yTop + offset.y);

	if (!Vec2iIsZero(t->ShadowSize))
	{
		DrawShadow(&gGraphicsDevice, picPos, t->ShadowSize);
	}

	if (t->CPicFunc)
	{
		CPicDrawContext c = t->CPicFunc(t->id);
		CPicDraw(b->g, &t->CPic, picPos, &c);
	}
	else if (t->getPicFunc)
	{
		Vec2i picOffset;
		const Pic *pic = t->getPicFunc(t->id, &picOffset);
		Blit(&gGraphicsDevice, pic, Vec2iAdd(picPos, picOffset));
	}
	else if (t->kind == KIND_CHARACTER)
	{
		TActor *a = CArrayGet(&gActors, t->id);
		ActorPics pics = GetCharacterPicsFromActor(a);
		DrawActorPics(&pics, picPos);
		// Draw weapon indicators
		DrawLaserSight(&pics, a, picPos);
	}
	else
	{
		(*(t->drawFunc))(picPos, &t->drawData);
	}

#ifdef DEBUG_DRAW_HITBOXES
	const int pulsePeriod = ConfigGetInt(&gConfig, "Game.FPS");
	int alphaUnscaled =
		(gMission.time % pulsePeriod) * 255 / (pulsePeriod / 2);
	if (alphaUnscaled > 255)
	{
		alphaUnscaled = 255 * 2 - alphaUnscaled;
	}
	color_t color = colorPurple;
	color.a = (Uint8)alphaUnscaled;
	DrawRectangle(
		&gGraphicsDevice, Vec2iMinus(picPos, Vec2iScaleDiv(t->size, 2)),
		t->size, color, DRAW_FLAG_LINE);
#endif
}
Exemple #2
0
static void DrawThing(
	DrawBuffer *b, const Thing *t, const struct vec2i offset)
{
	const struct vec2i picPos = svec2i_add(
		svec2i_subtract(
			svec2i_floor(svec2_add(t->Pos, t->drawShake)),
			svec2i(b->xTop, b->yTop)),
		offset);

	if (!svec2i_is_zero(t->ShadowSize))
	{
		DrawShadow(&gGraphicsDevice, picPos, t->ShadowSize);
	}

	if (t->CPicFunc)
	{
		t->CPicFunc(b->g, t->id, picPos);
	}
	else if (t->kind == KIND_CHARACTER)
	{
		TActor *a = CArrayGet(&gActors, t->id);
		ActorPics pics = GetCharacterPicsFromActor(a);
		DrawActorPics(&pics, picPos, false);
		// Draw weapon indicators
		DrawLaserSight(&pics, a, picPos);
	}
	else
	{
		(*(t->drawFunc))(picPos, &t->drawData);
	}

#ifdef DEBUG_DRAW_HITBOXES
	const int pulsePeriod = ConfigGetInt(&gConfig, "Game.FPS");
	int alphaUnscaled =
		(gMission.time % pulsePeriod) * 255 / (pulsePeriod / 2);
	if (alphaUnscaled > 255)
	{
		alphaUnscaled = 255 * 2 - alphaUnscaled;
	}
	color_t color = colorPurple;
	color.a = (Uint8)alphaUnscaled;
	DrawRectangle(
		&gGraphicsDevice, svec2i_subtract(picPos, svec2i_scale_divide(t->size, 2)),
		t->size, color, DRAW_FLAG_LINE);
#endif
}
Exemple #3
0
static void DrawActorPics(const TTileItem *t, const Vec2i picPos)
{
    const ActorPics pics = t->getActorPicsFunc(t->id);
    if (pics.IsDead)
    {
        if (pics.IsDying)
        {
            int pic = pics.OldPics[0];
            if (pic == 0)
            {
                return;
            }
            if (pics.IsTransparent)
            {
                DrawBTPic(
                    &gGraphicsDevice,
                    PicManagerGetFromOld(&gPicManager, pic),
                    Vec2iAdd(picPos, pics.Pics[0].offset),
                    pics.Tint);
            }
            else
            {
                DrawTTPic(
                    picPos.x + pics.Pics[0].offset.x,
                    picPos.y + pics.Pics[0].offset.y,
                    PicManagerGetOldPic(&gPicManager, pic),
                    pics.Table);
            }
        }
    }
    else if (pics.IsTransparent)
    {
        for (int i = 0; i < 3; i++)
        {
            Pic *oldPic = PicManagerGetFromOld(
                              &gPicManager, pics.OldPics[i]);
            if (oldPic == NULL)
            {
                continue;
            }
            DrawBTPic(
                &gGraphicsDevice,
                oldPic,
                Vec2iAdd(picPos, pics.Pics[i].offset),
                pics.Tint);
        }
    }
    else
    {
        DrawShadow(&gGraphicsDevice, picPos, Vec2iNew(8, 6));
        for (int i = 0; i < 3; i++)
        {
            PicPaletted *oldPic = PicManagerGetOldPic(
                                      &gPicManager, pics.OldPics[i]);
            if (oldPic == NULL)
            {
                continue;
            }
            BlitOld(
                picPos.x + pics.Pics[i].offset.x,
                picPos.y + pics.Pics[i].offset.y,
                oldPic,
                pics.Table, BLIT_TRANSPARENT);
        }

        const TActor *a = CArrayGet(&gActors, t->id);

        // Draw weapon indicators
        if (ConfigGetEnum(&gConfig, "Game.LaserSight") == LASER_SIGHT_ALL ||
                (ConfigGetEnum(&gConfig, "Game.LaserSight") == LASER_SIGHT_PLAYERS && a->PlayerUID >= 0))
        {
            DrawLaserSight(a, picPos);
        }
    }
}