Skip to content

Commit

Permalink
Merge branch 'removing-infinite-anims' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ben_pollard committed Dec 14, 2023
2 parents f1224da + 1ecd271 commit 9fa311a
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ internal class LaughAnimation(
val msPerFrame = (AnimationController.MILLISECONDS_PER_SECOND / laugh.framesPerSecond)
val duration = msPerFrame * totalMoves
var i = 0
var hasReportedFinished = false

val animationController = AnimationController(
duration.toLong(),
Expand All @@ -43,9 +42,6 @@ internal class LaughAnimation(

if (progress.finished) {
listener.invoke()
} else if (laugh.oscillations == Laugh.NO_OSCILLATION_LIMIT && !hasReportedFinished) {
hasReportedFinished = true
listener.invoke()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ internal class ShakeAnimation(
val msPerFrame = (AnimationController.MILLISECONDS_PER_SECOND / shake.framesPerSecond)
val duration = msPerFrame * totalMoves
var i = 0
var hasReportedFinished = false

val animationController = AnimationController(
duration.toLong(),
Expand All @@ -49,9 +48,6 @@ internal class ShakeAnimation(

if (progress.finished) {
listener.invoke()
} else if (shake.oscillations == Shake.NO_OSCILLATION_LIMIT && !hasReportedFinished) {
hasReportedFinished = true
listener.invoke()
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.github.benpollarduk.ktvn.characters.Character
import com.github.benpollarduk.ktvn.characters.animations.Animation
import com.github.benpollarduk.ktvn.characters.animations.Laugh
import com.github.benpollarduk.ktvn.characters.animations.Shake
import com.github.benpollarduk.ktvn.characters.animations.Stop
import com.github.benpollarduk.ktvn.layout.Position
import com.github.benpollarduk.ktvn.layout.PositionTranslator
import com.github.benpollarduk.ktvn.layout.Positions
Expand All @@ -18,7 +17,6 @@ import com.github.benpollarduk.ktvn.prototyping.swing.CharacterRender
import com.github.benpollarduk.ktvn.prototyping.swing.ImageResolver
import com.github.benpollarduk.ktvn.prototyping.swing.animations.character.LaughAnimation
import com.github.benpollarduk.ktvn.prototyping.swing.animations.character.ShakeAnimation
import com.github.benpollarduk.ktvn.prototyping.swing.animations.character.StopAnimation
import com.github.benpollarduk.ktvn.prototyping.swing.animations.layout.FadeInCharacter
import com.github.benpollarduk.ktvn.prototyping.swing.animations.layout.FadeOutCharacter
import com.github.benpollarduk.ktvn.prototyping.swing.animations.layout.InstantCharacter
Expand Down Expand Up @@ -115,10 +113,9 @@ class SceneCanvasPanel(
lock.lock()

val bk = backgroundImage
val scaledImage: BufferedImage?

// get dimensions
scaledImage = if (bk != null) {
val scaledImage: BufferedImage? = if (bk != null) {
// use the image, but scale it
ImageResolver.scaleImage(bk, scale)
} else if (resolution.width * resolution.height > 0) {
Expand Down Expand Up @@ -361,9 +358,6 @@ class SceneCanvasPanel(
is Shake -> {
ShakeAnimation(this, render, animation)
}
is Stop -> {
StopAnimation(this, render)
}
else -> {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import com.github.benpollarduk.ktvn.characters.Narrator
import com.github.benpollarduk.ktvn.characters.animations.Animation
import com.github.benpollarduk.ktvn.characters.animations.Laugh
import com.github.benpollarduk.ktvn.characters.animations.Shake
import com.github.benpollarduk.ktvn.characters.animations.Stop
import com.github.benpollarduk.ktvn.layout.transitions.FadeIn
import com.github.benpollarduk.ktvn.layout.transitions.LayoutTransition
import com.github.benpollarduk.ktvn.layout.transitions.Slide
Expand Down Expand Up @@ -122,10 +121,5 @@ public object AssetStore {
/**
* A shaking animation.
*/
public val indefiniteShaking: Animation = Shake(0.2, 0.0, Shake.NO_OSCILLATION_LIMIT, 20)

/**
* No animation.
*/
public val stop: Animation = Stop()
public val shaking: Animation = Shake(0.2, 0.0, 10, 20)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import com.github.benpollarduk.ktvn.characters.Emotions.happy
import com.github.benpollarduk.ktvn.characters.Emotions.normal
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.audio
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.configuration
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.indefiniteShaking
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.laughing
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.layoutFadeIn
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.layoutSlide
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.sceneFadeIn
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.sceneFadeOut
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.sfxWoosh
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.shaking
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.shuttleDay
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.shuttleDayMusic
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.sophie
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.stop
import com.github.benpollarduk.ktvn.examples.shuttleLaunch.assets.AssetStore.toki
import com.github.benpollarduk.ktvn.layout.Layout.Companion.createLayout
import com.github.benpollarduk.ktvn.structure.Scene
Expand Down Expand Up @@ -75,11 +74,10 @@ internal fun backOnTheLaunchPad(): Scene {
sophie looks normal
scene.layout exitRight sophie
toki says "Why does she always call me that?!"
toki begins indefiniteShaking
toki begins shaking
},
next {
scene.layout moveRight sophie
toki begins stop
sophie says "Because you are."
},
next {
Expand Down
2 changes: 1 addition & 1 deletion ktvn/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ plugins {
// Publishing properties defined at a project level gradle.properties.
val artifactId: String by project
val artifactGroup: String by project
val ver = "0.7.2"
val ver = "0.7.3"

ext {
// Set the version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package com.github.benpollarduk.ktvn.characters.animations

/**
* Provides an animation which has a shaking effect with a specified [strength] and number of [oscillations]. The
* [strength] should be specified within the normalised range of 0-1. [NO_OSCILLATION_LIMIT] can be specified for
* [oscillations] if the animation should continue indefinitely. The [framesPerSecond] specifies how many frames of the
* animation are displayed per second.
* [strength] should be specified within the normalised range of 0-1. The [framesPerSecond] specifies how many frames
* of the animation are displayed per second.
*/
public class Laugh(
public val strength: Double,
Expand All @@ -14,11 +13,4 @@ public class Laugh(
override fun toString(): String {
return "laugh"
}

public companion object {
/**
* A value representing no oscillation limit.
*/
public const val NO_OSCILLATION_LIMIT: Int = -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package com.github.benpollarduk.ktvn.characters.animations
/**
* Provides an animation which has a shaking effect with a specified [strengthX], [strengthY] and number of
* [oscillations]. The [strengthX] and [strengthY] should be specified within the normalised range of 0-1.
* [NO_OSCILLATION_LIMIT] can be specified for [oscillations] if the animation should continue indefinitely. The
* [framesPerSecond] specifies how many frames of the animation are displayed per second.
* The [framesPerSecond] specifies how many frames of the animation are displayed per second.
*/
public class Shake(
public val strengthX: Double,
Expand All @@ -15,11 +14,4 @@ public class Shake(
override fun toString(): String {
return "shake"
}

public companion object {
/**
* A value representing no oscillation limit.
*/
public const val NO_OSCILLATION_LIMIT: Int = -1
}
}

This file was deleted.

0 comments on commit 9fa311a

Please sign in to comment.