mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-10 22:01:52 +09:00
- We might need virtual disk image... Former-commit-id: c3278cd9fe1ddad8b26b45577fecb0500365d38b
64 lines
2.0 KiB
Kotlin
64 lines
2.0 KiB
Kotlin
package net.torvald.terrarum
|
|
|
|
import net.torvald.terrarum.gamecontroller.Key
|
|
import net.torvald.terrarum.virtualcomputer.computer.TerrarumComputer
|
|
import net.torvald.terrarum.virtualcomputer.terminal.SimpleTextTerminal
|
|
import net.torvald.terrarum.virtualcomputer.terminal.Teletype
|
|
import net.torvald.terrarum.virtualcomputer.terminal.TeletypeTerminal
|
|
import org.newdawn.slick.Color
|
|
import org.newdawn.slick.GameContainer
|
|
import org.newdawn.slick.Graphics
|
|
import org.newdawn.slick.Image
|
|
import org.newdawn.slick.state.BasicGameState
|
|
import org.newdawn.slick.state.StateBasedGame
|
|
|
|
/**
|
|
* ComputerCraft/OpenComputers like-alike, just for fun!
|
|
*
|
|
* Created by minjaesong on 16-09-07.
|
|
*/
|
|
class StateVTTest : BasicGameState() {
|
|
|
|
// HiRes: 100x64, LoRes: 80x25
|
|
val computerInside = TerrarumComputer(peripheralSlots = 8)
|
|
val vt = SimpleTextTerminal(SimpleTextTerminal.AMBER, 80, 25,
|
|
computerInside, colour = false, hires = false)
|
|
|
|
|
|
val vtUI = Image(vt.displayW, vt.displayH)
|
|
|
|
|
|
init {
|
|
computerInside.attachTerminal(vt)
|
|
}
|
|
|
|
override fun init(container: GameContainer, game: StateBasedGame) {
|
|
//vt.openInput()
|
|
}
|
|
|
|
override fun update(container: GameContainer, game: StateBasedGame, delta: Int) {
|
|
Terrarum.appgc.setTitle("VT — F: ${container.fps}" +
|
|
" — M: ${Terrarum.memInUse}M / ${Terrarum.memXmx}M")
|
|
vt.update(container, delta)
|
|
computerInside.update(container, delta)
|
|
}
|
|
|
|
override fun getID() = Terrarum.STATE_ID_TEST_TTY
|
|
|
|
private val paperColour = Color(0xfffce6)
|
|
|
|
val vtUIrenderX = Terrarum.WIDTH.minus(vtUI.width).div(2f)
|
|
val vtUIrenderY = Terrarum.HEIGHT.minus(vtUI.height).div(2f)
|
|
|
|
override fun render(container: GameContainer, game: StateBasedGame, g: Graphics) {
|
|
vt.render(container, vtUI.graphics)
|
|
|
|
|
|
blendNormal()
|
|
g.drawImage(vtUI, vtUIrenderX, vtUIrenderY)
|
|
}
|
|
|
|
override fun keyPressed(key: Int, c: Char) {
|
|
vt.keyPressed(key, c)
|
|
}
|
|
} |