You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

76 lines
2.1 KiB

package scenes
import korlibs.korge.scene.*
import korlibs.korge.view.*
import korlibs.time.*
import model.*
import views.*
import kotlin.math.*
class BattleScene : Scene() {
private val battle = Battle(LoadAction(
timestamp = TimeSpan.ZERO,
battlers = listOf(
Battler.Saved(
id = Battler.Id(0),
name = "Us",
composure = 0.0,
health = 150.0,
maxHealth = 200.0,
energy = 0.0,
stamina = 150.0,
maxStamina = 300.0,
shaken = false,
shakenTimes = 0,
composurePausedUntil = TimeSpan.ZERO,
energyPausedUntil = TimeSpan.ZERO,
),
Battler.Saved(
id = Battler.Id(1),
name = "Them",
composure = 0.0,
health = 150.0,
maxHealth = 200.0,
energy = 0.0,
stamina = 150.0,
maxStamina = 300.0,
shaken = false,
shakenTimes = 0,
composurePausedUntil = TimeSpan.ZERO,
energyPausedUntil = TimeSpan.ZERO,
)
),
pendingEffects = listOf()
))
override suspend fun SContainer.sceneInit() {
val usView = BattlerView(battle.battlers[0])
usView.xy(sceneWidth - (usView.width + 5), sceneHeight - (usView.height + 5))
addChild(usView)
val themView = BattlerView(battle.battlers[1])
themView.xy(5, 5)
addChild(themView)
var time = TimeSpan.ZERO
var fractional = 0.0
addUpdater {
val step = it.milliseconds + fractional
val whole = floor(step)
fractional = step - whole
time += TimeSpan(whole)
battle.setTimeTo(time)
}
}
override suspend fun SContainer.sceneMain() {
// @TODO: Main scene code here (after sceneInit)
}
override suspend fun sceneAfterInit() {
super.sceneAfterInit()
}
}