Skip to content

Commit

Permalink
Add color-coded, offset-based hit indicators to hit error meter
Browse files Browse the repository at this point in the history
  • Loading branch information
Rian8337 committed Mar 6, 2025
1 parent a347244 commit 4680957
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/com/reco1l/osu/hud/elements/HUDHitErrorMeter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.reco1l.osu.hud.elements
import com.reco1l.andengine.*
import com.reco1l.andengine.shape.Box
import com.reco1l.andengine.shape.RoundedBox
import com.reco1l.framework.ColorARGB
import com.reco1l.framework.Pool
import com.reco1l.osu.hud.HUDElement
import com.reco1l.osu.updateThread
Expand All @@ -16,6 +17,12 @@ class HUDHitErrorMeter : HUDElement() {

private val hitWindow = GlobalManager.getInstance().gameScene.hitWindow

private val greatColor = ColorARGB(70, 180, 220)

private val okColor = ColorARGB(100, 220, 40)

private val mehColor = ColorARGB(200, 180, 110)


init {
setSize(WIDTH, INDICATOR_HEIGHT)
Expand All @@ -25,7 +32,7 @@ class HUDHitErrorMeter : HUDElement() {
origin = Anchor.Center
cornerRadius = BAR_HEIGHT / 2
setSize(WIDTH, BAR_HEIGHT)
setColor(200f / 255f, 180f / 255f, 110f / 255f)
setColor(mehColor.red, mehColor.green, mehColor.blue)

depthInfo = DepthInfo.Default
}
Expand All @@ -34,7 +41,7 @@ class HUDHitErrorMeter : HUDElement() {
anchor = Anchor.Center
origin = Anchor.Center
setSize(WIDTH * (hitWindow.okWindow / hitWindow.mehWindow), BAR_HEIGHT)
setColor(100f / 255f, 220f / 255f, 40f / 255f)
setColor(okColor.red, okColor.green, okColor.blue)

depthInfo = DepthInfo.Default
}
Expand All @@ -43,7 +50,7 @@ class HUDHitErrorMeter : HUDElement() {
anchor = Anchor.Center
origin = Anchor.Center
setSize(WIDTH * (hitWindow.greatWindow / hitWindow.mehWindow), BAR_HEIGHT)
setColor(70f / 255f, 180f / 255f, 220f / 255f)
setColor(greatColor.red, greatColor.green, greatColor.blue)

depthInfo = DepthInfo.Clear
}
Expand All @@ -67,15 +74,27 @@ class HUDHitErrorMeter : HUDElement() {

override fun onAccuracyRegister(accuracy: Float) {

if (abs(accuracy * 1000) > hitWindow.mehWindow) {
val accuracyMs = accuracy * 1000

if (abs(accuracyMs) > hitWindow.mehWindow) {
return
}

val indicator = expiredIndicators.obtain()

indicator.x = (WIDTH / 2f) * (accuracy * 1000 / hitWindow.mehWindow)
indicator.x = (WIDTH / 2f) * (accuracyMs / hitWindow.mehWindow)
indicator.alpha = 0.6f

when {
abs(accuracyMs) <= hitWindow.greatWindow ->
indicator.setColor(greatColor.red, greatColor.green, greatColor.blue)

abs(accuracyMs) <= hitWindow.okWindow ->
indicator.setColor(okColor.red, okColor.green, okColor.blue)

else -> indicator.setColor(mehColor.red, mehColor.green, mehColor.blue)
}

if (indicator.parent == null) {
attachChild(indicator)
}
Expand All @@ -87,7 +106,6 @@ class HUDHitErrorMeter : HUDElement() {
init {
anchor = Anchor.Center
origin = Anchor.Center
setColor(70f / 255f, 180f / 255f, 220f / 255f)
setSize(INDICATOR_WIDTH, INDICATOR_HEIGHT - 2f)
}

Expand Down

0 comments on commit 4680957

Please sign in to comment.