mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
test watches
This commit is contained in:
BIN
assets/modules/basegame/fonts/7seg_small.tga
LFS
Normal file
BIN
assets/modules/basegame/fonts/7seg_small.tga
LFS
Normal file
Binary file not shown.
BIN
assets/modules/basegame/fonts/7segnum.tga
LFS
Normal file
BIN
assets/modules/basegame/fonts/7segnum.tga
LFS
Normal file
Binary file not shown.
BIN
assets/modules/basegame/fonts/watch_17pxmoondial.tga
LFS
Normal file
BIN
assets/modules/basegame/fonts/watch_17pxmoondial.tga
LFS
Normal file
Binary file not shown.
BIN
assets/modules/basegame/fonts/watch_dotalph.tga
LFS
Normal file
BIN
assets/modules/basegame/fonts/watch_dotalph.tga
LFS
Normal file
Binary file not shown.
BIN
assets/modules/basegame/gui/basic_meter_atlas.tga
LFS
Normal file
BIN
assets/modules/basegame/gui/basic_meter_atlas.tga
LFS
Normal file
Binary file not shown.
BIN
assets/modules/basegame/gui/watchface_atlas.tga
LFS
Normal file
BIN
assets/modules/basegame/gui/watchface_atlas.tga
LFS
Normal file
Binary file not shown.
@@ -96,6 +96,10 @@ class StateInGame : BasicGameState() {
|
||||
lateinit var uiVitalSecondary: UIHandler
|
||||
lateinit var uiVitalItem: UIHandler // itemcount/durability of held block or active ammo of held gun. As for the block, max value is 500.
|
||||
|
||||
lateinit var uiWatchBasic: UIHandler
|
||||
lateinit var uiWatchTierOne: UIHandler
|
||||
|
||||
|
||||
// UI aliases
|
||||
lateinit var uiAliases: ArrayList<UIHandler>
|
||||
private set
|
||||
@@ -103,7 +107,7 @@ class StateInGame : BasicGameState() {
|
||||
private set
|
||||
|
||||
var paused: Boolean = false
|
||||
get() = uiAlasesPausing.map { if (it.isOpened) 1 else 0 }.sum() > 0
|
||||
get() = uiAlasesPausing.map { if (it.isOpened) return true else 0 }.isEmpty() // isEmply is always false, which we want
|
||||
/**
|
||||
* Set to false if UI is opened; set to true if UI is closed.
|
||||
*/
|
||||
@@ -201,6 +205,15 @@ class StateInGame : BasicGameState() {
|
||||
uiVitalItem = UIHandler(UIVitalMetre(player, { null }, { null }, Color(0xffcc00), 0), customPositioning = true)
|
||||
uiVitalItem.setAsAlwaysVisible()
|
||||
|
||||
// basic watch-style notification bar (temperature, new mail)
|
||||
uiWatchBasic = UIHandler(UIBasicNotifier(player))
|
||||
uiWatchBasic.setAsAlwaysVisible()
|
||||
uiWatchBasic.setPosition(Terrarum.WIDTH - uiWatchBasic.UI.width, 0)
|
||||
|
||||
uiWatchTierOne = UIHandler(UITierOneWatch(player))
|
||||
uiWatchTierOne.setAsAlwaysVisible()
|
||||
uiWatchTierOne.setPosition(Terrarum.WIDTH - uiWatchTierOne.UI.width, uiWatchBasic.UI.height - 2)
|
||||
|
||||
|
||||
// batch-process uiAliases
|
||||
uiAliases = arrayListOf(
|
||||
@@ -209,7 +222,9 @@ class StateInGame : BasicGameState() {
|
||||
uiVitalSecondary,
|
||||
uiVitalItem,
|
||||
uiPieMenu,
|
||||
uiQuickBar
|
||||
uiQuickBar,
|
||||
uiWatchBasic,
|
||||
uiWatchTierOne
|
||||
// drawn last
|
||||
)
|
||||
uiAlasesPausing = arrayListOf(
|
||||
|
||||
@@ -89,6 +89,9 @@ class WorldTime(initTime: Long = 0L) {
|
||||
field = if (value < 0) 0 else value
|
||||
}
|
||||
|
||||
val moonPhase: Double
|
||||
get() = (TIME_T % LUNAR_CYCLE).toDouble() / LUNAR_CYCLE
|
||||
|
||||
@Transient private var realMillisec: Double = 0.0
|
||||
@Transient private val REAL_SEC_TO_GAME_SECS = 60
|
||||
|
||||
@@ -134,6 +137,9 @@ class WorldTime(initTime: Long = 0L) {
|
||||
else {
|
||||
s.toInt()
|
||||
}
|
||||
|
||||
|
||||
val LUNAR_CYCLE: Int = 2342643// 29 days, 12 hours, 44 minutes, and 3 seconds in-game calendar
|
||||
}
|
||||
|
||||
fun update(delta: Int) {
|
||||
|
||||
141
src/net/torvald/terrarum/ui/UIBasicNotifier.kt
Normal file
141
src/net/torvald/terrarum/ui/UIBasicNotifier.kt
Normal file
@@ -0,0 +1,141 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.gameactors.abs
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer.normaliseToColour
|
||||
import org.newdawn.slick.*
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-06-10.
|
||||
*/
|
||||
class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas {
|
||||
override var width = 116
|
||||
override var height = 24
|
||||
override var handler: UIHandler? = null
|
||||
override var openCloseTime: Millisec = 0
|
||||
|
||||
private var ELuptimer = 9999 // to make the light turned off by default
|
||||
private val ELuptime = 5000
|
||||
private var ELon = false
|
||||
|
||||
private var atlas = SpriteSheet(ModMgr.getPath("basegame", "gui/basic_meter_atlas.tga"), width, height)
|
||||
|
||||
private var font = SpriteSheetFont(SpriteSheet(ModMgr.getPath("basegame", "fonts/7seg_small.tga"), 9, 12), ' ')
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
if (ELon) {
|
||||
ELuptimer += delta
|
||||
}
|
||||
|
||||
if (mouseUp || gc.input.isKeyDown(Terrarum.getConfigInt("keyinteract"))) {
|
||||
ELuptimer = 0
|
||||
ELon = true
|
||||
}
|
||||
|
||||
if (ELuptimer >= ELuptime) {
|
||||
ELon = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private val temperature: Int
|
||||
get() = -2
|
||||
private val mailCount: Int
|
||||
get() = 0
|
||||
|
||||
private val lcdLitCol = Color(20,20,20)
|
||||
|
||||
fun getTempStr(): String {
|
||||
val sb = StringBuilder()
|
||||
|
||||
if (temperature < 100) {
|
||||
if (temperature < 0)
|
||||
sb.append("-")
|
||||
else
|
||||
sb.append(" ")
|
||||
|
||||
if (temperature.abs() < 10)
|
||||
sb.append(" ")
|
||||
}
|
||||
|
||||
sb.append(temperature.abs())
|
||||
|
||||
sb.append('"') // celsius superscript
|
||||
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
fun getMailStr(): String {
|
||||
val sb = StringBuilder()
|
||||
|
||||
if (mailCount < 10)
|
||||
sb.append(" ")
|
||||
|
||||
sb.append(mailCount)
|
||||
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
|
||||
override fun render(gc: GameContainer, g: Graphics) {
|
||||
atlas.startUse()
|
||||
|
||||
// backplate
|
||||
g.drawImage(atlas.getSubImage(0, 0), 0f, 0f)
|
||||
|
||||
// because what the fuck
|
||||
blendScreen()
|
||||
g.drawImage(atlas.getSubImage(0, 1), 0f, 0f, Color(12, 12, 12))
|
||||
|
||||
// light overlay or EL
|
||||
if (ELon) {
|
||||
blendNormal()
|
||||
g.drawImage(atlas.getSubImage(0, 2), 0f, 0f)
|
||||
}
|
||||
else {
|
||||
var lightLevel = Color.black
|
||||
|
||||
if (player != null) {
|
||||
val playerPos = player.tilewiseHitbox
|
||||
lightLevel = (LightmapRenderer.getLight(playerPos.canonicalX.toInt(), playerPos.canonicalY.toInt()) ?:
|
||||
Terrarum.ingame!!.world.globalLight
|
||||
).normaliseToColour()
|
||||
}
|
||||
else {
|
||||
lightLevel = Terrarum.ingame!!.world.globalLight.normaliseToColour()
|
||||
}
|
||||
blendMul()
|
||||
g.drawImage(atlas.getSubImage(0, 1), 0f, 0f, lightLevel)
|
||||
}
|
||||
|
||||
// LCD back
|
||||
blendNormal()
|
||||
g.drawImage(atlas.getSubImage(0, 3), 0f, 0f)
|
||||
|
||||
atlas.endUse()
|
||||
|
||||
|
||||
// LCD contents
|
||||
g.color = lcdLitCol
|
||||
g.font = font
|
||||
g.drawString(getTempStr(), 21f, 5f)
|
||||
g.drawString(getMailStr(), 93f, 5f)
|
||||
}
|
||||
|
||||
override fun processInput(gc: GameContainer, delta: Int, input: Input) {
|
||||
}
|
||||
|
||||
override fun doOpening(gc: GameContainer, delta: Int) {
|
||||
}
|
||||
|
||||
override fun doClosing(gc: GameContainer, delta: Int) {
|
||||
}
|
||||
|
||||
override fun endOpening(gc: GameContainer, delta: Int) {
|
||||
}
|
||||
|
||||
override fun endClosing(gc: GameContainer, delta: Int) {
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.Millisec
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
import net.torvald.terrarum.gamecontroller.mouseScreenX
|
||||
import net.torvald.terrarum.gamecontroller.mouseScreenY
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.Input
|
||||
@@ -28,6 +30,20 @@ interface UICanvas {
|
||||
*/
|
||||
var openCloseTime: Millisec
|
||||
|
||||
|
||||
val relativeMouseX: Int
|
||||
get() = (Terrarum.appgc.mouseScreenX - (handler?.posX ?: 0))
|
||||
val relativeMouseY: Int
|
||||
get() = (Terrarum.appgc.mouseScreenY - (handler?.posY ?: 0))
|
||||
|
||||
/** If mouse is hovering over it */
|
||||
val mouseUp: Boolean
|
||||
get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1
|
||||
/** If mouse is hovering over it and mouse is down */
|
||||
val mousePushed: Boolean
|
||||
get() = mouseUp && Terrarum.appgc.input.isMouseButtonDown(Terrarum.getConfigInt("mouseprimary")!!)
|
||||
|
||||
|
||||
fun update(gc: GameContainer, delta: Int)
|
||||
|
||||
fun render(gc: GameContainer, g: Graphics)
|
||||
|
||||
129
src/net/torvald/terrarum/ui/UITierOneWatch.kt
Normal file
129
src/net/torvald/terrarum/ui/UITierOneWatch.kt
Normal file
@@ -0,0 +1,129 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
import net.torvald.terrarum.gameworld.WorldTime
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer.normaliseToColour
|
||||
import org.newdawn.slick.*
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-06-11.
|
||||
*/
|
||||
class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas {
|
||||
override var width = 85
|
||||
override var height = 52
|
||||
override var handler: UIHandler? = null
|
||||
override var openCloseTime: Millisec = 0
|
||||
|
||||
private var ELuptimer = 9999 // to make the light turned off by default
|
||||
private val ELuptime = 5000
|
||||
private var ELon = false
|
||||
|
||||
private var atlas = SpriteSheet(ModMgr.getPath("basegame", "gui/watchface_atlas.tga"), width, height)
|
||||
|
||||
private var littleFont = SpriteSheetFont(SpriteSheet(ModMgr.getPath("basegame", "fonts/7seg_small.tga"), 9, 12), ' ')
|
||||
private var timeFont = SpriteSheetFont(SpriteSheet(ModMgr.getPath("basegame", "fonts/7segnum.tga"), 11, 18), '/')
|
||||
private var textFont = SpriteSheetFont(SpriteSheet(ModMgr.getPath("basegame", "fonts/watch_dotalph.tga"), 12, 10), '@')
|
||||
private var moonDial = SpriteSheet(ModMgr.getPath("basegame", "fonts/watch_17pxmoondial.tga"), 17, 17)
|
||||
private var moonDialCount = moonDial.horizontalCount
|
||||
|
||||
private val lcdLitCol = Color(20,20,20)
|
||||
|
||||
private val worldTime: WorldTime
|
||||
get() = Terrarum.ingame!!.world.time
|
||||
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
if (ELon) {
|
||||
ELuptimer += delta
|
||||
}
|
||||
|
||||
if (mouseUp || gc.input.isKeyDown(Terrarum.getConfigInt("keyinteract"))) {
|
||||
ELuptimer = 0
|
||||
ELon = true
|
||||
}
|
||||
|
||||
if (ELuptimer >= ELuptime) {
|
||||
ELon = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun render(gc: GameContainer, g: Graphics) {
|
||||
atlas.startUse()
|
||||
|
||||
// backplate
|
||||
g.drawImage(atlas.getSubImage(0, 0), 0f, 0f)
|
||||
|
||||
// because what the fuck
|
||||
blendScreen()
|
||||
g.drawImage(atlas.getSubImage(0, 1), 0f, 0f, Color(12, 12, 12))
|
||||
|
||||
// light overlay or EL
|
||||
if (ELon) {
|
||||
blendNormal()
|
||||
g.drawImage(atlas.getSubImage(0, 2), 0f, 0f)
|
||||
}
|
||||
else {
|
||||
var lightLevel = Color.black
|
||||
|
||||
if (player != null) {
|
||||
val playerPos = player.tilewiseHitbox
|
||||
lightLevel = (LightmapRenderer.getLight(playerPos.canonicalX.toInt(), playerPos.canonicalY.toInt()) ?:
|
||||
Terrarum.ingame!!.world.globalLight
|
||||
).normaliseToColour()
|
||||
}
|
||||
else {
|
||||
lightLevel = Terrarum.ingame!!.world.globalLight.normaliseToColour()
|
||||
}
|
||||
blendMul()
|
||||
g.drawImage(atlas.getSubImage(0, 1), 0f, 0f, lightLevel)
|
||||
}
|
||||
|
||||
// LCD back
|
||||
blendNormal()
|
||||
g.drawImage(atlas.getSubImage(0, 3), 0f, 0f)
|
||||
|
||||
atlas.endUse()
|
||||
|
||||
|
||||
// day name
|
||||
g.color = lcdLitCol
|
||||
g.font = textFont
|
||||
g.drawString(worldTime.getDayNameShort().toUpperCase(), 7f, 7f)
|
||||
|
||||
// month
|
||||
g.font = littleFont
|
||||
g.drawString(worldTime.months.toString().padStart(2, ' '), 40f, 6f)
|
||||
// day
|
||||
g.drawString(worldTime.days.toString().padStart(2, ' '), 62f, 6f)
|
||||
|
||||
// hour
|
||||
g.font = timeFont
|
||||
g.drawString(worldTime.hours.toString().padStart(2, '/'), 30f, 28f)
|
||||
// minute
|
||||
g.drawString(worldTime.minutes.toString().padStart(2, '0'), 58f, 28f)
|
||||
|
||||
|
||||
// moon dial
|
||||
val moonPhase = (worldTime.moonPhase * moonDialCount).roundInt() % moonDialCount
|
||||
g.drawImage(moonDial.getSubImage(moonPhase, 0), 4f, 22f, lcdLitCol)
|
||||
}
|
||||
|
||||
override fun processInput(gc: GameContainer, delta: Int, input: Input) {
|
||||
}
|
||||
|
||||
override fun doOpening(gc: GameContainer, delta: Int) {
|
||||
}
|
||||
|
||||
override fun doClosing(gc: GameContainer, delta: Int) {
|
||||
}
|
||||
|
||||
override fun endOpening(gc: GameContainer, delta: Int) {
|
||||
}
|
||||
|
||||
override fun endClosing(gc: GameContainer, delta: Int) {
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,6 @@ Connect two or more tracker head to play the array of trackers play simultaneous
|
||||
- Implement it on ```<item>.primaryUse(gc, delta)```
|
||||
|
||||
|
||||
## Computers ##
|
||||
## Particles ##
|
||||
|
||||
Instead of single box with bunch of parts, make computers occupy several blocks -- processor unit, core memory unit, storage unit (RAMAC!), I/O unit, etc., like old PDPs. Powerful computer == more space. Plus portable units like TRS-80 Model 100.
|
||||
- Pickaxe sparks: hard material makes more sparks
|
||||
16
work_files/GameDesign/MODULE_IDEA_TECHPACK.md
Normal file
16
work_files/GameDesign/MODULE_IDEA_TECHPACK.md
Normal file
@@ -0,0 +1,16 @@
|
||||
## Computers
|
||||
|
||||
- Instead of single box with bunch of parts, make computers occupy several blocks -- processor unit, core memory unit, storage unit (RAMAC!), I/O unit, etc., like old PDPs. Powerful computer == more space.
|
||||
- Make portable units like TRS-80 Model 100.
|
||||
- Proper virtual machine with finite RAM and its own virtual CPU with full (but simplified/high level emulation of real things) instruction set and registers
|
||||
- at least BASIC is must be supported
|
||||
- plus C compiler? Am I too ambitious?
|
||||
|
||||
|
||||
## Electricity
|
||||
|
||||
If things would run with infinite energy, I'm out. We need realism to implement resource management which turns into a Fun! (for the most time)
|
||||
|
||||
- Direct Current (only! because AC makes EE 10x harder), follows Ohm's law, and EXPLOSION!
|
||||
- Take 'some' idea from _IndustrialCraft_ (Minecraft mod)
|
||||
|
||||
BIN
work_files/UI/watchface_mockup.psd
LFS
Normal file
BIN
work_files/UI/watchface_mockup.psd
LFS
Normal file
Binary file not shown.
Reference in New Issue
Block a user