1 か月前 · Jul 19, 2026 4:17 AM
Render an interactive circular radar in ImGui:
CPP
void DrawRadar(ImVec2 center, float radius, float localYaw, const std::vector<RadarPlayer>& players) {
ImDrawList* dl = ImGui::GetWindowDrawList();
dl->AddCircleFilled(center, radius, IM_COL32(20, 24, 32, 220));
dl->AddCircle(center, radius, IM_COL32(60, 70, 90, 255), 64, 1.5f);
dl->AddCircle(center, radius * 0.5f, IM_COL32(40, 50, 65, 180), 32, 1.0f); // 50m distance ring
// Draw Local Player Arrow
dl->AddTriangleFilled(ImVec2(center.x, center.y - 6), ImVec2(center.x - 4, center.y + 4), ImVec2(center.x + 4, center.y + 4), IM_COL32(0, 255, 255, 255));
for (const auto& p : players) {
Vector2 radarPos = WorldToRadar(localPos, p.pos, localYaw, radius, 0.2f);
dl->AddCircleFilled(ImVec2(center.x + radarPos.x, center.y + radarPos.y), 3.5f, p.isEnemy ? IM_COL32(255, 50, 50, 255) : IM_COL32(50, 255, 50, 255));
}
}