// TODO: Implement manual hud scale control in mod loader to fix this
static void __cdecl Indicator_Display(ObjectMaster* _this)
{
	if (!*(bool*)_this->UnknownB_ptr)
		return;

	njSetTexture(&multicommon_TEXLIST);
	njSetTextureNum(arrow);

	njColorBlendingMode(NJD_SOURCE_COLOR, NJD_COLOR_BLENDING_SRCALPHA);
	njColorBlendingMode(NJD_DESTINATION_COLOR, NJD_COLOR_BLENDING_INVSRCALPHA);

	for (Uint32 i = 0; i < 4; i++)
		DrawElement(i, arrow);

	for (Uint32 i = 0; i < 4; i++)
	{
		TextureIndex index = IsControllerEnabled((Uint8)i) ? p : cpu_1;
		njSetTextureNum(index);
		DrawElement(i, index);
	}

	for (Uint8 i = 0; i < 4; i++)
	{
		TextureIndex index = IsControllerEnabled(i) ? (TextureIndex)(p1 + i) : cpu_2;
		njSetTextureNum(index);
		DrawElement(i, index);
	}
}
static void DrawElement(Uint32 playerIndex, Uint32 textureIndex)
{
	EntityData1* player = CharObj1Ptrs[playerIndex];

	if (player == nullptr)
		return;

	Uint8 charid = MetalSonicFlag && player->CharID == Characters_Sonic ? Characters_MetalSonic : player->CharID;
	NJS_SPRITE* sp = &sprites[playerIndex];
	NJS_POINT2 projected;
	NJS_VECTOR pos = player->Position;
	pos.y += PhysicsArray[charid].CollisionSize;

	njProjectScreen(nullptr, &pos, &projected);

	sp->p = { projected.x, projected.y - (sp->tanim[0].sy + sp->tanim[1].sy), 0.0f };

	bool isVisible =
		sp->p.x < MARGIN_RIGHT &&
		sp->p.x > MARGIN_LEFT &&
		sp->p.y < MARGIN_BOTTOM &&
		sp->p.y > MARGIN_TOP;

	ClampToScreen(sp->p);
	int flags = NJD_SPRITE_COLOR | NJD_SPRITE_ALPHA;
	sp->ang = 0;

	if (textureIndex == arrow)
	{
		if (!isVisible)
		{
			flags |= NJD_SPRITE_ANGLE;
			sp->ang = NJM_RAD_ANG(GetAngle((NJS_POINT2*)&sp->p, &projected)) - 0x4000;
		}

		// TODO: Ellipse rotation around player number
		sp->tanim[arrow].cy = Indicator_TEXANIM[arrow].cy - ((isVisible) ? 0 : 12);
	}
	
	SetSpriteColor(IsControllerEnabled((Uint8)playerIndex) ? &colors[charid] : &colors[9]);
	Draw2DSprite(sp, textureIndex, -1.0f, flags, 0);
}
Exemple #3
0
static void __cdecl SuperSonicManager_Main(ObjectMaster* _this)
{
	if (super_count < 1)
	{
		DeleteObject_(_this);
		return;
	}

	if (CurrentSong != -1 && (CurrentLevel != last_level || CurrentAct != last_act))
		SetMusic();

	// HACK: Result screen disables P1 control. There's probably a nicer way to do this, we just need to find it.
	if (IsControllerEnabled(0))
	{
		++ring_timer %= 60;

		if (!ring_timer)
			AddRings(-1);
	}
}