fixed a bug where colourmap won't interpolate properly. BUG: fadeout/fadein is somewhat glitched, UIQuickBar does not fade-in/out instead it just (dis)appears with no effect
Former-commit-id: 029f504b7e2e4d85676ec8b36b27dcbed5e5db47 Former-commit-id: 0b56ca1e8976bfc5e7ea8d665e6ed6496a52de85
4
.idea/codeStyleSettings.xml
generated
@@ -7,9 +7,9 @@
|
|||||||
<JetCodeStyleSettings>
|
<JetCodeStyleSettings>
|
||||||
<option name="ALIGN_IN_COLUMNS_CASE_BRANCH" value="true" />
|
<option name="ALIGN_IN_COLUMNS_CASE_BRANCH" value="true" />
|
||||||
</JetCodeStyleSettings>
|
</JetCodeStyleSettings>
|
||||||
<MultiMarkdownCodeStyleSettings>
|
<MarkdownNavigatorCodeStyleSettings>
|
||||||
<option name="RIGHT_MARGIN" value="72" />
|
<option name="RIGHT_MARGIN" value="72" />
|
||||||
</MultiMarkdownCodeStyleSettings>
|
</MarkdownNavigatorCodeStyleSettings>
|
||||||
<XML>
|
<XML>
|
||||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||||
</XML>
|
</XML>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 932 B After Width: | Height: | Size: 932 B |
|
Before Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 906 B |
BIN
res/graphics/gui/quickbar/item_slot_large.png
Normal file
|
After Width: | Height: | Size: 904 B |
BIN
res/graphics/weathers/generic_light 복사본.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 19 KiB |
18
src/net/torvald/colourutil/ColourTemp.kt
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package net.torvald.colourutil
|
||||||
|
|
||||||
|
import org.newdawn.slick.Color
|
||||||
|
import org.newdawn.slick.Image
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 16-07-26.
|
||||||
|
*/
|
||||||
|
object ColourTemp {
|
||||||
|
private var envOverlayColourmap = Image("./res/graphics/colourmap/black_body_col_1000_40000_K.png")
|
||||||
|
|
||||||
|
private fun colTempToImagePos(K: Int): Int {
|
||||||
|
if (K < 1000 || K >= 40000) throw IllegalArgumentException("K: out of range. ($K)")
|
||||||
|
return (K - 1000) / 10
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun invoke(temp: Int): Color = envOverlayColourmap.getColor(colTempToImagePos(temp), 0)
|
||||||
|
}
|
||||||
10
src/net/torvald/colourutil/ColourUtil.kt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package net.torvald.colourutil
|
||||||
|
|
||||||
|
import org.newdawn.slick.Color
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 16-07-26.
|
||||||
|
*/
|
||||||
|
object ColourUtil {
|
||||||
|
fun toSlickColor(r: Int, g: Int, b: Int) = Color(r.shl(16) or g.shl(8) or b)
|
||||||
|
}
|
||||||
@@ -35,7 +35,7 @@ object WriteGameMapData {
|
|||||||
|
|
||||||
// write binary
|
// write binary
|
||||||
Files.write(tempPath, MAGIC)
|
Files.write(tempPath, MAGIC)
|
||||||
Files.write(tempPath, byteArrayOf(GameWorld.BITS))
|
Files.write(tempPath, byteArrayOf(GameWorld.SIZEOF))
|
||||||
Files.write(tempPath, byteArrayOf(GameWorld.LAYERS))
|
Files.write(tempPath, byteArrayOf(GameWorld.LAYERS))
|
||||||
Files.write(tempPath, byteArrayOf(BYTE_NULL))
|
Files.write(tempPath, byteArrayOf(BYTE_NULL))
|
||||||
Files.write(tempPath, byteArrayOf(BYTE_NULL))
|
Files.write(tempPath, byteArrayOf(BYTE_NULL))
|
||||||
@@ -44,15 +44,15 @@ object WriteGameMapData {
|
|||||||
Files.write(tempPath, toByteArray(map.spawnX))
|
Files.write(tempPath, toByteArray(map.spawnX))
|
||||||
Files.write(tempPath, toByteArray(map.spawnY))
|
Files.write(tempPath, toByteArray(map.spawnY))
|
||||||
map.layerTerrain.forEach(
|
map.layerTerrain.forEach(
|
||||||
{b -> Files.write(tempPath, byteArrayOf(b))})
|
{ b -> Files.write(tempPath, byteArrayOf(b)) })
|
||||||
map.layerWall.forEach(
|
map.layerWall.forEach(
|
||||||
{b -> Files.write(tempPath, byteArrayOf(b))})
|
{ b -> Files.write(tempPath, byteArrayOf(b)) })
|
||||||
map.terrainDamage.forEach(
|
map.terrainDamage.forEach(
|
||||||
{b -> Files.write(tempPath, byteArrayOf(b))})
|
{ b -> Files.write(tempPath, byteArrayOf(b)) })
|
||||||
map.wallDamage.forEach(
|
map.wallDamage.forEach(
|
||||||
{b -> Files.write(tempPath, byteArrayOf(b))})
|
{ b -> Files.write(tempPath, byteArrayOf(b)) })
|
||||||
map.layerWire.forEach(
|
map.layerWire.forEach(
|
||||||
{b -> Files.write(tempPath, byteArrayOf(b))})
|
{ b -> Files.write(tempPath, byteArrayOf(b)) })
|
||||||
|
|
||||||
// replace savemeta with tempfile
|
// replace savemeta with tempfile
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package net.torvald.serialise
|
|||||||
import net.torvald.terrarum.mapgenerator.MapGenerator
|
import net.torvald.terrarum.mapgenerator.MapGenerator
|
||||||
import net.torvald.terrarum.mapgenerator.RoguelikeRandomiser
|
import net.torvald.terrarum.mapgenerator.RoguelikeRandomiser
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.itemproperties.ItemPropCodex
|
||||||
|
import net.torvald.terrarum.itemproperties.MaterialPropCodex
|
||||||
import net.torvald.terrarum.tileproperties.TilePropCodex
|
import net.torvald.terrarum.tileproperties.TilePropCodex
|
||||||
import org.apache.commons.codec.digest.DigestUtils
|
import org.apache.commons.codec.digest.DigestUtils
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
@@ -43,8 +45,8 @@ object WriteMeta {
|
|||||||
// define files to get hash
|
// define files to get hash
|
||||||
val fileArray: Array<File> = arrayOf(
|
val fileArray: Array<File> = arrayOf(
|
||||||
File(TilePropCodex.CSV_PATH)
|
File(TilePropCodex.CSV_PATH)
|
||||||
//, File(ItemPropCodex.CSV_PATH)
|
, File(ItemPropCodex.CSV_PATH)
|
||||||
//, File(MaterialPropCodex.CSV_PATH)
|
, File(MaterialPropCodex.CSV_PATH)
|
||||||
//,
|
//,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
*Terrarum* by Torvald
|
*Terrarum* by Torvald
|
||||||
|
|
||||||
Copyright (C) 2015-2016 Torvald. All rights reserved.
|
Copyright (C) 2013-2016 Torvald. All rights reserved.
|
||||||
mailto: skyhi14 *64* __115875741922660__ *46* __6516589__
|
mailto: alswo9628 *at* __gmail__ *dot* __com__
|
||||||
|
|
||||||
|
You can use any assets (sprites, fonts and tiles) for your own goods (e.g. texture pack for Minecraft), provided that you gave necessary credit to this game and me.
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ object DefaultConfig {
|
|||||||
jsonObject.addProperty("joypadrstickx", 2)
|
jsonObject.addProperty("joypadrstickx", 2)
|
||||||
jsonObject.addProperty("joypadrsticky", 3) // logitech indices
|
jsonObject.addProperty("joypadrsticky", 3) // logitech indices
|
||||||
|
|
||||||
// control-keyboard (Java key index. This is what Minecraft also uses)
|
// control-keyboard (Java key codes. This is what Minecraft also uses)
|
||||||
jsonObject.addProperty("keyup", Key.E)
|
jsonObject.addProperty("keyup", Key.E)
|
||||||
jsonObject.addProperty("keyleft", Key.S)
|
jsonObject.addProperty("keyleft", Key.S)
|
||||||
jsonObject.addProperty("keydown", Key.D)
|
jsonObject.addProperty("keydown", Key.D)
|
||||||
|
|||||||
@@ -137,6 +137,13 @@ constructor() : BasicGameState() {
|
|||||||
|
|
||||||
// queue up game UIs
|
// queue up game UIs
|
||||||
// lesser UIs
|
// lesser UIs
|
||||||
|
// quick bar
|
||||||
|
uiAliases[UI_QUICK_BAR] = UIHandler(UIQuickBar())
|
||||||
|
uiAliases[UI_QUICK_BAR]!!.isVisible = true
|
||||||
|
uiAliases[UI_QUICK_BAR]!!.setPosition(0, 0)
|
||||||
|
uiAliases[UI_QUICK_BAR]!!.UI.handler = uiAliases[UI_QUICK_BAR]
|
||||||
|
uiContainer.add(uiAliases[UI_QUICK_BAR]!!)
|
||||||
|
// pie menu
|
||||||
uiAliases[UI_PIE_MENU] = UIHandler(UIPieMenu())
|
uiAliases[UI_PIE_MENU] = UIHandler(UIPieMenu())
|
||||||
uiAliases[UI_PIE_MENU]!!.setPosition(
|
uiAliases[UI_PIE_MENU]!!.setPosition(
|
||||||
(Terrarum.WIDTH - uiAliases[UI_PIE_MENU]!!.UI.width) / 2,
|
(Terrarum.WIDTH - uiAliases[UI_PIE_MENU]!!.UI.width) / 2,
|
||||||
@@ -284,65 +291,65 @@ constructor() : BasicGameState() {
|
|||||||
|
|
||||||
if (Terrarum.getConfigIntArray("keyquickselalt").contains(key)
|
if (Terrarum.getConfigIntArray("keyquickselalt").contains(key)
|
||||||
|| key == Terrarum.getConfigInt("keyquicksel")) {
|
|| key == Terrarum.getConfigInt("keyquicksel")) {
|
||||||
uiAliases[UI_PIE_MENU]!!.setAsOpening()
|
uiAliases[UI_PIE_MENU]!!.setAsOpen()
|
||||||
// TODO hide quick bar
|
uiAliases[UI_QUICK_BAR]!!.setAsClose()
|
||||||
}
|
}
|
||||||
|
|
||||||
uiContainer.forEach { it.keyPressed(key, c) }
|
uiContainer.forEach { it.keyPressed(key, c) } // for KeyboardControlled UIcanvases
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun keyReleased(key: Int, c: Char) {
|
override fun keyReleased(key: Int, c: Char) {
|
||||||
GameController.keyReleased(key, c)
|
GameController.keyReleased(key, c)
|
||||||
|
|
||||||
if (Terrarum.getConfigIntArray("keyquickselalt").contains(key)
|
if (Terrarum.getConfigIntArray("keyquickselalt").contains(key)
|
||||||
|| key == Terrarum.getConfigInt("keyquicksel")) {
|
|| key == Terrarum.getConfigInt("keyquicksel")) {
|
||||||
uiAliases[UI_PIE_MENU]!!.setAsClosing()
|
uiAliases[UI_PIE_MENU]!!.setAsClose()
|
||||||
// TODO show quick bar
|
uiAliases[UI_QUICK_BAR]!!.setAsOpen()
|
||||||
}
|
}
|
||||||
|
|
||||||
uiContainer.forEach { it.keyReleased(key, c) }
|
uiContainer.forEach { it.keyReleased(key, c) } // for KeyboardControlled UIcanvases
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
GameController.mouseMoved(oldx, oldy, newx, newy)
|
GameController.mouseMoved(oldx, oldy, newx, newy)
|
||||||
|
|
||||||
uiContainer.forEach { it.mouseMoved(oldx, oldy, newx, newy) }
|
uiContainer.forEach { it.mouseMoved(oldx, oldy, newx, newy) } // for MouseControlled UIcanvases
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
GameController.mouseDragged(oldx, oldy, newx, newy)
|
GameController.mouseDragged(oldx, oldy, newx, newy)
|
||||||
|
|
||||||
uiContainer.forEach { it.mouseDragged(oldx, oldy, newx, newy) }
|
uiContainer.forEach { it.mouseDragged(oldx, oldy, newx, newy) } // for MouseControlled UIcanvases
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mousePressed(button: Int, x: Int, y: Int) {
|
override fun mousePressed(button: Int, x: Int, y: Int) {
|
||||||
GameController.mousePressed(button, x, y)
|
GameController.mousePressed(button, x, y)
|
||||||
|
|
||||||
uiContainer.forEach { it.mousePressed(button, x, y) }
|
uiContainer.forEach { it.mousePressed(button, x, y) } // for MouseControlled UIcanvases
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mouseReleased(button: Int, x: Int, y: Int) {
|
override fun mouseReleased(button: Int, x: Int, y: Int) {
|
||||||
GameController.mouseReleased(button, x, y)
|
GameController.mouseReleased(button, x, y)
|
||||||
|
|
||||||
uiContainer.forEach { it.mouseReleased(button, x, y) }
|
uiContainer.forEach { it.mouseReleased(button, x, y) } // for MouseControlled UIcanvases
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mouseWheelMoved(change: Int) {
|
override fun mouseWheelMoved(change: Int) {
|
||||||
GameController.mouseWheelMoved(change)
|
GameController.mouseWheelMoved(change)
|
||||||
|
|
||||||
uiContainer.forEach { it.mouseWheelMoved(change) }
|
uiContainer.forEach { it.mouseWheelMoved(change) } // for MouseControlled UIcanvases
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun controllerButtonPressed(controller: Int, button: Int) {
|
override fun controllerButtonPressed(controller: Int, button: Int) {
|
||||||
GameController.controllerButtonPressed(controller, button)
|
GameController.controllerButtonPressed(controller, button)
|
||||||
|
|
||||||
uiContainer.forEach { it.controllerButtonPressed(controller, button) }
|
uiContainer.forEach { it.controllerButtonPressed(controller, button) } // for GamepadControlled UIcanvases
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun controllerButtonReleased(controller: Int, button: Int) {
|
override fun controllerButtonReleased(controller: Int, button: Int) {
|
||||||
GameController.controllerButtonReleased(controller, button)
|
GameController.controllerButtonReleased(controller, button)
|
||||||
|
|
||||||
uiContainer.forEach { it.controllerButtonReleased(controller, button) }
|
uiContainer.forEach { it.controllerButtonReleased(controller, button) } // for GamepadControlled UIcanvases
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getID(): Int = Terrarum.SCENE_ID_GAME
|
override fun getID(): Int = Terrarum.SCENE_ID_GAME
|
||||||
@@ -352,7 +359,7 @@ constructor() : BasicGameState() {
|
|||||||
/** Send message to notifier UI and toggle the UI as opened. */
|
/** Send message to notifier UI and toggle the UI as opened. */
|
||||||
fun sendNotification(msg: Array<String>) {
|
fun sendNotification(msg: Array<String>) {
|
||||||
(notifier.UI as Notification).sendNotification(Terrarum.appgc, UPDATE_DELTA, msg)
|
(notifier.UI as Notification).sendNotification(Terrarum.appgc, UPDATE_DELTA, msg)
|
||||||
notifier.setAsOpening()
|
notifier.setAsOpen()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun wakeDormantActors() {
|
fun wakeDormantActors() {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import net.torvald.terrarum.langpack.Lang
|
|||||||
import net.torvald.terrarum.ui.Typesetter
|
import net.torvald.terrarum.ui.Typesetter
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
import net.torvald.terrarum.ui.UIHandler
|
import net.torvald.terrarum.ui.UIHandler
|
||||||
import net.torvald.terrarum.ui.UITypable
|
import net.torvald.terrarum.ui.KeyboardControlled
|
||||||
import org.newdawn.slick.Color
|
import org.newdawn.slick.Color
|
||||||
import org.newdawn.slick.GameContainer
|
import org.newdawn.slick.GameContainer
|
||||||
import org.newdawn.slick.Graphics
|
import org.newdawn.slick.Graphics
|
||||||
@@ -32,7 +32,7 @@ class StateMonitorCheck : BasicGameState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun keyPressed(key: Int, c: Char) {
|
override fun keyPressed(key: Int, c: Char) {
|
||||||
//uiMonitorCheck.setAsClosing()
|
//uiMonitorCheck.setAsClose()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getID(): Int = Terrarum.SCENE_ID_CONFIG_CALIBRATE
|
override fun getID(): Int = Terrarum.SCENE_ID_CONFIG_CALIBRATE
|
||||||
|
|||||||
@@ -64,12 +64,11 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
get() = controllerVel!!.x
|
get() = controllerVel!!.x
|
||||||
internal set(value) { controllerVel!!.x = value }
|
internal set(value) { controllerVel!!.x = value }
|
||||||
var walkY: Double
|
var walkY: Double
|
||||||
get() = controllerVel!!.x
|
get() = controllerVel!!.y
|
||||||
internal set(value) { controllerVel!!.x = value }
|
internal set(value) { controllerVel!!.y = value }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Physical properties.
|
* Physical properties.
|
||||||
* Values derived from ActorValue must be @Transient.
|
|
||||||
*/
|
*/
|
||||||
var scale: Double
|
var scale: Double
|
||||||
get() = actorValue.getAsDouble(AVKey.SCALE) ?: 1.0
|
get() = actorValue.getAsDouble(AVKey.SCALE) ?: 1.0
|
||||||
@@ -212,6 +211,8 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
|
|
||||||
var ccdCollided = false
|
var ccdCollided = false
|
||||||
|
|
||||||
|
var isWalking = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// some initialiser goes here...
|
// some initialiser goes here...
|
||||||
}
|
}
|
||||||
@@ -291,6 +292,7 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
* Actual physics thing (altering velocity) starts from here
|
* Actual physics thing (altering velocity) starts from here
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Combine velo and walk
|
||||||
applyMovementVelocity()
|
applyMovementVelocity()
|
||||||
|
|
||||||
// applyBuoyancy()
|
// applyBuoyancy()
|
||||||
@@ -308,14 +310,13 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
// Set 'next' position (hitbox) from canonical and walking velocity
|
// Set 'next' position (hitbox) from canonical and walking velocity
|
||||||
setNewNextHitbox()
|
setNewNextHitbox()
|
||||||
|
|
||||||
applyNormalForce()
|
|
||||||
/**
|
/**
|
||||||
* solveCollision()?
|
* solveCollision()?
|
||||||
* If and only if:
|
* If and only if:
|
||||||
* This body is NON-STATIC and the other body is STATIC
|
* This body is NON-STATIC and the other body is STATIC
|
||||||
*/
|
*/
|
||||||
setNewNextHitbox()
|
|
||||||
displaceByCCD()
|
displaceByCCD()
|
||||||
|
applyNormalForce()
|
||||||
|
|
||||||
setHorizontalFriction()
|
setHorizontalFriction()
|
||||||
if (isPlayerNoClip) // or hanging on the rope, etc.
|
if (isPlayerNoClip) // or hanging on the rope, etc.
|
||||||
@@ -394,21 +395,15 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* FIXME the culprit!
|
|
||||||
* (5566 -> no collision but player does not "sink")
|
|
||||||
* (5567 -> collision)
|
|
||||||
* How to fix:
|
|
||||||
*/
|
|
||||||
private fun applyNormalForce() {
|
private fun applyNormalForce() {
|
||||||
if (!isNoCollideWorld) {
|
if (!isNoCollideWorld) {
|
||||||
// axis Y. Use operand >=
|
// axis Y. Use operand >=
|
||||||
if (moveDelta.y >= 0.0) { // was moving downward?
|
if (moveDelta.y >= 0.0) { // was moving downward?
|
||||||
if (isColliding(nextHitbox)) {
|
if (isColliding(nextHitbox)) { // FIXME if standing: standard box, if walking: top-squished box
|
||||||
hitAndReflectY()
|
hitAndReflectY()
|
||||||
grounded = true
|
grounded = true
|
||||||
}
|
}
|
||||||
else if (isTouchingSide(nextHitbox, COLLIDING_BOTTOM)) { // actor hit something on its bottom
|
else if (isTouchingSide(nextHitbox, COLLIDING_BOTTOM) && !isColliding(nextHitbox)) { // actor hit something on its bottom
|
||||||
grounded = true
|
grounded = true
|
||||||
}
|
}
|
||||||
else { // the actor is not grounded at all
|
else { // the actor is not grounded at all
|
||||||
@@ -427,7 +422,7 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
if (isTouchingSide(nextHitbox, COLLIDING_LEFT) && isTouchingSide(nextHitbox, COLLIDING_RIGHT)
|
if (isTouchingSide(nextHitbox, COLLIDING_LEFT) && isTouchingSide(nextHitbox, COLLIDING_RIGHT)
|
||||||
&& moveDelta.x != 0.0) { // check right and left
|
&& moveDelta.x != 0.0) { // check right and left
|
||||||
// the actor is hitting the wall
|
// the actor is hitting the wall
|
||||||
hitAndReflectX()
|
//hitAndReflectX()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -436,31 +431,32 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
* nextHitbox must NOT be altered before this method is called!
|
* nextHitbox must NOT be altered before this method is called!
|
||||||
*/
|
*/
|
||||||
private fun displaceByCCD() {
|
private fun displaceByCCD() {
|
||||||
|
ccdCollided = false
|
||||||
|
|
||||||
if (!isNoCollideWorld){
|
if (!isNoCollideWorld){
|
||||||
|
if (!isColliding(nextHitbox, COLLIDING_ALLSIDE))
|
||||||
|
return
|
||||||
|
|
||||||
// do some CCD between hitbox and nextHitbox
|
// do some CCD between hitbox and nextHitbox
|
||||||
val ccdBox = nextHitbox.clone()//.snapToPixel()
|
val ccdDelta = (nextHitbox.toVector() - hitbox.toVector())
|
||||||
val ccdDelta = nextHitbox.toVector() to hitbox.toVector()
|
if (ccdDelta.x != 0.0 || ccdDelta.y != 0.0)
|
||||||
val deltaMax = Math.max(ccdDelta.x.abs(), ccdDelta.y.abs())
|
ccdDelta.set(ccdDelta.setMagnitude(CCD_TICK))
|
||||||
// set ccdDelta so that CCD move a pixel per round
|
|
||||||
if (deltaMax > 1.0)
|
//////TEST//////
|
||||||
ccdDelta *= (1.0 / deltaMax)
|
ccdDelta.x = 0.0
|
||||||
|
//////TEST//////
|
||||||
|
// Result: player CAN WALK with ccdDelta.x of zero, which means previous method is a shit.
|
||||||
|
|
||||||
//println("deltaMax: $deltaMax")
|
//println("deltaMax: $deltaMax")
|
||||||
//println("ccdDelta: $ccdDelta")
|
//println("ccdDelta: $ccdDelta")
|
||||||
|
|
||||||
while (!ccdDelta.isZero && isColliding(ccdBox, COLLIDING_ALLSIDE)) {
|
while (!ccdDelta.isZero && isColliding(nextHitbox, COLLIDING_ALLSIDE)) {
|
||||||
nextHitbox.translate(ccdDelta)
|
nextHitbox.translate(-ccdDelta)
|
||||||
ccdCollided = true
|
ccdCollided = true
|
||||||
|
|
||||||
//ccdBox.reassign(nextHitbox).snapToPixel()
|
|
||||||
ccdBox.reassign(nextHitbox)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//println("ccdCollided: $ccdCollided")
|
//println("ccdCollided: $ccdCollided")
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
ccdCollided = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hitAndReflectX() {
|
private fun hitAndReflectX() {
|
||||||
@@ -625,7 +621,7 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false*/
|
return false*/
|
||||||
return if (tyEnd <= 347) false else true
|
return if (tyEnd < 348) false else true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getContactingAreaFluid(side: Int, translateX: Int = 0, translateY: Int = 0): Int {
|
private fun getContactingAreaFluid(side: Int, translateX: Int = 0, translateY: Int = 0): Int {
|
||||||
@@ -749,17 +745,23 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get highest friction value from feet tiles.
|
* Get highest friction value from surrounding tiles
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
internal val bodyFriction: Int
|
internal val bodyFriction: Int
|
||||||
get() {
|
get() {
|
||||||
/*var friction = 0
|
var friction = 0
|
||||||
|
val frictionCalcHitbox = if (isWalking)
|
||||||
|
Hitbox(nextHitbox.posX + 1.0, nextHitbox.posY + 1.0,
|
||||||
|
nextHitbox.width - 2.0, nextHitbox.height - 2.0)
|
||||||
|
else
|
||||||
|
nextHitbox.clone()
|
||||||
|
|
||||||
// take highest value
|
// take highest value
|
||||||
val tilePosXStart = (hitbox.posX / TSIZE).roundInt()
|
val tilePosXStart = (frictionCalcHitbox.posX / TSIZE).floorInt()
|
||||||
val tilePosXEnd = (hitbox.hitboxEnd.x / TSIZE).roundInt()
|
val tilePosXEnd = (frictionCalcHitbox.hitboxEnd.x / TSIZE).floorInt()
|
||||||
val tilePosY = (hitbox.pointedY.plus(1) / TSIZE).roundInt()
|
val tilePosY = (frictionCalcHitbox.pointedY / TSIZE).floorInt()
|
||||||
|
|
||||||
for (x in tilePosXStart..tilePosXEnd) {
|
for (x in tilePosXStart..tilePosXEnd) {
|
||||||
val tile = world.getTileFromTerrain(x, tilePosY)
|
val tile = world.getTileFromTerrain(x, tilePosY)
|
||||||
val thisFriction = TilePropCodex.getProp(tile).friction
|
val thisFriction = TilePropCodex.getProp(tile).friction
|
||||||
@@ -767,16 +769,10 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
if (thisFriction > friction) friction = thisFriction
|
if (thisFriction > friction) friction = thisFriction
|
||||||
}
|
}
|
||||||
|
|
||||||
return friction*/
|
return friction
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
fun Int.tileFrictionToMult(): Double = this / 16.0
|
fun Int.tileFrictionToMult(): Double = this / 16.0
|
||||||
|
|
||||||
internal val feetFriction: Int
|
|
||||||
get() {
|
|
||||||
return 16
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get highest tile density from occupying tiles, fluid only
|
* Get highest tile density from occupying tiles, fluid only
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ object PBSigrid {
|
|||||||
|
|
||||||
p.actorValue[AVKey.INTELLIGENT] = true
|
p.actorValue[AVKey.INTELLIGENT] = true
|
||||||
|
|
||||||
p.actorValue[AVKey.LUMINOSITY] = 95487100
|
p.actorValue[AVKey.LUMINOSITY] = 0//95487100
|
||||||
|
|
||||||
p.actorValue[AVKey.BASEDEFENCE] = 141
|
p.actorValue[AVKey.BASEDEFENCE] = 141
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,10 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
|
|
||||||
/** how long the jump button has down, in frames */
|
/** how long the jump button has down, in frames */
|
||||||
internal var jumpCounter = 0
|
internal var jumpCounter = 0
|
||||||
|
internal var jumpAcc = 0.0
|
||||||
/** how long the walk button has down, in frames */
|
/** how long the walk button has down, in frames */
|
||||||
internal var walkCounter = 0
|
internal var walkCounterX = 0
|
||||||
|
internal var walkCounterY = 0
|
||||||
@Transient private val MAX_JUMP_LENGTH = 17 // use 17; in internal frames
|
@Transient private val MAX_JUMP_LENGTH = 17 // use 17; in internal frames
|
||||||
|
|
||||||
private var readonly_totalX = 0.0
|
private var readonly_totalX = 0.0
|
||||||
@@ -134,7 +136,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
* @author minjaesong
|
* @author minjaesong
|
||||||
*/
|
*/
|
||||||
private fun walkHorizontal(left: Boolean, absAxisVal: Float) {
|
private fun walkHorizontal(left: Boolean, absAxisVal: Float) {
|
||||||
if ((!walledLeft && left) || (!walledRight && !left)) {
|
if (true) {//(!walledLeft && left) || (!walledRight && !left)) {
|
||||||
readonly_totalX = //veloX +
|
readonly_totalX = //veloX +
|
||||||
/*actorValue.getAsDouble(AVKey.ACCEL)!! *
|
/*actorValue.getAsDouble(AVKey.ACCEL)!! *
|
||||||
actorValue.getAsDouble(AVKey.ACCELMULT)!! *
|
actorValue.getAsDouble(AVKey.ACCELMULT)!! *
|
||||||
@@ -145,7 +147,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
actorValue.getAsDouble(AVKey.ACCEL)!! *
|
actorValue.getAsDouble(AVKey.ACCEL)!! *
|
||||||
actorValue.getAsDouble(AVKey.ACCELMULT)!! *
|
actorValue.getAsDouble(AVKey.ACCELMULT)!! *
|
||||||
Math.sqrt(scale) *
|
Math.sqrt(scale) *
|
||||||
applyVelo(walkCounter) *
|
applyVelo(walkCounterX) *
|
||||||
(if (left) -1 else 1).toFloat() *
|
(if (left) -1 else 1).toFloat() *
|
||||||
absAxisVal
|
absAxisVal
|
||||||
|
|
||||||
@@ -153,7 +155,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
walkX += readonly_totalX
|
walkX += readonly_totalX
|
||||||
walkX = absClamp(walkX, actorValue.getAsDouble(AVKey.SPEED)!! * actorValue.getAsDouble(AVKey.SPEEDMULT)!!)
|
walkX = absClamp(walkX, actorValue.getAsDouble(AVKey.SPEED)!! * actorValue.getAsDouble(AVKey.SPEEDMULT)!!)
|
||||||
|
|
||||||
walkCounter += 1
|
walkCounterX += 1
|
||||||
|
|
||||||
// Heading flag
|
// Heading flag
|
||||||
if (left)
|
if (left)
|
||||||
@@ -162,6 +164,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
walkHeading = RIGHT
|
walkHeading = RIGHT
|
||||||
|
|
||||||
// println("$walkCounter: ${readonly_totalX}")
|
// println("$walkCounter: ${readonly_totalX}")
|
||||||
|
isWalking = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,13 +179,16 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
actorValue.getAsDouble(AVKey.ACCEL)!! *
|
actorValue.getAsDouble(AVKey.ACCEL)!! *
|
||||||
actorValue.getAsDouble(AVKey.ACCELMULT)!! *
|
actorValue.getAsDouble(AVKey.ACCELMULT)!! *
|
||||||
Math.sqrt(scale) *
|
Math.sqrt(scale) *
|
||||||
applyVelo(walkCounter) *
|
applyVelo(walkCounterY) *
|
||||||
(if (up) -1 else 1).toFloat() *
|
(if (up) -1 else 1).toFloat() *
|
||||||
absAxisVal
|
absAxisVal
|
||||||
|
|
||||||
applyForce(Vector2(0.0, readonly_totalY))
|
walkY += readonly_totalY
|
||||||
|
walkY = absClamp(walkY, actorValue.getAsDouble(AVKey.SPEED)!! * actorValue.getAsDouble(AVKey.SPEEDMULT)!!)
|
||||||
|
|
||||||
if (walkCounter <= WALK_FRAMES_TO_MAX_ACCEL) walkCounter += 1
|
//if (walkCounterY <= WALK_FRAMES_TO_MAX_ACCEL) walkCounterY += 1
|
||||||
|
|
||||||
|
isWalking = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun applyAccel(x: Int): Double {
|
private fun applyAccel(x: Int): Double {
|
||||||
@@ -219,7 +225,8 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
|
|
||||||
//veloX = 0f
|
//veloX = 0f
|
||||||
|
|
||||||
walkCounter = 0
|
walkCounterX = 0
|
||||||
|
isWalking = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// stops; let the friction kick in by doing nothing to the velocity here
|
// stops; let the friction kick in by doing nothing to the velocity here
|
||||||
@@ -245,7 +252,8 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
|
|
||||||
///veloY = 0f
|
///veloY = 0f
|
||||||
|
|
||||||
walkCounter = 0
|
walkCounterY = 0
|
||||||
|
isWalking = false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -266,9 +274,11 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
var timedJumpCharge = init - init / len * jumpCounter
|
var timedJumpCharge = init - init / len * jumpCounter
|
||||||
if (timedJumpCharge < 0) timedJumpCharge = 0.0
|
if (timedJumpCharge < 0) timedJumpCharge = 0.0
|
||||||
|
|
||||||
val jumpAcc = pwr * timedJumpCharge * JUMP_ACCELERATION_MOD * Math.sqrt(scale) // positive value
|
jumpAcc = -pwr * timedJumpCharge * JUMP_ACCELERATION_MOD * Math.sqrt(scale) // positive value
|
||||||
|
|
||||||
applyForce(Vector2(0.0, -jumpAcc))
|
applyForce(Vector2(0.0, jumpAcc))
|
||||||
|
|
||||||
|
if (jumpAcc != 0.0) println(jumpAcc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// for mob ai:
|
// for mob ai:
|
||||||
@@ -359,7 +369,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
walkHorizontal(true, AXIS_POSMAX)
|
walkHorizontal(true, AXIS_POSMAX)
|
||||||
prevHMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)
|
prevHMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)
|
||||||
} // ↓F, ↓S
|
} // ↓F, ↓S
|
||||||
else if (isFuncDown(input, EnumKeyFunc.MOVE_LEFT) && isFuncDown(input, EnumKeyFunc.MOVE_RIGHT)) {
|
/*else if (isFuncDown(input, EnumKeyFunc.MOVE_LEFT) && isFuncDown(input, EnumKeyFunc.MOVE_RIGHT)) {
|
||||||
if (prevHMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)) {
|
if (prevHMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)) {
|
||||||
walkHorizontal(false, AXIS_POSMAX)
|
walkHorizontal(false, AXIS_POSMAX)
|
||||||
prevHMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_RIGHT)
|
prevHMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_RIGHT)
|
||||||
@@ -367,7 +377,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
walkHorizontal(true, AXIS_POSMAX)
|
walkHorizontal(true, AXIS_POSMAX)
|
||||||
prevHMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)
|
prevHMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -388,7 +398,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
walkVertical(true, AXIS_POSMAX)
|
walkVertical(true, AXIS_POSMAX)
|
||||||
prevVMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)
|
prevVMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)
|
||||||
} // ↓E, ↓D
|
} // ↓E, ↓D
|
||||||
else if (isFuncDown(input, EnumKeyFunc.MOVE_UP) && isFuncDown(input, EnumKeyFunc.MOVE_DOWN)) {
|
/*else if (isFuncDown(input, EnumKeyFunc.MOVE_UP) && isFuncDown(input, EnumKeyFunc.MOVE_DOWN)) {
|
||||||
if (prevVMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)) {
|
if (prevVMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)) {
|
||||||
walkVertical(false, AXIS_POSMAX)
|
walkVertical(false, AXIS_POSMAX)
|
||||||
prevVMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_DOWN)
|
prevVMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_DOWN)
|
||||||
@@ -396,7 +406,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
walkVertical(true, AXIS_POSMAX)
|
walkVertical(true, AXIS_POSMAX)
|
||||||
prevVMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)
|
prevVMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.torvald.terrarum.gamecontroller
|
package net.torvald.terrarum.gamecontroller
|
||||||
|
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
import java.util.Hashtable
|
import java.util.Hashtable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,11 +11,11 @@ object KeyMap {
|
|||||||
var map_code = Hashtable<EnumKeyFunc, Int>()
|
var map_code = Hashtable<EnumKeyFunc, Int>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
map_code.put(EnumKeyFunc.MOVE_UP, Key.E)
|
map_code.put(EnumKeyFunc.MOVE_UP, Terrarum.getConfigInt("keyup"))
|
||||||
map_code.put(EnumKeyFunc.MOVE_LEFT, Key.S)
|
map_code.put(EnumKeyFunc.MOVE_LEFT, Terrarum.getConfigInt("keyleft"))
|
||||||
map_code.put(EnumKeyFunc.MOVE_DOWN, Key.D)
|
map_code.put(EnumKeyFunc.MOVE_DOWN, Terrarum.getConfigInt("keydown"))
|
||||||
map_code.put(EnumKeyFunc.MOVE_RIGHT, Key.F)
|
map_code.put(EnumKeyFunc.MOVE_RIGHT, Terrarum.getConfigInt("keyright"))
|
||||||
map_code.put(EnumKeyFunc.JUMP, Key.SPACE)
|
map_code.put(EnumKeyFunc.JUMP, Terrarum.getConfigInt("keyjump"))
|
||||||
map_code.put(EnumKeyFunc.UI_CONSOLE, Key.GRAVE)
|
map_code.put(EnumKeyFunc.UI_CONSOLE, Key.GRAVE)
|
||||||
map_code.put(EnumKeyFunc.UI_BASIC_INFO, Key.F3)
|
map_code.put(EnumKeyFunc.UI_BASIC_INFO, Key.F3)
|
||||||
}
|
}
|
||||||
@@ -23,7 +24,7 @@ object KeyMap {
|
|||||||
return map_code[fn]!!
|
return map_code[fn]!!
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun set(func: EnumKeyFunc, key: Int) {
|
fun set(func: EnumKeyFunc, key: Int) {
|
||||||
map_code.put(func, key)
|
map_code.put(func, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ constructor(//properties
|
|||||||
@Transient val WIRE = 2
|
@Transient val WIRE = 2
|
||||||
|
|
||||||
@Transient val TILES_SUPPORTED = MapLayer.RANGE * PairedMapLayer.RANGE
|
@Transient val TILES_SUPPORTED = MapLayer.RANGE * PairedMapLayer.RANGE
|
||||||
@Transient val BITS: Byte = 1 // 1 for Byte, 2 for Char, 4 for Int, 8 for Long
|
@Transient val SIZEOF: Byte = MapLayer.SIZEOF
|
||||||
@Transient val LAYERS: Byte = 4 // terrain, wall (terrainDamage + wallDamage), wire
|
@Transient val LAYERS: Byte = 4 // terrain, wall (terrainDamage + wallDamage), wire
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,6 +51,7 @@ class MapLayer(var width: Int, var height: Int) : Iterable<Byte> {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@Transient const val RANGE = 256
|
@Transient const val RANGE = 256
|
||||||
|
@Transient const val SIZEOF: Byte = 1 // 1 for 8-bit, 2 for 16-bit, ...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class PairedMapLayer(width: Int, var height: Int) : Iterable<Byte> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@Transient const val RANGE = 16
|
@Transient const val RANGE = 16
|
||||||
|
@Transient const val SIZEOF: Byte = 1 // 1 for 8-bit, 2 for 16-bit, ...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import net.torvald.terrarum.Terrarum
|
|||||||
import net.torvald.terrarum.tileproperties.TileNameCode
|
import net.torvald.terrarum.tileproperties.TileNameCode
|
||||||
import net.torvald.terrarum.tilestats.TileStats
|
import net.torvald.terrarum.tilestats.TileStats
|
||||||
import com.jme3.math.FastMath
|
import com.jme3.math.FastMath
|
||||||
|
import net.torvald.colourutil.ColourTemp
|
||||||
import org.newdawn.slick.*
|
import org.newdawn.slick.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,14 +14,13 @@ import org.newdawn.slick.*
|
|||||||
object MapDrawer {
|
object MapDrawer {
|
||||||
const val TILE_SIZE = 16
|
const val TILE_SIZE = 16
|
||||||
|
|
||||||
private var envOverlayColourmap: Image = Image("./res/graphics/colourmap/black_body_col_1000_40000_K.png")
|
|
||||||
|
|
||||||
private val ENV_COLTEMP_LOWEST = 5500
|
private val ENV_COLTEMP_LOWEST = 5500
|
||||||
private val ENV_COLTEMP_HIGHEST = 7500
|
private val ENV_COLTEMP_HIGHEST = 7500
|
||||||
|
|
||||||
val ENV_COLTEMP_NOON = 6500 // 6500 == sRGB White == untouched!
|
val ENV_COLTEMP_NOON = 6500 // 6500 == sRGB White == untouched!
|
||||||
|
|
||||||
private var colTemp: Int = 0
|
var colTemp: Int = 0
|
||||||
|
private set
|
||||||
|
|
||||||
private val TILES_COLD = intArrayOf(
|
private val TILES_COLD = intArrayOf(
|
||||||
TileNameCode.ICE_MAGICAL
|
TileNameCode.ICE_MAGICAL
|
||||||
@@ -49,7 +49,7 @@ object MapDrawer {
|
|||||||
colTemp = colTemp_warm + colTemp_cold - ENV_COLTEMP_NOON
|
colTemp = colTemp_warm + colTemp_cold - ENV_COLTEMP_NOON
|
||||||
val zoom = Terrarum.ingame.screenZoom
|
val zoom = Terrarum.ingame.screenZoom
|
||||||
|
|
||||||
g.color = getColourFromMap(colTemp)
|
g.color = ColourTemp(colTemp)
|
||||||
//g.color = getColourFromMap(3022)
|
//g.color = getColourFromMap(3022)
|
||||||
g.fillRect(
|
g.fillRect(
|
||||||
MapCamera.cameraX * zoom,
|
MapCamera.cameraX * zoom,
|
||||||
@@ -70,18 +70,4 @@ object MapDrawer {
|
|||||||
|
|
||||||
return Math.round((ENV_COLTEMP_HIGHEST - ENV_COLTEMP_LOWEST) / 2 * FastMath.clamp(x, -1f, 1f) + colTempMedian)
|
return Math.round((ENV_COLTEMP_HIGHEST - ENV_COLTEMP_LOWEST) / 2 * FastMath.clamp(x, -1f, 1f) + colTempMedian)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getColourFromMap(K: Int): Color {
|
|
||||||
return envOverlayColourmap.getColor(colTempToImagePos(K), 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun colTempToImagePos(K: Int): Int {
|
|
||||||
if (K < 1000 || K >= 40000) throw IllegalArgumentException("K: out of range. ($K)")
|
|
||||||
return (K - 1000) / 10
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun getColTemp(): Int {
|
|
||||||
return colTemp
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@ import java.util.*
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-03-14.
|
* Created by minjaesong on 16-03-14.
|
||||||
*/
|
*/
|
||||||
class BasicDebugInfoWindow:UICanvas {
|
class BasicDebugInfoWindow : UICanvas {
|
||||||
|
|
||||||
override var width: Int = Terrarum.WIDTH
|
override var width: Int = Terrarum.WIDTH
|
||||||
override var height: Int = Terrarum.HEIGHT
|
override var height: Int = Terrarum.HEIGHT
|
||||||
@@ -101,6 +101,8 @@ class BasicDebugInfoWindow:UICanvas {
|
|||||||
printLine(g, 5, "grounded $ccG${player.grounded}")
|
printLine(g, 5, "grounded $ccG${player.grounded}")
|
||||||
printLine(g, 6, "noClip $ccG${player.noClip}")
|
printLine(g, 6, "noClip $ccG${player.noClip}")
|
||||||
|
|
||||||
|
printLine(g, 7, "jump $ccG${player.jumpAcc}")
|
||||||
|
|
||||||
val lightVal: String
|
val lightVal: String
|
||||||
val mtX = mouseTileX.toString()
|
val mtX = mouseTileX.toString()
|
||||||
val mtY = mouseTileY.toString()
|
val mtY = mouseTileY.toString()
|
||||||
@@ -114,7 +116,7 @@ class BasicDebugInfoWindow:UICanvas {
|
|||||||
rawR.toString() + " " +
|
rawR.toString() + " " +
|
||||||
rawG.toString() + " " +
|
rawG.toString() + " " +
|
||||||
rawB.toString() + ")"
|
rawB.toString() + ")"
|
||||||
printLine(g, 7, "light@cursor $ccG$lightVal")
|
printLine(g, 8, "light@cursor $ccG$lightVal")
|
||||||
|
|
||||||
val tileNo: String
|
val tileNo: String
|
||||||
val tileNumRaw = Terrarum.ingame.world.getTileFromTerrain(mouseTileX, mouseTileY) ?: -1
|
val tileNumRaw = Terrarum.ingame.world.getTileFromTerrain(mouseTileX, mouseTileY) ?: -1
|
||||||
@@ -122,18 +124,22 @@ class BasicDebugInfoWindow:UICanvas {
|
|||||||
val tiledmg = tileNumRaw % PairedMapLayer.RANGE
|
val tiledmg = tileNumRaw % PairedMapLayer.RANGE
|
||||||
tileNo = if (tileNumRaw == -1) "—" else "$tilenum:$tiledmg"
|
tileNo = if (tileNumRaw == -1) "—" else "$tilenum:$tiledmg"
|
||||||
|
|
||||||
printLine(g, 8, "tile@cursor $ccG$tileNo ($mtX, $mtY)")
|
printLine(g, 9, "tile@cursor $ccG$tileNo ($mtX, $mtY)")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Second column
|
* Second column
|
||||||
*/
|
*/
|
||||||
|
|
||||||
printLineColumn(g, 2, 1, "VSync $ccG" + Terrarum.appgc.isVSyncRequested)
|
printLineColumn(g, 2, 1, "VSync $ccG" + Terrarum.appgc.isVSyncRequested)
|
||||||
printLineColumn(g, 2, 2, "Env colour temp $ccG" + MapDrawer.getColTemp())
|
printLineColumn(g, 2, 2, "Env colour temp $ccG" + MapDrawer.colTemp)
|
||||||
printLineColumn(g, 2, 5, "Time $ccG${Terrarum.ingame.world.time.elapsedSeconds()}" +
|
printLineColumn(g, 2, 5, "Time $ccG${Terrarum.ingame.world.time.elapsedSeconds()}" +
|
||||||
" (${Terrarum.ingame.world.time.getFormattedTime()})")
|
" (${Terrarum.ingame.world.time.getFormattedTime()})")
|
||||||
printLineColumn(g, 2, 6, "Mass $ccG${player.mass}")
|
printLineColumn(g, 2, 6, "Mass $ccG${player.mass}")
|
||||||
|
|
||||||
|
printLineColumn(g, 2, 7, "p_WalkX $ccG${player.walkX}")
|
||||||
|
printLineColumn(g, 2, 8, "p_WalkY $ccG${player.walkY}")
|
||||||
|
|
||||||
|
|
||||||
drawHistogram(g, LightmapRenderer.histogram,
|
drawHistogram(g, LightmapRenderer.histogram,
|
||||||
Terrarum.WIDTH - histogramW - 30,
|
Terrarum.WIDTH - histogramW - 30,
|
||||||
Terrarum.HEIGHT - histogramH - 30
|
Terrarum.HEIGHT - histogramH - 30
|
||||||
@@ -220,7 +226,7 @@ class BasicDebugInfoWindow:UICanvas {
|
|||||||
|
|
||||||
private fun line(i: Int): Float = i * 10f
|
private fun line(i: Int): Float = i * 10f
|
||||||
|
|
||||||
private fun column(i: Int): Float = 250f * (i - 1)
|
private fun column(i: Int): Float = 300f * (i - 1)
|
||||||
|
|
||||||
override fun doOpening(gc: GameContainer, delta: Int) {
|
override fun doOpening(gc: GameContainer, delta: Int) {
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import org.newdawn.slick.Input
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 15-12-31.
|
* Created by minjaesong on 15-12-31.
|
||||||
*/
|
*/
|
||||||
class ConsoleWindow : UICanvas, UITypable {
|
class ConsoleWindow : UICanvas, KeyboardControlled {
|
||||||
|
|
||||||
internal var UIColour = Color(0xCC000000.toInt())
|
internal var UIColour = Color(0xCC000000.toInt())
|
||||||
|
|
||||||
|
|||||||
12
src/net/torvald/terrarum/ui/GamepadControlled.kt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Button pressing only. If you want stick-controls, use processInput()
|
||||||
|
*
|
||||||
|
* Created by minjaesong on 16-07-21.
|
||||||
|
*/
|
||||||
|
interface GamepadControlled {
|
||||||
|
fun controllerButtonPressed(controller: Int, button: Int)
|
||||||
|
|
||||||
|
fun controllerButtonReleased(controller: Int, button: Int)
|
||||||
|
}
|
||||||
@@ -23,10 +23,16 @@ object ItemSlotImageBuilder {
|
|||||||
SpriteSheet("./res/graphics/fonts/numeric_small.png", 5, 8),
|
SpriteSheet("./res/graphics/fonts/numeric_small.png", 5, 8),
|
||||||
'0'
|
'0'
|
||||||
)
|
)
|
||||||
private val slotImage = Image("./res/graphics/gui/quickbar/item_slot.png")
|
val slotImage = Image("./res/graphics/gui/quickbar/item_slot.png") // must have same w/h as slotLarge
|
||||||
|
val slotLarge = Image("./res/graphics/gui/quickbar/item_slot_large.png")
|
||||||
private val canvas = Image(slotImage.width, slotImage.height)
|
private val canvas = Image(slotImage.width, slotImage.height)
|
||||||
|
private val canvasLarge = Image(slotLarge.width, slotLarge.height)
|
||||||
|
|
||||||
|
val slotImageSize = slotImage.width
|
||||||
|
|
||||||
fun produce(color: Int, number: Int = -1): Image {
|
fun produce(color: Int, number: Int = -1): Image {
|
||||||
|
canvas.graphics.clear()
|
||||||
|
|
||||||
if (color == COLOR_BLACK)
|
if (color == COLOR_BLACK)
|
||||||
canvas.graphics.drawImage(slotImage, 0f, 0f, colourBlack)
|
canvas.graphics.drawImage(slotImage, 0f, 0f, colourBlack)
|
||||||
else if (color == COLOR_WHITE)
|
else if (color == COLOR_WHITE)
|
||||||
@@ -41,12 +47,38 @@ object ItemSlotImageBuilder {
|
|||||||
canvas.graphics.color = colourBlack
|
canvas.graphics.color = colourBlack
|
||||||
|
|
||||||
canvas.graphics.drawString(number.mod(UIQuickBar.SLOT_COUNT).toString(),
|
canvas.graphics.drawString(number.mod(UIQuickBar.SLOT_COUNT).toString(),
|
||||||
slotImage.width - 6f,
|
slotImage.width - 10f,
|
||||||
slotImage.height - 10f
|
slotImage.height - 13f
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return canvas
|
return canvas
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun produceLarge(color: Int, number: Int = -1): Image {
|
||||||
|
canvasLarge.graphics.clear()
|
||||||
|
|
||||||
|
if (color == COLOR_BLACK)
|
||||||
|
canvasLarge.graphics.drawImage(slotLarge, 0f, 0f, colourBlack)
|
||||||
|
else if (color == COLOR_WHITE)
|
||||||
|
canvasLarge.graphics.drawImage(slotLarge, 0f, 0f, colourWhite)
|
||||||
|
|
||||||
|
if (number >= 0) {
|
||||||
|
canvasLarge.graphics.font = numberFont
|
||||||
|
|
||||||
|
if (color == COLOR_BLACK)
|
||||||
|
canvasLarge.graphics.color = colourWhite
|
||||||
|
else if (color == COLOR_WHITE)
|
||||||
|
canvasLarge.graphics.color = colourBlack
|
||||||
|
|
||||||
|
canvasLarge.graphics.drawString(number.mod(UIQuickBar.SLOT_COUNT).toString(),
|
||||||
|
slotLarge.width - 10f,
|
||||||
|
slotLarge.height - 13f
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return canvasLarge
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.ui
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-03-06.
|
* Created by minjaesong on 16-03-06.
|
||||||
*/
|
*/
|
||||||
interface UITypable {
|
interface KeyboardControlled {
|
||||||
fun keyPressed(key: Int, c: Char)
|
fun keyPressed(key: Int, c: Char)
|
||||||
|
|
||||||
fun keyReleased(key: Int, c: Char)
|
fun keyReleased(key: Int, c: Char)
|
||||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.ui
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-03-06.
|
* Created by minjaesong on 16-03-06.
|
||||||
*/
|
*/
|
||||||
interface UIClickable {
|
interface MouseControlled {
|
||||||
fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int)
|
fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int)
|
||||||
|
|
||||||
fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int)
|
fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int)
|
||||||
@@ -13,9 +13,4 @@ interface UIClickable {
|
|||||||
fun mouseReleased(button: Int, x: Int, y: Int)
|
fun mouseReleased(button: Int, x: Int, y: Int)
|
||||||
|
|
||||||
fun mouseWheelMoved(change: Int)
|
fun mouseWheelMoved(change: Int)
|
||||||
|
|
||||||
fun controllerButtonPressed(controller: Int, button: Int)
|
|
||||||
|
|
||||||
fun controllerButtonReleased(controller: Int, button: Int)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,14 +11,18 @@ interface UICanvas {
|
|||||||
|
|
||||||
var width: Int
|
var width: Int
|
||||||
var height: Int
|
var height: Int
|
||||||
|
|
||||||
|
var handler: UIHandler?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In milliseconds
|
* In milliseconds
|
||||||
*/
|
*/
|
||||||
var openCloseTime: Int
|
var openCloseTime: Int
|
||||||
|
/**
|
||||||
|
* Usage: get() = handler!!.openCloseCounter
|
||||||
|
*/
|
||||||
var openCloseTimer: Int
|
var openCloseTimer: Int
|
||||||
|
|
||||||
var handler: UIHandler?
|
|
||||||
|
|
||||||
fun update(gc: GameContainer, delta: Int)
|
fun update(gc: GameContainer, delta: Int)
|
||||||
|
|
||||||
fun render(gc: GameContainer, g: Graphics)
|
fun render(gc: GameContainer, g: Graphics)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.ui
|
|||||||
import net.torvald.terrarum.mapdrawer.MapCamera
|
import net.torvald.terrarum.mapdrawer.MapCamera
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import com.jme3.math.FastMath
|
import com.jme3.math.FastMath
|
||||||
|
import org.lwjgl.opengl.GL11
|
||||||
import org.newdawn.slick.*
|
import org.newdawn.slick.*
|
||||||
import org.newdawn.slick.state.StateBasedGame
|
import org.newdawn.slick.state.StateBasedGame
|
||||||
|
|
||||||
@@ -44,22 +45,25 @@ constructor(val UI: UICanvas) {
|
|||||||
set(value) {
|
set(value) {
|
||||||
if (alwaysVisible)
|
if (alwaysVisible)
|
||||||
throw RuntimeException("[UIHandler] Tried to 'set visibility of' constant UI")
|
throw RuntimeException("[UIHandler] Tried to 'set visibility of' constant UI")
|
||||||
|
if (value == true) {
|
||||||
field = value
|
isOpened = true
|
||||||
|
field = value
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
isOpened = false
|
||||||
|
field = value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var opacity = 1f
|
var opacity = 1f
|
||||||
var scale = 1f
|
var scale = 1f
|
||||||
|
|
||||||
var openCloseCounter = 0
|
var openCloseCounter: Int = 0
|
||||||
|
|
||||||
init {
|
init {
|
||||||
println("[UIHandler] Creating UI '${UI.javaClass.simpleName}'")
|
println("[UIHandler] Creating UI '${UI.javaClass.simpleName}'")
|
||||||
|
|
||||||
UIDrawnCanvas = Image(
|
UIDrawnCanvas = Image(UI.width, UI.height)
|
||||||
//FastMath.nearestPowerOfTwo(UI.width), FastMath.nearestPowerOfTwo(UI.height))
|
|
||||||
UI.width, UI.height)
|
|
||||||
UIDrawnCanvas.filter = Image.FILTER_LINEAR
|
|
||||||
|
|
||||||
UIGraphicInstance = UIDrawnCanvas.graphics
|
UIGraphicInstance = UIDrawnCanvas.graphics
|
||||||
}
|
}
|
||||||
@@ -84,6 +88,7 @@ constructor(val UI: UICanvas) {
|
|||||||
else {
|
else {
|
||||||
UI.endOpening(gc, delta)
|
UI.endOpening(gc, delta)
|
||||||
isOpening = false
|
isOpening = false
|
||||||
|
isClosing = false
|
||||||
isOpened = true
|
isOpened = true
|
||||||
openCloseCounter = 0
|
openCloseCounter = 0
|
||||||
}
|
}
|
||||||
@@ -101,6 +106,7 @@ constructor(val UI: UICanvas) {
|
|||||||
else {
|
else {
|
||||||
UI.endClosing(gc, delta)
|
UI.endClosing(gc, delta)
|
||||||
isClosing = false
|
isClosing = false
|
||||||
|
isOpening = false
|
||||||
isOpened = false
|
isOpened = false
|
||||||
isVisible = false
|
isVisible = false
|
||||||
openCloseCounter = 0
|
openCloseCounter = 0
|
||||||
@@ -113,8 +119,6 @@ constructor(val UI: UICanvas) {
|
|||||||
UIGraphicInstance.clear()
|
UIGraphicInstance.clear()
|
||||||
UIGraphicInstance.font = Terrarum.gameFont
|
UIGraphicInstance.font = Terrarum.gameFont
|
||||||
|
|
||||||
UIGraphicInstance.setAntiAlias(true)
|
|
||||||
|
|
||||||
UI.render(gc, UIGraphicInstance)
|
UI.render(gc, UIGraphicInstance)
|
||||||
if (sbg.currentStateID == Terrarum.SCENE_ID_GAME) {
|
if (sbg.currentStateID == Terrarum.SCENE_ID_GAME) {
|
||||||
ingameGraphics.drawImage(UIDrawnCanvas.getScaledCopy(scale),
|
ingameGraphics.drawImage(UIDrawnCanvas.getScaledCopy(scale),
|
||||||
@@ -151,39 +155,47 @@ constructor(val UI: UICanvas) {
|
|||||||
/**
|
/**
|
||||||
* Send OPEN signal to the attached UI.
|
* Send OPEN signal to the attached UI.
|
||||||
*/
|
*/
|
||||||
fun setAsOpening() {
|
fun setAsOpen() {
|
||||||
if (alwaysVisible) {
|
if (alwaysVisible) {
|
||||||
throw RuntimeException("[UIHandler] Tried to 'open' constant UI")
|
throw RuntimeException("[UIHandler] Tried to 'open' constant UI")
|
||||||
}
|
}
|
||||||
if (!isOpened && !isVisible) {
|
if (!isOpened && !isOpening) {
|
||||||
isOpened = false
|
isOpened = false
|
||||||
isOpening = true
|
isOpening = true
|
||||||
|
isClosing = false
|
||||||
|
isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send CLOSE signal to the attached UI.
|
* Send CLOSE signal to the attached UI.
|
||||||
*/
|
*/
|
||||||
fun setAsClosing() {
|
fun setAsClose() {
|
||||||
if (alwaysVisible) {
|
if (alwaysVisible) {
|
||||||
throw RuntimeException("[UIHandler] Tried to 'close' constant UI")
|
throw RuntimeException("[UIHandler] Tried to 'close' constant UI")
|
||||||
}
|
}
|
||||||
isOpened = false
|
if ((isOpening || isOpened) && !isClosing && isVisible) {
|
||||||
isClosing = true
|
isOpened = false
|
||||||
|
isClosing = true
|
||||||
|
isOpening = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val isClosed: Boolean
|
||||||
|
get() = !isOpened && !isClosing && !isOpening
|
||||||
|
|
||||||
fun toggleOpening() {
|
fun toggleOpening() {
|
||||||
if (alwaysVisible) {
|
if (alwaysVisible) {
|
||||||
throw RuntimeException("[UIHandler] Tried to 'toggle opening of' constant UI")
|
throw RuntimeException("[UIHandler] Tried to 'toggle opening of' constant UI")
|
||||||
}
|
}
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
if (!isClosing) {
|
if (!isClosing) {
|
||||||
setAsClosing()
|
setAsClose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!isOpening) {
|
if (!isOpening) {
|
||||||
setAsOpening()
|
setAsOpen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,55 +207,55 @@ constructor(val UI: UICanvas) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun keyPressed(key: Int, c: Char) {
|
fun keyPressed(key: Int, c: Char) {
|
||||||
if (isVisible && UI is UITypable) {
|
if (isVisible && UI is KeyboardControlled) {
|
||||||
UI.keyPressed(key, c)
|
UI.keyPressed(key, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun keyReleased(key: Int, c: Char) {
|
fun keyReleased(key: Int, c: Char) {
|
||||||
if (isVisible && UI is UITypable) {
|
if (isVisible && UI is KeyboardControlled) {
|
||||||
UI.keyReleased(key, c)
|
UI.keyReleased(key, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
if (isVisible && UI is UIClickable) {
|
if (isVisible && UI is MouseControlled) {
|
||||||
UI.mouseMoved(oldx, oldy, newx, newy)
|
UI.mouseMoved(oldx, oldy, newx, newy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
if (isVisible && UI is UIClickable) {
|
if (isVisible && UI is MouseControlled) {
|
||||||
UI.mouseDragged(oldx, oldy, newx, newy)
|
UI.mouseDragged(oldx, oldy, newx, newy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mousePressed(button: Int, x: Int, y: Int) {
|
fun mousePressed(button: Int, x: Int, y: Int) {
|
||||||
if (isVisible && UI is UIClickable) {
|
if (isVisible && UI is MouseControlled) {
|
||||||
UI.mousePressed(button, x, y)
|
UI.mousePressed(button, x, y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mouseReleased(button: Int, x: Int, y: Int) {
|
fun mouseReleased(button: Int, x: Int, y: Int) {
|
||||||
if (isVisible && UI is UIClickable) {
|
if (isVisible && UI is MouseControlled) {
|
||||||
UI.mouseReleased(button, x, y)
|
UI.mouseReleased(button, x, y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mouseWheelMoved(change: Int) {
|
fun mouseWheelMoved(change: Int) {
|
||||||
if (isVisible && UI is UIClickable) {
|
if (isVisible && UI is MouseControlled) {
|
||||||
UI.mouseWheelMoved(change)
|
UI.mouseWheelMoved(change)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun controllerButtonPressed(controller: Int, button: Int) {
|
fun controllerButtonPressed(controller: Int, button: Int) {
|
||||||
if (isVisible && UI is UIClickable) {
|
if (isVisible && UI is GamepadControlled) {
|
||||||
UI.controllerButtonPressed(controller, button)
|
UI.controllerButtonPressed(controller, button)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun controllerButtonReleased(controller: Int, button: Int) {
|
fun controllerButtonReleased(controller: Int, button: Int) {
|
||||||
if (isVisible && UI is UIClickable) {
|
if (isVisible && UI is GamepadControlled) {
|
||||||
UI.controllerButtonReleased(controller, button)
|
UI.controllerButtonReleased(controller, button)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,29 +13,31 @@ import org.newdawn.slick.Input
|
|||||||
* Created by minjaesong on 16-07-20.
|
* Created by minjaesong on 16-07-20.
|
||||||
*/
|
*/
|
||||||
class UIPieMenu : UICanvas {
|
class UIPieMenu : UICanvas {
|
||||||
private val cellSize = 32
|
private val cellSize = UIQuickBar.CELL_SIZE
|
||||||
|
|
||||||
private val slotCount = UIQuickBar.SLOT_COUNT
|
private val slotCount = UIQuickBar.SLOT_COUNT
|
||||||
private val roundRectRadius = 6
|
|
||||||
|
|
||||||
|
private val slotDistanceFromCentre = cellSize * 2.7
|
||||||
override var width: Int = cellSize * 7
|
override var width: Int = cellSize * 7
|
||||||
override var height: Int = width
|
override var height: Int = width
|
||||||
|
|
||||||
|
override var handler: UIHandler? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In milliseconds
|
* In milliseconds
|
||||||
*/
|
*/
|
||||||
override var openCloseTime: Int = 160
|
override var openCloseTime: Int = 160
|
||||||
override var openCloseTimer: Int = 0
|
override var openCloseTimer: Int = 0
|
||||||
|
get() = handler!!.openCloseCounter
|
||||||
override var handler: UIHandler? = null
|
|
||||||
|
|
||||||
private val smallenSize = 0.93f
|
private val smallenSize = 0.93f
|
||||||
|
|
||||||
var menuSelection: Int = -1
|
var selection: Int = -1
|
||||||
|
|
||||||
override fun update(gc: GameContainer, delta: Int) {
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
if (menuSelection >= 0)
|
if (selection >= 0)
|
||||||
Terrarum.ingame.player.actorValue[AVKey._PLAYER_QUICKBARSEL] =
|
Terrarum.ingame.player.actorValue[AVKey._PLAYER_QUICKBARSEL] =
|
||||||
menuSelection % quickbarSlots
|
selection % slotCount
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(gc: GameContainer, g: Graphics) {
|
override fun render(gc: GameContainer, g: Graphics) {
|
||||||
@@ -45,17 +47,19 @@ class UIPieMenu : UICanvas {
|
|||||||
for (i in 0..slotCount - 1) {
|
for (i in 0..slotCount - 1) {
|
||||||
// set position
|
// set position
|
||||||
val angle = Math.PI * 2.0 * (i.toDouble() / slotCount) + Math.PI // 180 deg monitor-wise
|
val angle = Math.PI * 2.0 * (i.toDouble() / slotCount) + Math.PI // 180 deg monitor-wise
|
||||||
val slotCentrePoint = Vector2(0.0, cellSize * 3.0).setDirection(angle) + centrePoint
|
val slotCentrePoint = Vector2(0.0, slotDistanceFromCentre.toDouble()).setDirection(angle) + centrePoint
|
||||||
|
|
||||||
// draw cells
|
// draw cells
|
||||||
g.color = if (menuSelection == i) Color(0xC0C0C0) else Color(0x404040)
|
val color = if (i == selection)
|
||||||
g.drawImage(ItemSlotImageBuilder.produce(
|
ItemSlotImageBuilder.COLOR_WHITE
|
||||||
if (menuSelection == i)
|
else
|
||||||
ItemSlotImageBuilder.COLOR_WHITE
|
ItemSlotImageBuilder.COLOR_BLACK
|
||||||
|
|
||||||
|
g.drawImage(
|
||||||
|
if (i == selection)
|
||||||
|
ItemSlotImageBuilder.produceLarge(color, i + 1)
|
||||||
else
|
else
|
||||||
ItemSlotImageBuilder.COLOR_BLACK,
|
ItemSlotImageBuilder.produce(color, i + 1),
|
||||||
i + 1
|
|
||||||
),
|
|
||||||
slotCentrePoint.x.toFloat() - (cellSize / 2f),
|
slotCentrePoint.x.toFloat() - (cellSize / 2f),
|
||||||
slotCentrePoint.y.toFloat() - (cellSize / 2f)
|
slotCentrePoint.y.toFloat() - (cellSize / 2f)
|
||||||
)
|
)
|
||||||
@@ -70,38 +74,29 @@ class UIPieMenu : UICanvas {
|
|||||||
val centre = Vector2(Terrarum.WIDTH / 2.0, Terrarum.HEIGHT / 2.0)
|
val centre = Vector2(Terrarum.WIDTH / 2.0, Terrarum.HEIGHT / 2.0)
|
||||||
val deg = (centre - cursorPos).direction.toFloat()
|
val deg = (centre - cursorPos).direction.toFloat()
|
||||||
|
|
||||||
menuSelection = Math.round(deg * slotCount / FastMath.TWO_PI)
|
selection = Math.round(deg * slotCount / FastMath.TWO_PI)
|
||||||
if (menuSelection < 0) menuSelection += 10
|
if (selection < 0) selection += 10
|
||||||
|
|
||||||
|
// TODO add gamepad support
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doOpening(gc: GameContainer, delta: Int) {
|
override fun doOpening(gc: GameContainer, delta: Int) {
|
||||||
if (openCloseTimer < openCloseTime) {
|
handler!!.opacity = openCloseTimer.toFloat() / openCloseTime
|
||||||
openCloseTimer += delta
|
handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity)
|
||||||
|
|
||||||
handler!!.opacity = openCloseTimer.toFloat() / openCloseTime
|
|
||||||
handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doClosing(gc: GameContainer, delta: Int) {
|
override fun doClosing(gc: GameContainer, delta: Int) {
|
||||||
if (openCloseTimer < openCloseTime) {
|
handler!!.opacity = (openCloseTime - openCloseTimer.toFloat()) / openCloseTime
|
||||||
openCloseTimer += delta
|
handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity)
|
||||||
handler!!.isOpened = false
|
|
||||||
|
|
||||||
handler!!.opacity = (openCloseTime - openCloseTimer.toFloat()) / openCloseTime
|
|
||||||
handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun endOpening(gc: GameContainer, delta: Int) {
|
override fun endOpening(gc: GameContainer, delta: Int) {
|
||||||
openCloseTimer = 0
|
|
||||||
handler!!.opacity = 1f
|
handler!!.opacity = 1f
|
||||||
handler!!.scale = 1f
|
handler!!.scale = 1f
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun endClosing(gc: GameContainer, delta: Int) {
|
override fun endClosing(gc: GameContainer, delta: Int) {
|
||||||
openCloseTimer = 0
|
|
||||||
handler!!.opacity = 0f
|
handler!!.opacity = 0f
|
||||||
handler!!.scale = 1f
|
handler!!.scale = 1f
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package net.torvald.terrarum.ui
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import org.newdawn.slick.GameContainer
|
import org.newdawn.slick.GameContainer
|
||||||
import org.newdawn.slick.Graphics
|
import org.newdawn.slick.Graphics
|
||||||
import org.newdawn.slick.Input
|
import org.newdawn.slick.Input
|
||||||
@@ -7,58 +9,87 @@ import org.newdawn.slick.Input
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-07-20.
|
* Created by minjaesong on 16-07-20.
|
||||||
*/
|
*/
|
||||||
class UIQuickBar : UICanvas {
|
class UIQuickBar : UICanvas, MouseControlled {
|
||||||
override var width: Int
|
private val gutter = 8
|
||||||
get() = throw UnsupportedOperationException()
|
override var width: Int = (ItemSlotImageBuilder.slotImageSize + gutter) * SLOT_COUNT
|
||||||
set(value) {
|
override var height: Int = ItemSlotImageBuilder.slotImageSize + 4 + Terrarum.gameFont.lineHeight
|
||||||
}
|
|
||||||
override var height: Int
|
|
||||||
get() = throw UnsupportedOperationException()
|
|
||||||
set(value) {
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* In milliseconds
|
* In milliseconds
|
||||||
*/
|
*/
|
||||||
override var openCloseTime: Int
|
override var openCloseTime: Int = 160
|
||||||
get() = throw UnsupportedOperationException()
|
override var openCloseTimer: Int = 0
|
||||||
set(value) {
|
|
||||||
}
|
private val startPointX = ItemSlotImageBuilder.slotLarge.width / 2
|
||||||
override var openCloseTimer: Int
|
private val startPointY = ItemSlotImageBuilder.slotLarge.height / 2
|
||||||
get() = throw UnsupportedOperationException()
|
|
||||||
set(value) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override var handler: UIHandler? = null
|
override var handler: UIHandler? = null
|
||||||
|
|
||||||
|
private var selection: Int
|
||||||
|
get() = Terrarum.ingame.player.actorValue.getAsInt(AVKey._PLAYER_QUICKBARSEL)!!
|
||||||
|
set(value) { Terrarum.ingame.player.actorValue[AVKey._PLAYER_QUICKBARSEL] = value }
|
||||||
|
|
||||||
override fun update(gc: GameContainer, delta: Int) {
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(gc: GameContainer, g: Graphics) {
|
override fun render(gc: GameContainer, g: Graphics) {
|
||||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
for (i in 0..SLOT_COUNT - 1) {
|
||||||
|
val color = if (i == selection)
|
||||||
|
ItemSlotImageBuilder.COLOR_WHITE
|
||||||
|
else
|
||||||
|
ItemSlotImageBuilder.COLOR_BLACK
|
||||||
|
|
||||||
|
// draw slots
|
||||||
|
g.drawImage(
|
||||||
|
if (i == selection)
|
||||||
|
ItemSlotImageBuilder.produceLarge(color, i + 1)
|
||||||
|
else
|
||||||
|
ItemSlotImageBuilder.produce(color, i + 1),
|
||||||
|
startPointX + (CELL_SIZE + gutter).times(i).toFloat(),
|
||||||
|
startPointY.toFloat()
|
||||||
|
)
|
||||||
|
// draw items
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processInput(input: Input) {
|
override fun processInput(input: Input) {
|
||||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doOpening(gc: GameContainer, delta: Int) {
|
override fun doOpening(gc: GameContainer, delta: Int) {
|
||||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
handler!!.opacity = openCloseTimer.toFloat() / openCloseTime
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doClosing(gc: GameContainer, delta: Int) {
|
override fun doClosing(gc: GameContainer, delta: Int) {
|
||||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
handler!!.opacity = (openCloseTime - openCloseTimer.toFloat()) / openCloseTime
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun endOpening(gc: GameContainer, delta: Int) {
|
override fun endOpening(gc: GameContainer, delta: Int) {
|
||||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
handler!!.opacity = 1f
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun endClosing(gc: GameContainer, delta: Int) {
|
override fun endClosing(gc: GameContainer, delta: Int) {
|
||||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
handler!!.opacity = 0f
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mousePressed(button: Int, x: Int, y: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseReleased(button: Int, x: Int, y: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseWheelMoved(change: Int) {
|
||||||
|
selection = selection.plus(if (change > 1) 1 else if (change < -1) -1 else 0).mod(SLOT_COUNT)
|
||||||
|
if (selection < 0) selection += SLOT_COUNT
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val SLOT_COUNT = 10
|
const val SLOT_COUNT = 10
|
||||||
|
const val CELL_SIZE = 32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.weather
|
|||||||
|
|
||||||
import com.jme3.math.FastMath
|
import com.jme3.math.FastMath
|
||||||
import net.torvald.JsonFetcher
|
import net.torvald.JsonFetcher
|
||||||
|
import net.torvald.colourutil.ColourUtil
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.gamemap.WorldTime
|
import net.torvald.terrarum.gamemap.WorldTime
|
||||||
@@ -93,24 +94,47 @@ object WeatherMixer {
|
|||||||
Light10B(getGradientColour(currentWeather.globalLightColourMap, 0, timeInSec))
|
Light10B(getGradientColour(currentWeather.globalLightColourMap, 0, timeInSec))
|
||||||
|
|
||||||
fun getGradientColour(image: Image, row: Int, timeInSec: Int): Color {
|
fun getGradientColour(image: Image, row: Int, timeInSec: Int): Color {
|
||||||
val gradMapWidth = image.width
|
|
||||||
val phaseThis = Math.round(
|
|
||||||
timeInSec.toFloat() / WorldTime.DAY_LENGTH.toFloat() * gradMapWidth
|
|
||||||
)
|
|
||||||
val phaseNext = (phaseThis + 1) % WorldTime.DAY_LENGTH
|
|
||||||
val dataPointDistance = WorldTime.DAY_LENGTH / image.width
|
val dataPointDistance = WorldTime.DAY_LENGTH / image.width
|
||||||
|
|
||||||
|
val phaseThis: Int = timeInSec / dataPointDistance // x-coord in gradmap
|
||||||
|
val phaseNext: Int = (phaseThis + 1) % image.width
|
||||||
|
|
||||||
val colourThis = image.getColor(phaseThis, row)
|
val colourThis = image.getColor(phaseThis, row)
|
||||||
val colourNext = image.getColor(phaseNext, row)
|
val colourNext = image.getColor(phaseNext, row)
|
||||||
|
|
||||||
// interpolate R, G and B
|
// interpolate R, G and B
|
||||||
val scale = (timeInSec % dataPointDistance).toFloat() / dataPointDistance
|
val scale = (timeInSec % dataPointDistance).toFloat() / dataPointDistance // [0.0, 1.0]
|
||||||
val retColour = Color(0)
|
|
||||||
retColour.r = FastMath.interpolateLinear(scale, colourThis.r, colourNext.r)
|
|
||||||
retColour.g = FastMath.interpolateLinear(scale, colourThis.g, colourNext.g)
|
|
||||||
retColour.b = FastMath.interpolateLinear(scale, colourThis.b, colourNext.b)
|
|
||||||
|
|
||||||
return retColour
|
val r = interpolateLinear(scale, colourThis.red, colourNext.red)
|
||||||
|
val g = interpolateLinear(scale, colourThis.green, colourNext.green)
|
||||||
|
val b = interpolateLinear(scale, colourThis.blue, colourNext.blue)
|
||||||
|
|
||||||
|
val newCol = ColourUtil.toSlickColor(r, g, b)
|
||||||
|
|
||||||
|
/* // very nice monitor code
|
||||||
|
// 65 -> 66 | 300 | 19623 | RGB8(255, 0, 255) -[41%]-> RGB8(193, 97, 23) | * `230`40`160`
|
||||||
|
// ^ step |width| time | colour from scale colour to | output
|
||||||
|
if (dataPointDistance == 300)
|
||||||
|
println("$phaseThis -> $phaseNext | $dataPointDistance | $timeInSec" +
|
||||||
|
" | ${colourThis.toStringRGB()} -[${scale.times(100).toInt()}%]-> ${colourNext.toStringRGB()}" +
|
||||||
|
" | * `$r`$g`$b`")*/
|
||||||
|
|
||||||
|
return newCol
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Color.toStringRGB() = "RGB8(${this.red}, ${this.green}, ${this.blue})"
|
||||||
|
|
||||||
|
fun interpolateLinear(scale: Float, startValue: Int, endValue: Int): Int {
|
||||||
|
if (startValue == endValue) {
|
||||||
|
return startValue
|
||||||
|
}
|
||||||
|
if (scale <= 0f) {
|
||||||
|
return startValue
|
||||||
|
}
|
||||||
|
if (scale >= 1f) {
|
||||||
|
return endValue
|
||||||
|
}
|
||||||
|
return Math.round((1f - scale) * startValue + scale * endValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getWeatherList(classification: String) = weatherList[classification]!!
|
fun getWeatherList(classification: String) = weatherList[classification]!!
|
||||||
|
|||||||
1
work_files/graphics/weathers/.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.{psd,tga,ogg} filter=lfs diff=lfs merge=lfs -text
|
||||||