Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmasB committed Mar 24, 2024
1 parent c3d8d53 commit f68cd7c
Showing 1 changed file with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import com.almasb.fxgl.input.KeyTrigger
import com.almasb.fxgl.input.Trigger
import com.almasb.fxgl.input.TriggerListener
import com.almasb.fxgl.input.view.TriggerView
import com.almasb.fxgl.logging.Logger
import com.almasb.fxgl.minigames.MiniGame
import com.almasb.fxgl.minigames.MiniGameResult
import com.almasb.fxgl.minigames.MiniGameView
Expand Down Expand Up @@ -49,7 +48,6 @@ class TriggerSequenceView(miniGame: TriggerSequenceMiniGame = TriggerSequenceMin
private val bad = ImageView(Image(javaClass.getResourceAsStream("cross.png")))

init {

line1.strokeWidth = 2.0
line2.strokeWidth = 2.0

Expand All @@ -60,16 +58,16 @@ class TriggerSequenceView(miniGame: TriggerSequenceMiniGame = TriggerSequenceMin
.interpolator(Interpolators.ELASTIC.EASE_OUT())
.onFinished(Runnable { circle.opacity = 0.0 })
.translate(circle)
.from(Point2D(0.0, 40.0))
.to(Point2D(0.0, -40.0))
.from(Point2D(25.0, 40.0))
.to(Point2D(25.0, -40.0))
.build()

animationBad = AnimationBuilder().duration(Duration.seconds(0.49))
.onFinished(Runnable { circle.opacity = 0.0 })
.interpolator(Interpolators.ELASTIC.EASE_OUT())
.translate(circle)
.from(Point2D(0.0, 40.0))
.to(Point2D(0.0, 190.0))
.from(Point2D(25.0, 40.0))
.to(Point2D(25.0, 190.0))
.build()

children.addAll(line1, line2, circle, triggerViews)
Expand All @@ -95,11 +93,10 @@ class TriggerSequenceView(miniGame: TriggerSequenceMiniGame = TriggerSequenceMin

private fun checkTriggerPosition(currentTriggerView: Node) {
if (currentTriggerView.translateX < line1.startX) {
triggerViews.children.removeAt(0) // TODO Check index
triggerViews.children.remove(currentTriggerView)
currentTriggerIndex++
startAnimationBad()
}

}

private fun startAnimationGood() {
Expand Down Expand Up @@ -130,10 +127,10 @@ class TriggerSequenceView(miniGame: TriggerSequenceMiniGame = TriggerSequenceMin
val currentTrigger = triggerViews.children.removeAt(0)

// Has the correct key been pressed, and is the current view between the two lines
if (miniGame.isCorrect(key, currentTriggerIndex) &&
currentTrigger.translateX >= line1.startX &&
currentTrigger.translateX <= line2.startX)
{
if (miniGame.isCorrect(key, currentTriggerIndex)
&& currentTrigger.translateX >= line1.startX
&& currentTrigger.translateX <= line2.startX) {

startAnimationGood()
numCorrectTriggers++
} else {
Expand All @@ -153,8 +150,6 @@ class TriggerSequenceView(miniGame: TriggerSequenceMiniGame = TriggerSequenceMin
*/
class TriggerSequenceMiniGame(val winRatio: Double) : MiniGame<TriggerSequenceResult>() {

private val log = Logger.get(javaClass)

var numTriggersForSuccess = 0
val numTriggers: Int
get() = triggers.size
Expand Down Expand Up @@ -196,6 +191,4 @@ class TriggerSequenceMiniGame(val winRatio: Double) : MiniGame<TriggerSequenceRe
}
}

class TriggerSequenceResult(override val isSuccess: Boolean, val ratio: Double ) : MiniGameResult {

}
class TriggerSequenceResult(override val isSuccess: Boolean, val ratio: Double ) : MiniGameResult

0 comments on commit f68cd7c

Please sign in to comment.