mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-22 16:34:05 +09:00
fixes, bits and pieces, changes in ID referencing, terrain and wall takes damage, working test pickaxe, and a new issue
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.Millisec
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.Input
|
||||
@@ -57,21 +60,86 @@ interface UICanvas {
|
||||
fun doOpeningFade(handler: UIHandler?, openCloseTime: Int) {
|
||||
handler!!.opacity = handler.openCloseCounter.toFloat() / openCloseTime
|
||||
}
|
||||
|
||||
fun doClosingFade(handler: UIHandler?, openCloseTime: Int) {
|
||||
handler!!.opacity = (openCloseTime - handler.openCloseCounter.toFloat()) / openCloseTime
|
||||
}
|
||||
|
||||
fun endOpeningFade(handler: UIHandler?) {
|
||||
handler!!.opacity = 1f
|
||||
}
|
||||
|
||||
fun endClosingFade(handler: UIHandler?) {
|
||||
handler!!.opacity = 0f
|
||||
}
|
||||
|
||||
// TODO add drawer slide in/out (quadratic)
|
||||
|
||||
fun doOpeningPopOut(handler: UIHandler?, openCloseTime: Int, position: Position) {
|
||||
when (position) {
|
||||
Position.LEFT -> handler!!.posX = Movement.fastPullOut(
|
||||
handler.openCloseCounter.toFloat() / openCloseTime,
|
||||
-handler.UI.width.toFloat(),
|
||||
0f
|
||||
).roundInt()
|
||||
Position.TOP -> handler!!.posY = Movement.fastPullOut(
|
||||
handler.openCloseCounter.toFloat() / openCloseTime,
|
||||
-handler.UI.height.toFloat(),
|
||||
0f
|
||||
).roundInt()
|
||||
Position.RIGHT -> handler!!.posX = Movement.fastPullOut(
|
||||
handler.openCloseCounter.toFloat() / openCloseTime,
|
||||
Terrarum.WIDTH.toFloat(),
|
||||
Terrarum.WIDTH - handler.UI.width.toFloat()
|
||||
).roundInt()
|
||||
Position.BOTTOM -> handler!!.posY = Movement.fastPullOut(
|
||||
handler.openCloseCounter.toFloat() / openCloseTime,
|
||||
Terrarum.HEIGHT.toFloat(),
|
||||
Terrarum.HEIGHT - handler.UI.height.toFloat()
|
||||
).roundInt()
|
||||
}
|
||||
}
|
||||
fun doClosingPopOut(handler: UIHandler?, openCloseTime: Int, position: Position) {
|
||||
when (position) {
|
||||
Position.LEFT -> handler!!.posX = Movement.fastPullOut(
|
||||
handler.openCloseCounter.toFloat() / openCloseTime,
|
||||
0f,
|
||||
-handler.UI.width.toFloat()
|
||||
).roundInt()
|
||||
Position.TOP -> handler!!.posY = Movement.fastPullOut(
|
||||
handler.openCloseCounter.toFloat() / openCloseTime,
|
||||
0f,
|
||||
-handler.UI.height.toFloat()
|
||||
).roundInt()
|
||||
Position.RIGHT -> handler!!.posX = Movement.fastPullOut(
|
||||
handler.openCloseCounter.toFloat() / openCloseTime,
|
||||
Terrarum.WIDTH - handler.UI.width.toFloat(),
|
||||
Terrarum.WIDTH.toFloat()
|
||||
).roundInt()
|
||||
Position.BOTTOM -> handler!!.posY = Movement.fastPullOut(
|
||||
handler.openCloseCounter.toFloat() / openCloseTime,
|
||||
Terrarum.HEIGHT - handler.UI.height.toFloat(),
|
||||
Terrarum.HEIGHT.toFloat()
|
||||
).roundInt()
|
||||
}
|
||||
}
|
||||
fun endOpeningPopOut(handler: UIHandler?, position: Position) {
|
||||
when (position) {
|
||||
Position.LEFT -> handler!!.posX = 0
|
||||
Position.TOP -> handler!!.posY = 0
|
||||
Position.RIGHT -> handler!!.posX = Terrarum.WIDTH - handler.UI.width
|
||||
Position.BOTTOM -> handler!!.posY = Terrarum.HEIGHT - handler.UI.height
|
||||
}
|
||||
}
|
||||
fun endClosingPopOut(handler: UIHandler?, position: Position) {
|
||||
when (position) {
|
||||
Position.LEFT -> handler!!.posX = -handler.UI.width
|
||||
Position.TOP -> handler!!.posY = -handler.UI.height
|
||||
Position.RIGHT -> handler!!.posX = Terrarum.WIDTH
|
||||
Position.BOTTOM -> handler!!.posY = Terrarum.HEIGHT
|
||||
}
|
||||
}
|
||||
|
||||
// TODO add blackboard take in/out (sinusoidal)
|
||||
|
||||
enum class Position {
|
||||
LEFT, RIGHT, TOP, BOTTOM
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user