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.
78 lines
2.3 KiB
78 lines
2.3 KiB
package scenes
|
|
|
|
import korlibs.event.*
|
|
import korlibs.korge.input.*
|
|
import korlibs.korge.scene.*
|
|
import korlibs.korge.view.*
|
|
import korlibs.time.*
|
|
import model.*
|
|
import views.*
|
|
|
|
class BattleScene : Scene() {
|
|
private val us = BattlerView(Battler("Us", 200.0, 300.0))
|
|
private val them = BattlerView(Battler("Them", 200.0, 300.0))
|
|
|
|
override suspend fun SContainer.sceneInit() {
|
|
us.xy(sceneWidth - (us.width + 5), sceneHeight - (us.height + 5))
|
|
addChild(us)
|
|
|
|
them.xy(5, 5)
|
|
addChild(them)
|
|
|
|
var time = TimeSpan.ZERO
|
|
addUpdater {
|
|
time += it
|
|
}
|
|
|
|
keys {
|
|
downRepeating(Key.Q) {
|
|
them.battler.updateAt(time) {
|
|
them.battler.composure = (them.battler.composure + 5.0).coerceAtMost(them.battler.health)
|
|
}
|
|
}
|
|
downRepeating(Key.A) {
|
|
them.battler.updateAt(time) {
|
|
inflictComposureDamage(5.0)
|
|
}
|
|
}
|
|
downRepeating(Key.W) {
|
|
them.battler.updateAt(time) {
|
|
them.battler.health = (them.battler.health + 5.0).coerceAtMost(them.battler.maxHealth)
|
|
}
|
|
}
|
|
downRepeating(Key.S) {
|
|
them.battler.updateAt(time) {
|
|
inflictHealthDamage(5.0)
|
|
}
|
|
}
|
|
downRepeating(Key.E) {
|
|
them.battler.updateAt(time) {
|
|
them.battler.energy = (them.battler.energy + 5.0).coerceAtMost(them.battler.stamina)
|
|
}
|
|
}
|
|
downRepeating(Key.D) {
|
|
them.battler.updateAt(time) {
|
|
spendEnergy(5.0)
|
|
}
|
|
}
|
|
downRepeating(Key.R) {
|
|
them.battler.updateAt(time) {
|
|
them.battler.stamina = (them.battler.stamina + 5.0).coerceAtMost(them.battler.maxStamina)
|
|
}
|
|
}
|
|
downRepeating(Key.F) {
|
|
them.battler.updateAt(time) {
|
|
spendStamina(5.0)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
override suspend fun SContainer.sceneMain() {
|
|
// @TODO: Main scene code here (after sceneInit)
|
|
}
|
|
|
|
override suspend fun sceneAfterInit() {
|
|
super.sceneAfterInit()
|
|
}
|
|
}
|
|
|