more pictogrammes
Former-commit-id: 670df70bbed466e56034dbdd33d7a1da31cd88d7 Former-commit-id: 2b106753155be6080d4651acca1981f10d614421
|
Before Width: | Height: | Size: 579 B After Width: | Height: | Size: 18 KiB |
BIN
assets/graphics/gui/monitor_bad.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
assets/graphics/gui/monitor_good.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
assets/graphics/gui/monitor_good_alt_maru.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
1
assets/graphics/gui/quickbar/.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.{psd,tga,ogg} filter=lfs diff=lfs merge=lfs -text
|
||||||
BIN
assets/graphics/sprites/test_player_2_testa.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
1
assets/graphics/terrain/.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.{psd,tga,ogg} filter=lfs diff=lfs merge=lfs -text
|
||||||
|
Before Width: | Height: | Size: 353 KiB After Width: | Height: | Size: 353 KiB |
@@ -2121,7 +2121,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"n": "MENU_LABEL_PRESS_START",
|
"n": "MENU_LABEL_PRESS_START",
|
||||||
"s": "Start drücken"
|
"s": "Drücke Start"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"n": "MENU_LABEL_PRESS_START_CONTINUE",
|
"n": "MENU_LABEL_PRESS_START_CONTINUE",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Creature raw documentation
|
|||||||
## Physical properties ##
|
## Physical properties ##
|
||||||
|
|
||||||
* 1 m = 24 px
|
* 1 m = 24 px
|
||||||
* mult: Multiplier. e.g. 1.0, 0.85, 1.25, ...
|
* mult: Multiplier in pencentage. e.g. 100, 85, 125, ...
|
||||||
|
|
||||||
|name|unit|description|
|
|name|unit|description|
|
||||||
|----|----|-----------|
|
|----|----|-----------|
|
||||||
@@ -15,7 +15,7 @@ Creature raw documentation
|
|||||||
|scale|unit|Creature body scale. Mass/strength/accel/etc. will be changed accordingly, hence the prefix “base” for some raw tokens|
|
|scale|unit|Creature body scale. Mass/strength/accel/etc. will be changed accordingly, hence the prefix “base” for some raw tokens|
|
||||||
|dragcoeff|unit|Drag coefficient|
|
|dragcoeff|unit|Drag coefficient|
|
||||||
|speedmult, accelmult, jumppowermult|array of percentiles (Int)|Variability factor|
|
|speedmult, accelmult, jumppowermult|array of percentiles (Int)|Variability factor|
|
||||||
|physiquemult|mult|Breadth variation for mobs|
|
|scalemult|mult|Breadth variation for mobs|
|
||||||
|
|
||||||
## Creature properties ##
|
## Creature properties ##
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
"jumppowermult": [100,100,100,100,100,100,100],
|
"jumppowermult": [100,100,100,100,100,100,100],
|
||||||
|
|
||||||
"scale": 1.0,
|
"scale": 1.0,
|
||||||
"physiquemult": [100,100,100,100,100,100,100],
|
"scalemult": [100,100,100,100,100,100,100],
|
||||||
|
|
||||||
"encumbrance": 1000,
|
"encumbrance": 1000,
|
||||||
"basedefence": 100,
|
"basedefence": 100,
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package net.torvald
|
package net.torvald
|
||||||
|
|
||||||
import net.torvald.terrarum.Terrarum
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO
|
import javax.imageio.ImageIO
|
||||||
import java.awt.*
|
import java.awt.*
|
||||||
import java.awt.color.ColorSpace
|
import java.awt.color.ColorSpace
|
||||||
|
|||||||
38
src/net/torvald/serialise/ReadGameMapData.kt
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package net.torvald.serialise
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 16-08-24.
|
||||||
|
*/
|
||||||
|
object ReadGameMapData {
|
||||||
|
|
||||||
|
fun InputStream.readRelative(b: ByteArray, off: Int, len: Int): Int {
|
||||||
|
if (b == null) {
|
||||||
|
throw NullPointerException()
|
||||||
|
} else if (off < 0 || len < 0 || len > b.size) {
|
||||||
|
throw IndexOutOfBoundsException()
|
||||||
|
} else if (len == 0) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
var c = read()
|
||||||
|
if (c == -1) {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
b[0] = c.toByte()
|
||||||
|
|
||||||
|
var i = 1
|
||||||
|
try {
|
||||||
|
while (i < len) {
|
||||||
|
c = read()
|
||||||
|
if (c == -1) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
b[i] = c.toByte()
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
} catch (ee: IOException) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package net.torvald.serialise
|
package net.torvald.serialise
|
||||||
|
|
||||||
import net.torvald.terrarum.mapgenerator.MapGenerator
|
import net.torvald.terrarum.mapgenerator.WorldGenerator
|
||||||
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.ItemPropCodex
|
||||||
@@ -29,7 +29,7 @@ object WriteMeta {
|
|||||||
|
|
||||||
val BYTE_NULL: Byte = 0
|
val BYTE_NULL: Byte = 0
|
||||||
|
|
||||||
val terraseed: Long = MapGenerator.SEED
|
val terraseed: Long = WorldGenerator.SEED
|
||||||
val rogueseed: Long = RoguelikeRandomiser.seed
|
val rogueseed: Long = RoguelikeRandomiser.seed
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -48,5 +48,5 @@ class StateFontTester : BasicGameState() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getID(): Int = Terrarum.SCENE_ID_TEST_FONT
|
override fun getID(): Int = Terrarum.STATE_ID_TEST_FONT
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,8 @@ import net.torvald.terrarum.audio.AudioResourceLibrary
|
|||||||
import net.torvald.terrarum.concurrent.ThreadPool
|
import net.torvald.terrarum.concurrent.ThreadPool
|
||||||
import net.torvald.terrarum.gameactors.*
|
import net.torvald.terrarum.gameactors.*
|
||||||
import net.torvald.terrarum.console.Authenticator
|
import net.torvald.terrarum.console.Authenticator
|
||||||
|
import net.torvald.terrarum.console.CommandDict
|
||||||
|
import net.torvald.terrarum.console.SetGlobalLightOverride
|
||||||
import net.torvald.terrarum.gameactors.physicssolver.CollisionSolver
|
import net.torvald.terrarum.gameactors.physicssolver.CollisionSolver
|
||||||
import net.torvald.terrarum.gamecontroller.GameController
|
import net.torvald.terrarum.gamecontroller.GameController
|
||||||
import net.torvald.terrarum.gamecontroller.Key
|
import net.torvald.terrarum.gamecontroller.Key
|
||||||
@@ -16,7 +18,7 @@ import net.torvald.terrarum.gamemap.WorldTime
|
|||||||
import net.torvald.terrarum.mapdrawer.LightmapRenderer
|
import net.torvald.terrarum.mapdrawer.LightmapRenderer
|
||||||
import net.torvald.terrarum.mapdrawer.MapCamera
|
import net.torvald.terrarum.mapdrawer.MapCamera
|
||||||
import net.torvald.terrarum.mapdrawer.MapDrawer
|
import net.torvald.terrarum.mapdrawer.MapDrawer
|
||||||
import net.torvald.terrarum.mapgenerator.MapGenerator
|
import net.torvald.terrarum.mapgenerator.WorldGenerator
|
||||||
import net.torvald.terrarum.mapgenerator.RoguelikeRandomiser
|
import net.torvald.terrarum.mapgenerator.RoguelikeRandomiser
|
||||||
import net.torvald.terrarum.tileproperties.TilePropCodex
|
import net.torvald.terrarum.tileproperties.TilePropCodex
|
||||||
import net.torvald.terrarum.tilestats.TileStats
|
import net.torvald.terrarum.tilestats.TileStats
|
||||||
@@ -94,6 +96,11 @@ constructor() : BasicGameState() {
|
|||||||
|
|
||||||
@Throws(SlickException::class)
|
@Throws(SlickException::class)
|
||||||
override fun init(gameContainer: GameContainer, stateBasedGame: StateBasedGame) {
|
override fun init(gameContainer: GameContainer, stateBasedGame: StateBasedGame) {
|
||||||
|
// state init code. Executed before the game goes into any "state" in states in StateBasedGame.java
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun enter(gc: GameContainer, sbg: StateBasedGame) {
|
||||||
|
// load things when the game entered this "state"
|
||||||
// load necessary shaders
|
// load necessary shaders
|
||||||
shader12BitCol = Shader.makeShader("./assets/4096.vrt", "./assets/4096.frg")
|
shader12BitCol = Shader.makeShader("./assets/4096.vrt", "./assets/4096.frg")
|
||||||
shaderBlurH = Shader.makeShader("./assets/blurH.vrt", "./assets/blur.frg")
|
shaderBlurH = Shader.makeShader("./assets/blurH.vrt", "./assets/blur.frg")
|
||||||
@@ -103,10 +110,10 @@ constructor() : BasicGameState() {
|
|||||||
world = GameWorld(8192, 2048)
|
world = GameWorld(8192, 2048)
|
||||||
|
|
||||||
// generate terrain for the map
|
// generate terrain for the map
|
||||||
MapGenerator.attachMap(world)
|
WorldGenerator.attachMap(world)
|
||||||
MapGenerator.SEED = 0x51621D2
|
WorldGenerator.SEED = 0x51621D2
|
||||||
//mapgenerator.setSeed(new HQRNG().nextLong());
|
//mapgenerator.setSeed(new HQRNG().nextLong());
|
||||||
MapGenerator.generateMap()
|
WorldGenerator.generateMap()
|
||||||
|
|
||||||
|
|
||||||
RoguelikeRandomiser.seed = 0x540198
|
RoguelikeRandomiser.seed = 0x540198
|
||||||
@@ -114,8 +121,8 @@ constructor() : BasicGameState() {
|
|||||||
|
|
||||||
|
|
||||||
// add new player and put it to actorContainer
|
// add new player and put it to actorContainer
|
||||||
player = PBSigrid.create()
|
//player = PBSigrid.create()
|
||||||
//player = PFCynthia.create()
|
player = PBCynthia.create()
|
||||||
//player.setNoClip(true);
|
//player.setNoClip(true);
|
||||||
addActor(player)
|
addActor(player)
|
||||||
|
|
||||||
@@ -159,16 +166,18 @@ constructor() : BasicGameState() {
|
|||||||
|
|
||||||
override fun update(gc: GameContainer, sbg: StateBasedGame, delta: Int) {
|
override fun update(gc: GameContainer, sbg: StateBasedGame, delta: Int) {
|
||||||
UPDATE_DELTA = delta
|
UPDATE_DELTA = delta
|
||||||
|
|
||||||
setAppTitle()
|
setAppTitle()
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
// world-related updates //
|
// world-related updates //
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
world.updateWorldTime(delta)
|
world.updateWorldTime(delta)
|
||||||
WorldSimulator(world, player, delta)
|
WorldSimulator(world, player, delta)
|
||||||
WeatherMixer.update(gc, delta)
|
WeatherMixer.update(gc, delta)
|
||||||
world.globalLight = globalLightByTime.toInt()
|
TileStats.update()
|
||||||
|
if (!(CommandDict["setgl"] as SetGlobalLightOverride).lightOverride)
|
||||||
|
world.globalLight = globalLightByTime.toInt()
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
@@ -178,9 +187,6 @@ constructor() : BasicGameState() {
|
|||||||
uiContainer.forEach { it.processInput(gc.input) }
|
uiContainer.forEach { it.processInput(gc.input) }
|
||||||
|
|
||||||
|
|
||||||
TileStats.update()
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// camera-related updates //
|
// camera-related updates //
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
@@ -213,6 +219,9 @@ constructor() : BasicGameState() {
|
|||||||
// app-related updates //
|
// app-related updates //
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
Terrarum.appgc.setVSync(Terrarum.appgc.fps >= Terrarum.VSYNC_TRIGGER_THRESHOLD)
|
Terrarum.appgc.setVSync(Terrarum.appgc.fps >= Terrarum.VSYNC_TRIGGER_THRESHOLD)
|
||||||
|
|
||||||
|
// determine if lightmap blending should be done
|
||||||
|
Terrarum.gameConfig["smoothlighting"] = KeyToggler.isOn(KEY_LIGHTMAP_SMOOTH)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setAppTitle() {
|
private fun setAppTitle() {
|
||||||
@@ -225,34 +234,41 @@ constructor() : BasicGameState() {
|
|||||||
override fun render(gc: GameContainer, sbg: StateBasedGame, g: Graphics) {
|
override fun render(gc: GameContainer, sbg: StateBasedGame, g: Graphics) {
|
||||||
setBlendNormal()
|
setBlendNormal()
|
||||||
|
|
||||||
// determine if lightmap blending should be done
|
|
||||||
Terrarum.gameConfig["smoothlighting"] = KeyToggler.isOn(KEY_LIGHTMAP_SMOOTH)
|
|
||||||
|
|
||||||
// set antialias as on
|
|
||||||
if (!g.isAntiAlias) g.isAntiAlias = true
|
|
||||||
|
|
||||||
drawSkybox(g)
|
drawSkybox(g)
|
||||||
|
|
||||||
|
|
||||||
|
// make camara work //
|
||||||
// compensate for zoom. UIs have to be treated specially! (see UIHandler)
|
// compensate for zoom. UIs have to be treated specially! (see UIHandler)
|
||||||
g.translate(-MapCamera.cameraX * screenZoom, -MapCamera.cameraY * screenZoom)
|
g.translate(-MapCamera.cameraX * screenZoom, -MapCamera.cameraY * screenZoom)
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
// draw map related stuffs //
|
||||||
|
/////////////////////////////
|
||||||
MapCamera.renderBehind(gc, g)
|
MapCamera.renderBehind(gc, g)
|
||||||
|
|
||||||
// draw actors
|
|
||||||
run {
|
|
||||||
actorContainer.forEach { actor ->
|
|
||||||
if (actor is Visible && actor.inScreen() && actor !is Player) { // if visible and within screen
|
|
||||||
actor.drawBody(gc, g)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
player.drawBody(gc, g)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/////////////////
|
||||||
|
// draw actors //
|
||||||
|
/////////////////
|
||||||
|
actorContainer.forEach { actor ->
|
||||||
|
if (actor is Visible && actor.inScreen() && actor !is Player) { // if visible and within screen
|
||||||
|
actor.drawBody(gc, g)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
player.drawBody(gc, g)
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
// draw map related stuffs //
|
||||||
|
/////////////////////////////
|
||||||
LightmapRenderer.renderLightMap()
|
LightmapRenderer.renderLightMap()
|
||||||
|
|
||||||
MapCamera.renderFront(gc, g)
|
MapCamera.renderFront(gc, g)
|
||||||
MapDrawer.render(gc, g)
|
MapDrawer.render(gc, g)
|
||||||
|
|
||||||
|
|
||||||
setBlendMul()
|
setBlendMul()
|
||||||
MapDrawer.drawEnvOverlay(g)
|
MapDrawer.drawEnvOverlay(g)
|
||||||
|
|
||||||
@@ -260,22 +276,27 @@ constructor() : BasicGameState() {
|
|||||||
LightmapRenderer.draw(g)
|
LightmapRenderer.draw(g)
|
||||||
setBlendNormal()
|
setBlendNormal()
|
||||||
|
|
||||||
// draw actor glows
|
|
||||||
run {
|
|
||||||
actorContainer.forEach { actor ->
|
|
||||||
if (actor is Visible && actor.inScreen() && actor !is Player) { // if visible and within screen
|
|
||||||
actor.drawGlow(gc, g)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
player.drawGlow(gc, g)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//////////////////////
|
||||||
|
// draw actor glows //
|
||||||
|
//////////////////////
|
||||||
|
actorContainer.forEach { actor ->
|
||||||
|
if (actor is Visible && actor.inScreen() && actor !is Player) { // if visible and within screen
|
||||||
|
actor.drawGlow(gc, g)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
player.drawGlow(gc, g)
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////
|
||||||
|
// debug informations //
|
||||||
|
////////////////////////
|
||||||
// draw reference ID if debugWindow is open
|
// draw reference ID if debugWindow is open
|
||||||
if (debugWindow.isVisible) {
|
if (debugWindow.isVisible) {
|
||||||
actorContainer.forEachIndexed { i, actor ->
|
actorContainer.forEachIndexed { i, actor ->
|
||||||
if (actor is Visible) {
|
if (actor is Visible) {
|
||||||
g.color = Color.white
|
g.color = Color.white
|
||||||
g.font = Terrarum.smallNumbers
|
g.font = Terrarum.fontSmallNumbers
|
||||||
g.drawString(
|
g.drawString(
|
||||||
actor.referenceID.toString(),
|
actor.referenceID.toString(),
|
||||||
actor.hitbox.posX.toFloat(),
|
actor.hitbox.posX.toFloat(),
|
||||||
@@ -293,14 +314,18 @@ constructor() : BasicGameState() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// fluidmap debug
|
||||||
|
if (KeyToggler.isOn(Key.F4))
|
||||||
|
WorldSimulator.drawFluidMapDebug(player, g)
|
||||||
|
|
||||||
// draw UIs
|
|
||||||
run {
|
//////////////
|
||||||
uiContainer.forEach { ui -> ui.render(gc, sbg, g) }
|
// draw UIs //
|
||||||
debugWindow.render(gc, sbg, g)
|
//////////////
|
||||||
consoleHandler.render(gc, sbg, g)
|
uiContainer.forEach { ui -> ui.render(gc, sbg, g) }
|
||||||
notifier.render(gc, sbg, g)
|
debugWindow.render(gc, sbg, g)
|
||||||
}
|
consoleHandler.render(gc, sbg, g)
|
||||||
|
notifier.render(gc, sbg, g)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun keyPressed(key: Int, c: Char) {
|
override fun keyPressed(key: Int, c: Char) {
|
||||||
@@ -369,7 +394,7 @@ constructor() : BasicGameState() {
|
|||||||
uiContainer.forEach { it.controllerButtonReleased(controller, button) } // for GamepadControlled UIcanvases
|
uiContainer.forEach { it.controllerButtonReleased(controller, button) } // for GamepadControlled UIcanvases
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getID(): Int = Terrarum.SCENE_ID_GAME
|
override fun getID(): Int = Terrarum.STATE_ID_GAME
|
||||||
|
|
||||||
private fun drawSkybox(g: Graphics) = WeatherMixer.render(g)
|
private fun drawSkybox(g: Graphics) = WeatherMixer.render(g)
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
package net.torvald.terrarum
|
package net.torvald.terrarum
|
||||||
|
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.ui.Typography
|
import net.torvald.terrarum.ui.*
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import org.newdawn.slick.*
|
||||||
import net.torvald.terrarum.ui.UIHandler
|
|
||||||
import net.torvald.terrarum.ui.KeyboardControlled
|
|
||||||
import org.newdawn.slick.Color
|
|
||||||
import org.newdawn.slick.GameContainer
|
|
||||||
import org.newdawn.slick.Graphics
|
|
||||||
import org.newdawn.slick.Input
|
|
||||||
import org.newdawn.slick.state.BasicGameState
|
import org.newdawn.slick.state.BasicGameState
|
||||||
import org.newdawn.slick.state.StateBasedGame
|
import org.newdawn.slick.state.StateBasedGame
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-07-06.
|
* Created by minjaesong on 16-07-06.
|
||||||
@@ -35,7 +30,7 @@ class StateMonitorCheck : BasicGameState() {
|
|||||||
//uiMonitorCheck.setAsClose()
|
//uiMonitorCheck.setAsClose()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getID(): Int = Terrarum.SCENE_ID_CONFIG_CALIBRATE
|
override fun getID(): Int = Terrarum.STATE_ID_CONFIG_CALIBRATE
|
||||||
|
|
||||||
class MonitorCheckUI : UICanvas {
|
class MonitorCheckUI : UICanvas {
|
||||||
override var width = Terrarum.WIDTH
|
override var width = Terrarum.WIDTH
|
||||||
@@ -44,6 +39,8 @@ class StateMonitorCheck : BasicGameState() {
|
|||||||
|
|
||||||
override var handler: UIHandler? = null
|
override var handler: UIHandler? = null
|
||||||
|
|
||||||
|
private val backgroundCol = Color(0x404040)
|
||||||
|
|
||||||
private val colourLUT = arrayOf(
|
private val colourLUT = arrayOf(
|
||||||
0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38, 0x40,
|
0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38, 0x40,
|
||||||
0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x78, 0x80,
|
0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x78, 0x80,
|
||||||
@@ -51,13 +48,29 @@ class StateMonitorCheck : BasicGameState() {
|
|||||||
0xC8, 0xD0, 0xD8, 0xE0, 0xE8, 0xF0, 0xF8, 0xFF
|
0xC8, 0xD0, 0xD8, 0xE0, 0xE8, 0xF0, 0xF8, 0xFF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val pictograms = ArrayList<Image>()
|
||||||
|
lateinit var imageGallery: ItemImageGallery
|
||||||
|
|
||||||
|
val instructionY = Terrarum.HEIGHT / 2//Terrarum.HEIGHT * 9 / 16
|
||||||
|
val anykeyY = Terrarum.HEIGHT * 15 / 16
|
||||||
|
|
||||||
|
val maru_alt = Regex("CN|JP|K[RP]|TW")
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (Terrarum.gameLocale.length >= 4 && Terrarum.gameLocale.contains(maru_alt))
|
||||||
|
pictograms.add(Image("./assets/graphics/gui/monitor_good_alt_maru.png"))
|
||||||
|
else
|
||||||
|
pictograms.add(Image("./assets/graphics/gui/monitor_good.png"))
|
||||||
|
pictograms.add(Image("./assets/graphics/gui/monitor_bad.png"))
|
||||||
|
|
||||||
|
imageGallery = ItemImageGallery(0, instructionY, Terrarum.WIDTH, anykeyY - instructionY, pictograms)
|
||||||
|
}
|
||||||
|
|
||||||
override fun update(gc: GameContainer, delta: Int) {
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(gc: GameContainer, g: Graphics) {
|
override fun render(gc: GameContainer, g: Graphics) {
|
||||||
val titleY = Terrarum.HEIGHT * 7 / 16
|
val titleY = Terrarum.HEIGHT * 7 / 16
|
||||||
val instructionY = Terrarum.HEIGHT * 9 / 16
|
|
||||||
val anykeyY = Terrarum.HEIGHT * 15 / 16
|
|
||||||
|
|
||||||
val barWidthAll = Terrarum.WIDTH.div(100).times(100) * 9 / 10
|
val barWidthAll = Terrarum.WIDTH.div(100).times(100) * 9 / 10
|
||||||
val barWidth: Int = barWidthAll / 32 + 1
|
val barWidth: Int = barWidthAll / 32 + 1
|
||||||
@@ -77,7 +90,7 @@ class StateMonitorCheck : BasicGameState() {
|
|||||||
|
|
||||||
// bar start point indicator
|
// bar start point indicator
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
g.color = Color(0x404040)
|
g.color = backgroundCol
|
||||||
g.drawLine(
|
g.drawLine(
|
||||||
barXstart.toFloat(), barYstart - barNumberGap - labelH.toFloat(),
|
barXstart.toFloat(), barYstart - barNumberGap - labelH.toFloat(),
|
||||||
barXstart.toFloat(), barYstart - barNumberGap.toFloat()
|
barXstart.toFloat(), barYstart - barNumberGap.toFloat()
|
||||||
@@ -105,7 +118,7 @@ class StateMonitorCheck : BasicGameState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// messages background
|
// messages background
|
||||||
g.color = Color(0x404040)
|
g.color = backgroundCol
|
||||||
g.fillRect(
|
g.fillRect(
|
||||||
0f, Terrarum.HEIGHT.shr(1).toFloat(),
|
0f, Terrarum.HEIGHT.shr(1).toFloat(),
|
||||||
Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.shr(1).plus(1).toFloat()
|
Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.shr(1).plus(1).toFloat()
|
||||||
@@ -119,14 +132,20 @@ class StateMonitorCheck : BasicGameState() {
|
|||||||
this
|
this
|
||||||
)
|
)
|
||||||
|
|
||||||
(1..12).forEach {
|
// message text
|
||||||
|
/*(1..12).forEach {
|
||||||
Typography.printCentered(
|
Typography.printCentered(
|
||||||
g, Lang["MENU_MONITOR_CALI_LABEL_$it"],
|
g, Lang["MENU_MONITOR_CALI_LABEL_$it"],
|
||||||
instructionY + it.minus(2).times(g.font.lineHeight),
|
instructionY + it.minus(2).times(g.font.lineHeight),
|
||||||
this
|
this
|
||||||
)
|
)
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
// message pictogram
|
||||||
|
imageGallery.render(gc, g)
|
||||||
|
|
||||||
|
|
||||||
|
// anykey
|
||||||
Typography.printCentered(
|
Typography.printCentered(
|
||||||
g, Lang["MENU_LABEL_PRESS_ANYKEY_CONTINUE"],
|
g, Lang["MENU_LABEL_PRESS_ANYKEY_CONTINUE"],
|
||||||
anykeyY,
|
anykeyY,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import net.torvald.terrarum.gameactors.roundInt
|
|||||||
import net.torvald.terrarum.gamecontroller.Key
|
import net.torvald.terrarum.gamecontroller.Key
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.ui.DrawUtil
|
import net.torvald.terrarum.ui.DrawUtil
|
||||||
|
import net.torvald.terrarum.ui.ItemImageGallery
|
||||||
import net.torvald.terrarum.ui.Typography
|
import net.torvald.terrarum.ui.Typography
|
||||||
import org.newdawn.slick.Color
|
import org.newdawn.slick.Color
|
||||||
import org.newdawn.slick.GameContainer
|
import org.newdawn.slick.GameContainer
|
||||||
@@ -37,13 +38,16 @@ class StateSplash : BasicGameState() {
|
|||||||
|
|
||||||
val backgroundColour = Color(0x303030)
|
val backgroundColour = Color(0x303030)
|
||||||
|
|
||||||
var delta = 0
|
|
||||||
val deltathre = 500
|
val deltathre = 500
|
||||||
|
|
||||||
val auto_dismiss = 5000
|
val auto_dismiss = 6500
|
||||||
|
|
||||||
var opened = false
|
var opened = false
|
||||||
|
|
||||||
|
var init = false
|
||||||
|
|
||||||
|
lateinit var imageGallery: ItemImageGallery
|
||||||
|
|
||||||
override fun init(container: GameContainer?, game: StateBasedGame?) {
|
override fun init(container: GameContainer?, game: StateBasedGame?) {
|
||||||
// pre-load lang
|
// pre-load lang
|
||||||
Lang["MENU_LANGUAGE_THIS"]
|
Lang["MENU_LANGUAGE_THIS"]
|
||||||
@@ -53,19 +57,24 @@ class StateSplash : BasicGameState() {
|
|||||||
|
|
||||||
fadeSheet = Image(Terrarum.WIDTH, Terrarum.HEIGHT)
|
fadeSheet = Image(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||||
thisG = fadeSheet.graphics
|
thisG = fadeSheet.graphics
|
||||||
thisG.font = Terrarum.gameFont
|
thisG.font = Terrarum.fontGame
|
||||||
|
|
||||||
|
imageBoardHeight = Terrarum.HEIGHT - thisG.font.lineHeight.times(6)
|
||||||
|
imageBoardOffset = thisG.font.lineHeight.times(3)
|
||||||
|
|
||||||
|
imageGallery = ItemImageGallery(0, imageBoardOffset, Terrarum.WIDTH, imageBoardHeight, pictogramCollection)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun update(container: GameContainer, game: StateBasedGame, delta: Int) {
|
override fun update(container: GameContainer, game: StateBasedGame, delta: Int) {
|
||||||
this.delta = delta
|
|
||||||
|
|
||||||
// next splash or load next scene
|
// next splash or load next scene
|
||||||
if (anykey_hit && opacity == 0f) {
|
if (anykey_hit && opened) {
|
||||||
System.exit(0)
|
game.enterState(Terrarum.STATE_ID_GAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fade-in
|
// fade-in
|
||||||
if (delta < deltathre) {
|
if (delta < deltathre) {
|
||||||
|
init = true
|
||||||
|
|
||||||
if (opacity < 1f && !anykey_hit) {
|
if (opacity < 1f && !anykey_hit) {
|
||||||
opacity = FastMath.interpolateLinear(
|
opacity = FastMath.interpolateLinear(
|
||||||
fadeTimer.toFloat() / fadeTime, 0f, 1f
|
fadeTimer.toFloat() / fadeTime, 0f, 1f
|
||||||
@@ -85,18 +94,15 @@ class StateSplash : BasicGameState() {
|
|||||||
|
|
||||||
// auto dismiss
|
// auto dismiss
|
||||||
if (opened && fadeTimer >= auto_dismiss)
|
if (opened && fadeTimer >= auto_dismiss)
|
||||||
doAnykeyThingy()
|
//doAnykeyThingy()
|
||||||
|
|
||||||
fadeTimer += delta
|
fadeTimer += delta
|
||||||
|
println(fadeTimer)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getID(): Int = Terrarum.SCENE_ID_SPLASH
|
override fun getID(): Int = Terrarum.STATE_ID_SPLASH
|
||||||
|
|
||||||
override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics) {
|
|
||||||
|
|
||||||
imageBoardHeight = Terrarum.HEIGHT - thisG.font.lineHeight.times(6)
|
|
||||||
imageBoardOffset = thisG.font.lineHeight.times(3)
|
|
||||||
|
|
||||||
|
override fun render(container: GameContainer, game: StateBasedGame, g: Graphics) {
|
||||||
thisG.color = backgroundColour
|
thisG.color = backgroundColour
|
||||||
thisG.fillRect(0f, 0f, fadeSheet.width.toFloat(), fadeSheet.height.toFloat())
|
thisG.fillRect(0f, 0f, fadeSheet.width.toFloat(), fadeSheet.height.toFloat())
|
||||||
|
|
||||||
@@ -108,9 +114,7 @@ class StateSplash : BasicGameState() {
|
|||||||
Typography.printCentered(thisG, Lang["MENU_LABEL_PRESS_ANYKEY_CONTINUE"],
|
Typography.printCentered(thisG, Lang["MENU_LABEL_PRESS_ANYKEY_CONTINUE"],
|
||||||
Terrarum.HEIGHT - thisG.font.lineHeight.times(3))
|
Terrarum.HEIGHT - thisG.font.lineHeight.times(3))
|
||||||
|
|
||||||
pictogramCollection.forEachIndexed { i, image ->
|
imageGallery.render(container, thisG)
|
||||||
DrawUtil.drawCentered(thisG, image, knowYourPlace(i) + imageBoardOffset)
|
|
||||||
}
|
|
||||||
|
|
||||||
g.drawImage(fadeSheet, 0f, 0f, Color(1f, 1f, 1f, opacity))
|
g.drawImage(fadeSheet, 0f, 0f, Color(1f, 1f, 1f, opacity))
|
||||||
}
|
}
|
||||||
@@ -131,7 +135,7 @@ class StateSplash : BasicGameState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun doAnykeyThingy() {
|
private fun doAnykeyThingy() {
|
||||||
if (delta < deltathre && !anykey_hit) {
|
if (!anykey_hit) {
|
||||||
anykey_hit = true
|
anykey_hit = true
|
||||||
fadeTimer = 0
|
fadeTimer = 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ import java.util.logging.SimpleFormatter
|
|||||||
class Terrarum @Throws(SlickException::class)
|
class Terrarum @Throws(SlickException::class)
|
||||||
constructor(gamename: String) : StateBasedGame(gamename) {
|
constructor(gamename: String) : StateBasedGame(gamename) {
|
||||||
|
|
||||||
|
// these properties goes into the GameContainer
|
||||||
|
|
||||||
|
var previousState: Int? = null // to be used with temporary states like StateMonitorCheck
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
||||||
gameConfig = GameConfig()
|
gameConfig = GameConfig()
|
||||||
@@ -63,8 +67,8 @@ constructor(gamename: String) : StateBasedGame(gamename) {
|
|||||||
override fun initStatesList(gc: GameContainer) {
|
override fun initStatesList(gc: GameContainer) {
|
||||||
gc.input.enableKeyRepeat()
|
gc.input.enableKeyRepeat()
|
||||||
|
|
||||||
gameFont = GameFontWhite()
|
fontGame = GameFontWhite()
|
||||||
smallNumbers = TinyAlphNum()
|
fontSmallNumbers = TinyAlphNum()
|
||||||
|
|
||||||
hasController = gc.input.controllerCount > 0
|
hasController = gc.input.controllerCount > 0
|
||||||
if (hasController) {
|
if (hasController) {
|
||||||
@@ -75,11 +79,11 @@ constructor(gamename: String) : StateBasedGame(gamename) {
|
|||||||
|
|
||||||
gc.graphics.clear() // clean up any 'dust' in the buffer
|
gc.graphics.clear() // clean up any 'dust' in the buffer
|
||||||
|
|
||||||
ingame = StateInGame()
|
//addState(StateSplash())
|
||||||
//addState(ingame)
|
addState(StateMonitorCheck())
|
||||||
//addState(StateMonitorCheck())
|
|
||||||
//addState(StateFontTester())
|
//addState(StateFontTester())
|
||||||
addState(StateSplash())
|
ingame = StateInGame()
|
||||||
|
addState(ingame)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -137,20 +141,20 @@ constructor(gamename: String) : StateBasedGame(gamename) {
|
|||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
lateinit var gameFont: Font
|
lateinit var fontGame: Font
|
||||||
private set
|
private set
|
||||||
lateinit var smallNumbers: Font
|
lateinit var fontSmallNumbers: Font
|
||||||
private set
|
private set
|
||||||
|
|
||||||
// 0x0 - 0xF: Game-related
|
// 0x0 - 0xF: Game-related
|
||||||
// 0x10 - 0x1F: Config
|
// 0x10 - 0x1F: Config
|
||||||
// 0x100 and onward: unit tests for dev
|
// 0x100 and onward: unit tests for dev
|
||||||
val SCENE_ID_SPLASH = 0x0
|
val STATE_ID_SPLASH = 0x0
|
||||||
val SCENE_ID_HOME = 0x1
|
val STATE_ID_HOME = 0x1
|
||||||
val SCENE_ID_GAME = 0x3
|
val STATE_ID_GAME = 0x3
|
||||||
val SCENE_ID_CONFIG_CALIBRATE = 0x11
|
val STATE_ID_CONFIG_CALIBRATE = 0x11
|
||||||
|
|
||||||
val SCENE_ID_TEST_FONT = 0x100
|
val STATE_ID_TEST_FONT = 0x100
|
||||||
|
|
||||||
var hasController = false
|
var hasController = false
|
||||||
val CONTROLLER_DEADZONE = 0.1f
|
val CONTROLLER_DEADZONE = 0.1f
|
||||||
@@ -367,7 +371,7 @@ fun main(args: Array<String>) = Terrarum.main(args)
|
|||||||
|
|
||||||
fun setBlendMul() {
|
fun setBlendMul() {
|
||||||
GL11.glEnable(GL11.GL_BLEND)
|
GL11.glEnable(GL11.GL_BLEND)
|
||||||
GL11.glColorMask(true, true, true, false)
|
GL11.glColorMask(true, true, true, true)
|
||||||
GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_ONE_MINUS_SRC_ALPHA)
|
GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_ONE_MINUS_SRC_ALPHA)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ object CommandDict {
|
|||||||
Pair("tp", TeleportPlayer()),
|
Pair("tp", TeleportPlayer()),
|
||||||
Pair("cat", CatStdout()),
|
Pair("cat", CatStdout()),
|
||||||
Pair("exportav", ExportAV()),
|
Pair("exportav", ExportAV()),
|
||||||
Pair("setgl", SetGlobalLightLevel()),
|
Pair("setgl", SetGlobalLightOverride()),
|
||||||
Pair("getfaction", GetFactioning()),
|
Pair("getfaction", GetFactioning()),
|
||||||
Pair("auth", Terrarum.ingame.auth),
|
Pair("auth", Terrarum.ingame.auth),
|
||||||
Pair("spawnball", SpawnPhysTestBall()),
|
Pair("spawnball", SpawnPhysTestBall()),
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ import net.torvald.terrarum.Terrarum
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-02-17.
|
* Created by minjaesong on 16-02-17.
|
||||||
*/
|
*/
|
||||||
class SetGlobalLightLevel : ConsoleCommand {
|
class SetGlobalLightOverride : ConsoleCommand {
|
||||||
|
|
||||||
|
var lightOverride = false
|
||||||
|
private set
|
||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 4) {
|
if (args.size == 4) {
|
||||||
try {
|
try {
|
||||||
@@ -15,6 +19,7 @@ class SetGlobalLightLevel : ConsoleCommand {
|
|||||||
val b = args[3].toInt()
|
val b = args[3].toInt()
|
||||||
val GL = LightmapRenderer.constructRGBFromInt(r, g, b)
|
val GL = LightmapRenderer.constructRGBFromInt(r, g, b)
|
||||||
|
|
||||||
|
lightOverride = true
|
||||||
Terrarum.ingame.world.globalLight = GL
|
Terrarum.ingame.world.globalLight = GL
|
||||||
}
|
}
|
||||||
catch (e: NumberFormatException) {
|
catch (e: NumberFormatException) {
|
||||||
@@ -37,7 +42,10 @@ class SetGlobalLightLevel : ConsoleCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e: NumberFormatException) {
|
catch (e: NumberFormatException) {
|
||||||
Echo().execute("Wrong number input.")
|
if (args[1].toLowerCase() == "none")
|
||||||
|
lightOverride = false
|
||||||
|
else
|
||||||
|
Echo().execute("Wrong number input.")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -47,6 +55,6 @@ class SetGlobalLightLevel : ConsoleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun printUsage() {
|
override fun printUsage() {
|
||||||
Echo().execute("Usage: setgl [raw_value|r g b]")
|
Echo().execute("Usage: setgl [raw_value|r g b|“none”]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ abstract class Actor : Comparable<Actor>, Runnable {
|
|||||||
"ID: ${hashCode()} (${actorValue.getAsString(AVKey.NAME)})"
|
"ID: ${hashCode()} (${actorValue.getAsString(AVKey.NAME)})"
|
||||||
override fun compareTo(other: Actor): Int = (this.referenceID - other.referenceID).sign()
|
override fun compareTo(other: Actor): Int = (this.referenceID - other.referenceID).sign()
|
||||||
|
|
||||||
fun Int.sign(): Int = if (this > 0) 1 else if (this < 0) -1 else this
|
fun Int.sign(): Int = if (this > 0) 1 else if (this < 0) -1 else 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage:
|
* Usage:
|
||||||
|
|||||||
@@ -769,7 +769,7 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
Hitbox(nextHitbox.posX, nextHitbox.posY,
|
Hitbox(nextHitbox.posX, nextHitbox.posY,
|
||||||
nextHitbox.width + 2.0, nextHitbox.height + 2.0)
|
nextHitbox.width + 2.0, nextHitbox.height + 2.0)
|
||||||
// when not walking, enlarge the hitbox for calculation so that
|
// when not walking, enlarge the hitbox for calculation so that
|
||||||
// feet tiles are to be taken into calculation
|
// feet tiles are also counted
|
||||||
else
|
else
|
||||||
nextHitbox.clone()
|
nextHitbox.clone()
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.security.SecureRandom
|
|||||||
*/
|
*/
|
||||||
object CreatureRawInjector {
|
object CreatureRawInjector {
|
||||||
|
|
||||||
const val JSONPATH = "./res/raw/creatures/"
|
const val JSONPATH = "./assets/raw/creatures/"
|
||||||
private const val MULTIPLIER_RAW_ELEM_SUFFIX = AVKey.MULT
|
private const val MULTIPLIER_RAW_ELEM_SUFFIX = AVKey.MULT
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,12 +26,14 @@ object CreatureRawInjector {
|
|||||||
fun inject(actorValueRef: ActorValue, jsonFileName: String) {
|
fun inject(actorValueRef: ActorValue, jsonFileName: String) {
|
||||||
val jsonObj = JsonFetcher(JSONPATH + jsonFileName)
|
val jsonObj = JsonFetcher(JSONPATH + jsonFileName)
|
||||||
|
|
||||||
|
val elementsInt = arrayOf(AVKey.BASEHEIGHT, AVKey.TOOLSIZE, AVKey.ENCUMBRANCE)
|
||||||
val elementsString = arrayOf(AVKey.RACENAME, AVKey.RACENAMEPLURAL)
|
val elementsString = arrayOf(AVKey.RACENAME, AVKey.RACENAMEPLURAL)
|
||||||
val elementsDouble = arrayOf(AVKey.BASEHEIGHT, AVKey.BASEMASS, AVKey.ACCEL, AVKey.TOOLSIZE, AVKey.ENCUMBRANCE)
|
val elementsDouble = arrayOf(AVKey.BASEMASS, AVKey.ACCEL)
|
||||||
val elementsDoubleVariable = arrayOf(AVKey.STRENGTH, AVKey.SPEED, AVKey.JUMPPOWER, AVKey.SCALE, AVKey.SPEED)
|
val elementsDoubleVariable = arrayOf(AVKey.STRENGTH, AVKey.SPEED, AVKey.JUMPPOWER, AVKey.SCALE)
|
||||||
val elementsBoolean = arrayOf(AVKey.INTELLIGENT)
|
val elementsBoolean = arrayOf(AVKey.INTELLIGENT)
|
||||||
// val elementsMultiplyFromOne = arrayOf()
|
// val elementsMultiplyFromOne = arrayOf()
|
||||||
|
|
||||||
|
setAVInts(actorValueRef, elementsInt, jsonObj)
|
||||||
setAVStrings(actorValueRef, elementsString, jsonObj)
|
setAVStrings(actorValueRef, elementsString, jsonObj)
|
||||||
setAVDoubles(actorValueRef, elementsDouble, jsonObj)
|
setAVDoubles(actorValueRef, elementsDouble, jsonObj)
|
||||||
setAVDoublesVariable(actorValueRef, elementsDoubleVariable, jsonObj)
|
setAVDoublesVariable(actorValueRef, elementsDoubleVariable, jsonObj)
|
||||||
@@ -93,6 +95,20 @@ object CreatureRawInjector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch and set int actor values
|
||||||
|
* @param avRef
|
||||||
|
* *
|
||||||
|
* @param elemSet
|
||||||
|
* *
|
||||||
|
* @param jsonObject
|
||||||
|
*/
|
||||||
|
private fun setAVInts(avRef: ActorValue, elemSet: Array<String>, jsonObject: JsonObject) {
|
||||||
|
for (s in elemSet) {
|
||||||
|
avRef[s] = jsonObject.get(s).asInt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch and set actor values that should multiplier be applied to the base value of 1.
|
* Fetch and set actor values that should multiplier be applied to the base value of 1.
|
||||||
* E.g. physiquemult
|
* E.g. physiquemult
|
||||||
|
|||||||
@@ -12,8 +12,10 @@ object PBCynthia {
|
|||||||
val p: Player = Player()
|
val p: Player = Player()
|
||||||
CreatureRawInjector.inject(p.actorValue, "CreatureHuman.json")
|
CreatureRawInjector.inject(p.actorValue, "CreatureHuman.json")
|
||||||
|
|
||||||
|
p.actorValue[AVKey._PLAYER_QUICKBARSEL] = 0
|
||||||
p.actorValue["selectedtile"] = 16
|
p.actorValue["selectedtile"] = 16
|
||||||
|
|
||||||
|
|
||||||
p.sprite = SpriteAnimation()
|
p.sprite = SpriteAnimation()
|
||||||
p.sprite!!.setDimension(26, 42)
|
p.sprite!!.setDimension(26, 42)
|
||||||
p.sprite!!.setSpriteImage("assets/graphics/sprites/test_player_2.png")
|
p.sprite!!.setSpriteImage("assets/graphics/sprites/test_player_2.png")
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ object PBSigrid {
|
|||||||
p.actorValue[AVKey.BASEDEFENCE] = 141
|
p.actorValue[AVKey.BASEDEFENCE] = 141
|
||||||
|
|
||||||
p.actorValue["selectedtile"] = 16
|
p.actorValue["selectedtile"] = 16
|
||||||
p.actorValue[AVKey._PLAYER_QUICKBARSEL] = 0
|
|
||||||
|
|
||||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT)!!, 10, 0)
|
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT)!!, 10, 0)
|
||||||
|
|
||||||
|
|||||||
@@ -172,14 +172,14 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
|
|
||||||
walkCounterX += 1
|
walkCounterX += 1
|
||||||
|
|
||||||
// Heading flag
|
|
||||||
if (left)
|
|
||||||
walkHeading = LEFT
|
|
||||||
else
|
|
||||||
walkHeading = RIGHT
|
|
||||||
|
|
||||||
isWalkingH = true
|
isWalkingH = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Heading flag
|
||||||
|
if (left)
|
||||||
|
walkHeading = LEFT
|
||||||
|
else
|
||||||
|
walkHeading = RIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
9
src/net/torvald/terrarum/gamemap/FluidCodex.kt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package net.torvald.terrarum.gamemap
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 16-08-06.
|
||||||
|
*/
|
||||||
|
object FluidCodex {
|
||||||
|
const val FLUID_LAVA = 0xFE.toByte()
|
||||||
|
const val FLUID_WATER = 0xFF.toByte()
|
||||||
|
}
|
||||||
@@ -40,7 +40,7 @@ class MapLayer(var width: Int, var height: Int) : Iterable<Byte> {
|
|||||||
return if (x !in 0..width - 1 || y !in 0..height - 1)
|
return if (x !in 0..width - 1 || y !in 0..height - 1)
|
||||||
null
|
null
|
||||||
else
|
else
|
||||||
uint8ToInt32(data[y][x])
|
data[y][x].toUint()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun setTile(x: Int, y: Int, tile: Byte) {
|
internal fun setTile(x: Int, y: Int, tile: Byte) {
|
||||||
@@ -49,11 +49,10 @@ class MapLayer(var width: Int, var height: Int) : Iterable<Byte> {
|
|||||||
|
|
||||||
fun isInBound(x: Int, y: Int) = (x >= 0 && y >= 0 && x < width && y < height)
|
fun isInBound(x: Int, y: Int) = (x >= 0 && y >= 0 && x < width && y < height)
|
||||||
|
|
||||||
private fun uint8ToInt32(x: Byte): Int = java.lang.Byte.toUnsignedInt(x)
|
|
||||||
|
|
||||||
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, ...
|
@Transient const val SIZEOF: Byte = 1 // 1 for 8-bit, 2 for 16-bit, ...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Byte.toUint() = java.lang.Byte.toUnsignedInt(this)
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
package net.torvald.terrarum.gamemap
|
package net.torvald.terrarum.gamemap
|
||||||
|
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.gameactors.Player
|
import net.torvald.terrarum.gameactors.Player
|
||||||
import net.torvald.terrarum.gameactors.roundInt
|
import net.torvald.terrarum.gameactors.roundInt
|
||||||
|
import net.torvald.terrarum.gamemap.WorldSimulator.isSolid
|
||||||
|
import net.torvald.terrarum.mapdrawer.MapCamera
|
||||||
import net.torvald.terrarum.mapdrawer.MapDrawer
|
import net.torvald.terrarum.mapdrawer.MapDrawer
|
||||||
import net.torvald.terrarum.tileproperties.TileNameCode
|
import net.torvald.terrarum.tileproperties.TileNameCode
|
||||||
import net.torvald.terrarum.tileproperties.TilePropCodex
|
import net.torvald.terrarum.tileproperties.TilePropCodex
|
||||||
|
import org.newdawn.slick.Color
|
||||||
import org.newdawn.slick.Graphics
|
import org.newdawn.slick.Graphics
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,16 +20,31 @@ object WorldSimulator {
|
|||||||
* In tiles;
|
* In tiles;
|
||||||
* square width/height = field * 2
|
* square width/height = field * 2
|
||||||
*/
|
*/
|
||||||
const val FLUID_UPDATING_SQUARE_RADIUS = 128
|
const val FLUID_UPDATING_SQUARE_RADIUS = 64 // larger value will have dramatic impact on performance
|
||||||
const private val DOUBLE_RADIUS = FLUID_UPDATING_SQUARE_RADIUS * 2
|
const private val DOUBLE_RADIUS = FLUID_UPDATING_SQUARE_RADIUS * 2
|
||||||
|
|
||||||
private val fluidMap = Array<IntArray>(DOUBLE_RADIUS, { IntArray(DOUBLE_RADIUS) })
|
private val fluidMap = Array<IntArray>(DOUBLE_RADIUS, { IntArray(DOUBLE_RADIUS) })
|
||||||
|
private val fluidTypeMap = Array<ByteArray>(DOUBLE_RADIUS, { ByteArray(DOUBLE_RADIUS) })
|
||||||
|
|
||||||
const val DISPLACE_CAP = 4
|
const val DISPLACE_CAP = 4
|
||||||
const val FLUID_MAX = 16
|
const val FLUID_MAX = 16
|
||||||
|
|
||||||
|
var updateXFrom = 0
|
||||||
|
var updateXTo = 0
|
||||||
|
var updateYFrom = 0
|
||||||
|
var updateYTo = 0
|
||||||
|
|
||||||
|
val colourNone = Color(0x808080)
|
||||||
|
val colourWater = Color(0x66BBFF)
|
||||||
|
|
||||||
operator fun invoke(world: GameWorld, p: Player, delta: Int) {
|
operator fun invoke(world: GameWorld, p: Player, delta: Int) {
|
||||||
|
updateXFrom = p.hitbox.centeredX.div(MapDrawer.TILE_SIZE).minus(FLUID_UPDATING_SQUARE_RADIUS).roundInt()
|
||||||
|
updateYFrom = p.hitbox.centeredY.div(MapDrawer.TILE_SIZE).minus(FLUID_UPDATING_SQUARE_RADIUS).roundInt()
|
||||||
|
updateXTo = updateXFrom + DOUBLE_RADIUS
|
||||||
|
updateYTo = updateYFrom + DOUBLE_RADIUS
|
||||||
|
|
||||||
moveFluids(world, p, delta)
|
moveFluids(world, p, delta)
|
||||||
|
displaceFallables(world, p, delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,148 +53,169 @@ object WorldSimulator {
|
|||||||
* reverse-gravity.
|
* reverse-gravity.
|
||||||
*/
|
*/
|
||||||
fun moveFluids(world: GameWorld, p: Player, delta: Int) {
|
fun moveFluids(world: GameWorld, p: Player, delta: Int) {
|
||||||
val updateXFrom = p.hitbox.centeredX.div(MapDrawer.TILE_SIZE).minus(FLUID_UPDATING_SQUARE_RADIUS).roundInt()
|
////////////////////
|
||||||
val updateYFrom = p.hitbox.centeredY.div(MapDrawer.TILE_SIZE).minus(FLUID_UPDATING_SQUARE_RADIUS).roundInt()
|
// build fluidmap //
|
||||||
val updateXTo = updateXFrom + 1 * FLUID_UPDATING_SQUARE_RADIUS
|
////////////////////
|
||||||
val updateYTo = updateYFrom + 1 * FLUID_UPDATING_SQUARE_RADIUS
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return amount of fluid actually drained.
|
|
||||||
* (intended drainage - this) will give you how much fluid is not yet drained.
|
|
||||||
*/
|
|
||||||
fun drain(x: Int, y: Int, amount: Int): Int {
|
|
||||||
val displacement = Math.min(fluidMap[y - updateYFrom][x - updateXFrom], amount)
|
|
||||||
|
|
||||||
fluidMap[y - updateYFrom][x - updateXFrom] -= displacement
|
|
||||||
|
|
||||||
return displacement
|
|
||||||
}
|
|
||||||
|
|
||||||
fun pour(x: Int, y: Int, amount: Int) {
|
|
||||||
fun pourInternal(xpos: Int, ypos: Int, volume: Int): Int {
|
|
||||||
var spil = 0
|
|
||||||
|
|
||||||
val addrX = xpos - updateXFrom
|
|
||||||
val addrY = ypos - updateYFrom
|
|
||||||
|
|
||||||
if (addrX >= 0 && addrY >= 0 && addrX < DOUBLE_RADIUS && addrY < DOUBLE_RADIUS) {
|
|
||||||
fluidMap[addrY][addrX] += volume
|
|
||||||
if (fluidMap[addrY][addrX] > FLUID_MAX) {
|
|
||||||
spil = fluidMap[addrY][addrX] - FLUID_MAX
|
|
||||||
fluidMap[addrY][addrX] = FLUID_MAX
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return spil
|
|
||||||
}
|
|
||||||
|
|
||||||
// pour the fluid
|
|
||||||
var spillage = pourInternal(x, y, amount)
|
|
||||||
|
|
||||||
if (spillage == 0) return
|
|
||||||
|
|
||||||
// deal with the spillage
|
|
||||||
|
|
||||||
val tileUp = world.getTileFromTerrain(x - updateXFrom, y - updateYFrom - 1)
|
|
||||||
val tileDown = world.getTileFromTerrain(x - updateXFrom, y - updateYFrom + 1)
|
|
||||||
|
|
||||||
// try to fill downward
|
|
||||||
if (tileDown != null && !tileDown.isSolid()) {
|
|
||||||
spillage = pourInternal(x, y + 1, spillage)
|
|
||||||
}
|
|
||||||
// else, try to fill upward. if there is no space, just discard
|
|
||||||
if (tileUp != null && !tileUp.isSolid()) {
|
|
||||||
pourInternal(x, y - 1, spillage)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
purgeFluidMap()
|
purgeFluidMap()
|
||||||
|
worldToFluidMap(world)
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
// displace fluids. Record displacements into the fluidMap //
|
// displace fluids. Record displacements into the fluidMap //
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
for (y in updateYFrom..updateYTo) {
|
for (y in updateYFrom..updateYTo) {
|
||||||
for (x in updateXFrom..updateXTo) {
|
for (x in updateXFrom..updateXTo) {
|
||||||
val tile = world.getTileFromTerrain(x, y)
|
val tile = world.getTileFromTerrain(x, y) ?: TileNameCode.STONE
|
||||||
val tileBottom = world.getTileFromTerrain(x, y + 1)
|
val tileBottom = world.getTileFromTerrain(x, y + 1) ?: TileNameCode.STONE
|
||||||
val tileLeft = world.getTileFromTerrain(x - 1, y)
|
val tileLeft = world.getTileFromTerrain(x - 1, y) ?: TileNameCode.STONE
|
||||||
val tileRight = world.getTileFromTerrain(x + 1, y)
|
val tileRight = world.getTileFromTerrain(x + 1, y) ?: TileNameCode.STONE
|
||||||
if (tile != null && tile.isFluid()) {
|
if (tile.isFluid()) {
|
||||||
|
|
||||||
// move down if not obstructed
|
// move down if not obstructed
|
||||||
if (tileBottom != null && !tileBottom.isSolid()) {
|
if (!tileBottom.isSolid()) {
|
||||||
val drainage = drain(x, y, DISPLACE_CAP)
|
val drainage = drain(world, x, y, DISPLACE_CAP)
|
||||||
pour(x, y + 1, drainage)
|
pour(world, x, y + 1, drainage)
|
||||||
}
|
}
|
||||||
// left and right both open (null is considered as open)
|
// left and right both open
|
||||||
else if ((tileLeft != null && tileRight != null && !tileLeft.isSolid() && !tileRight.isSolid()) ||
|
else if (!tileLeft.isSolid() && !tileRight.isSolid()) {
|
||||||
tileLeft == null && tileRight == null) {
|
|
||||||
// half-breaker
|
// half-breaker
|
||||||
val moreToTheRight = HQRNG().nextBoolean()
|
val moreToTheRight = HQRNG().nextBoolean()
|
||||||
val displacement = drain(x, y, DISPLACE_CAP)
|
val displacement = drain(world, x, y, DISPLACE_CAP)
|
||||||
|
|
||||||
if (displacement.isEven()) {
|
if (displacement.isEven()) {
|
||||||
pour(x - 1, y, displacement shr 1)
|
pour(world, x - 1, y, displacement shr 1)
|
||||||
pour(x + 1, y, displacement shr 1)
|
pour(world, x + 1, y, displacement shr 1)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pour(x - 1, y, (displacement shr 1) + if (moreToTheRight) 0 else 1)
|
pour(world, x - 1, y, (displacement shr 1) + if (moreToTheRight) 0 else 1)
|
||||||
pour(x + 1, y, (displacement shr 1) + if (moreToTheRight) 1 else 0)
|
pour(world, x + 1, y, (displacement shr 1) + if (moreToTheRight) 1 else 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// left open (null is considered as open)
|
// left open
|
||||||
else if ((tileLeft != null && !tileLeft.isSolid()) || tileLeft == null) {
|
else if (!tileLeft.isSolid()) {
|
||||||
val displacement = drain(x, y, DISPLACE_CAP)
|
val displacement = drain(world, x, y, DISPLACE_CAP)
|
||||||
pour(x - 1, y, displacement)
|
pour(world, x - 1, y, displacement)
|
||||||
}
|
}
|
||||||
// right open (null is considered as open)
|
// right open
|
||||||
else if ((tileRight != null && !tileRight.isSolid()) || tileRight == null) {
|
else if (!tileRight.isSolid()) {
|
||||||
val displacement = drain(x, y, DISPLACE_CAP)
|
val displacement = drain(world, x, y, DISPLACE_CAP)
|
||||||
pour(x + 1, y, displacement)
|
pour(world, x + 1, y, displacement)
|
||||||
}
|
}
|
||||||
// nowhere open; do default (fill top)
|
// nowhere open; do default (fill top)
|
||||||
else {
|
else {
|
||||||
pour(x, y - 1, DISPLACE_CAP)
|
pour(world, x, y - 1, DISPLACE_CAP)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
// replace fluids in the map according to fluidMap //
|
// replace fluids in the map according to fluidMap //
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
for (y in 0..fluidMap.size - 1) {
|
fluidMapToWorld(world)
|
||||||
for (x in 0..fluidMap[0].size - 1) {
|
|
||||||
placeFluid(world, updateXFrom + x, updateYFrom + y, WATER, fluidMap[y][x].minus(1))
|
|
||||||
// FIXME test code: deals with water only!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* displace fallable tiles. It is scanned bottom-left first. To achieve the sens ofreal
|
||||||
|
* falling, each tiles are displaced by ONLY ONE TILE below.
|
||||||
|
*/
|
||||||
|
fun displaceFallables(world: GameWorld, p: Player, delta: Int) {
|
||||||
|
for (y in updateYFrom..updateYTo) {
|
||||||
|
for (x in updateXFrom..updateXTo) {
|
||||||
|
val tile = world.getTileFromTerrain(x, y) ?: TileNameCode.STONE
|
||||||
|
val tileBelow = world.getTileFromTerrain(x, y + 1) ?: TileNameCode.STONE
|
||||||
|
|
||||||
|
if (tile.isFallable()) {
|
||||||
|
// displace fluid. This statement must precede isSolid()
|
||||||
|
if (tileBelow.isFluid()) {
|
||||||
|
// remove tileThis to create air pocket
|
||||||
|
world.setTileTerrain(x, y, TileNameCode.AIR)
|
||||||
|
|
||||||
|
pour(world, x, y, drain(world, x, y, tileBelow.fluidLevel()))
|
||||||
|
// place our tile
|
||||||
|
world.setTileTerrain(x, y + 1, tile)
|
||||||
|
}
|
||||||
|
else if (!tileBelow.isSolid()) {
|
||||||
|
world.setTileTerrain(x, y, TileNameCode.AIR)
|
||||||
|
world.setTileTerrain(x, y + 1, tile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun drawFluidMapDebug(p: Player, g: Graphics) {
|
fun drawFluidMapDebug(p: Player, g: Graphics) {
|
||||||
|
g.font = Terrarum.fontSmallNumbers
|
||||||
|
g.color = colourWater
|
||||||
|
|
||||||
for (y in 0..fluidMap.size - 1) {
|
for (y in 0..fluidMap.size - 1) {
|
||||||
for (x in 0..fluidMap[0].size - 1) {
|
for (x in 0..fluidMap[0].size - 1) {
|
||||||
|
val data = fluidMap[y][x]
|
||||||
|
if (MapCamera.tileInCamera(x + updateXFrom, y + updateYFrom)) {
|
||||||
|
if (data == 0)
|
||||||
|
g.color = colourNone
|
||||||
|
else
|
||||||
|
g.color = colourWater
|
||||||
|
|
||||||
|
g.drawString(data.toString(),
|
||||||
|
updateXFrom.plus(x).times(MapDrawer.TILE_SIZE).toFloat()
|
||||||
|
+ if (data < 10) 4f else 0f,
|
||||||
|
updateYFrom.plus(y).times(MapDrawer.TILE_SIZE) + 4f
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//if (data > 0) println(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun purgeFluidMap() {
|
private fun purgeFluidMap() {
|
||||||
for (y in 1..DOUBLE_RADIUS)
|
for (y in 1..DOUBLE_RADIUS) {
|
||||||
for (x in 1..DOUBLE_RADIUS)
|
for (x in 1..DOUBLE_RADIUS) {
|
||||||
fluidMap[y - 1][x - 1] = 0
|
fluidMap[y - 1][x - 1] = 0
|
||||||
|
fluidTypeMap[y - 1][x - 1] = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun worldToFluidMap(world: GameWorld) {
|
||||||
|
for (y in updateYFrom..updateYTo) {
|
||||||
|
for (x in updateXFrom..updateXTo) {
|
||||||
|
val tile = world.getTileFromTerrain(x, y) ?: TileNameCode.STONE
|
||||||
|
if (tile.isFluid()) {
|
||||||
|
fluidMap[y - updateYFrom][x - updateXFrom] = tile.fluidLevel()
|
||||||
|
fluidTypeMap[y - updateYFrom][x - updateXFrom] = tile.fluidType().toByte()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun fluidMapToWorld(world: GameWorld) {
|
||||||
|
for (y in 0..fluidMap.size - 1) {
|
||||||
|
for (x in 0..fluidMap[0].size - 1) {
|
||||||
|
placeFluid(world, updateXFrom + x, updateYFrom + y
|
||||||
|
, FluidCodex.FLUID_WATER, fluidMap[y][x] - 1
|
||||||
|
)
|
||||||
|
// FIXME test code: deals with water only!
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Int.isFluid() = TilePropCodex.getProp(this).isFluid
|
fun Int.isFluid() = TilePropCodex.getProp(this).isFluid
|
||||||
fun Int.isSolid() = TilePropCodex.getProp(this).isSolid
|
fun Int.isSolid() = this.fluidLevel() == FLUID_MAX || TilePropCodex.getProp(this).isSolid
|
||||||
//fun Int.viscosity() = TilePropCodex.getProp(this).
|
//fun Int.viscosity() = TilePropCodex.getProp(this).
|
||||||
fun Int.fluidLevel() = this % FLUID_MAX
|
fun Int.fluidLevel() = if (!this.isFluid()) 0 else (this % FLUID_MAX) + 1
|
||||||
|
fun Int.fluidType() = this / FLUID_MAX
|
||||||
fun Int.isEven() = (this and 0x01) == 0
|
fun Int.isEven() = (this and 0x01) == 0
|
||||||
|
fun Int.isFallable() = TilePropCodex.getProp(this).isFallable
|
||||||
|
|
||||||
private fun placeFluid(world: GameWorld, x: Int, y: Int, tileFluid: Int, amount: Int) {
|
private fun placeFluid(world: GameWorld, x: Int, y: Int, fluidType: Byte, amount: Int) {
|
||||||
if (world.layerTerrain.isInBound(x, y)) {
|
if (world.layerTerrain.isInBound(x, y)) {
|
||||||
if (amount > 0 && !world.getTileFromTerrain(x, y)!!.isSolid()) {
|
if (amount > 0 && !world.getTileFromTerrain(x, y)!!.isSolid()) {
|
||||||
world.setTileTerrain(x, y, amount.minus(1).plus(tileFluid))
|
world.setTileTerrain(x, y, fluidType, amount - 1)
|
||||||
}
|
}
|
||||||
else if (amount == 0 && world.getTileFromTerrain(x, y)!!.isFluid()) {
|
else if (amount == 0 && world.getTileFromTerrain(x, y)!!.isFluid()) {
|
||||||
world.setTileTerrain(x, y, TileNameCode.AIR)
|
world.setTileTerrain(x, y, TileNameCode.AIR)
|
||||||
@@ -183,6 +223,64 @@ object WorldSimulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val LAVA = TileNameCode.LAVA_1
|
/**
|
||||||
val WATER = TileNameCode.WATER_1
|
* @param x and y: world tile coord
|
||||||
|
* @return amount of fluid actually drained.
|
||||||
|
* (intended drainage - this) will give you how much fluid is not yet drained.
|
||||||
|
* TODO add fluidType support
|
||||||
|
*/
|
||||||
|
private fun drain(world: GameWorld, x: Int, y: Int, amount: Int): Int {
|
||||||
|
val displacement = Math.min(fluidMap[y - updateYFrom][x - updateXFrom], amount)
|
||||||
|
|
||||||
|
fluidMap[y - updateYFrom][x - updateXFrom] -= displacement
|
||||||
|
|
||||||
|
return displacement
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param x and y: world tile coord
|
||||||
|
* TODO add fluidType support
|
||||||
|
*/
|
||||||
|
private fun pour(world: GameWorld, x: Int, y: Int, amount: Int) {
|
||||||
|
/**
|
||||||
|
* @param x and y: world tile coord
|
||||||
|
* @return spillage
|
||||||
|
* TODO add fluidType support
|
||||||
|
*/
|
||||||
|
fun pourInternal(worldXpos: Int, worldYPos: Int, volume: Int): Int {
|
||||||
|
var spil = 0
|
||||||
|
|
||||||
|
val addrX = worldXpos - updateXFrom
|
||||||
|
val addrY = worldYPos - updateYFrom
|
||||||
|
|
||||||
|
if (addrX >= 0 && addrY >= 0 && addrX < DOUBLE_RADIUS && addrY < DOUBLE_RADIUS) {
|
||||||
|
fluidMap[addrY][addrX] += volume
|
||||||
|
if (fluidMap[addrY][addrX] > FLUID_MAX) {
|
||||||
|
spil = fluidMap[addrY][addrX] - FLUID_MAX
|
||||||
|
fluidMap[addrY][addrX] = FLUID_MAX
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return spil
|
||||||
|
}
|
||||||
|
|
||||||
|
// pour the fluid
|
||||||
|
var spillage = pourInternal(x, y, amount)
|
||||||
|
|
||||||
|
if (spillage <= 0) return
|
||||||
|
|
||||||
|
// deal with the spillage
|
||||||
|
|
||||||
|
val tileUp = world.getTileFromTerrain(x - updateXFrom, y - updateYFrom - 1)
|
||||||
|
val tileDown = world.getTileFromTerrain(x - updateXFrom, y - updateYFrom + 1)
|
||||||
|
|
||||||
|
// try to fill downward
|
||||||
|
if (tileDown != null && !tileDown.isSolid()) {
|
||||||
|
spillage = pourInternal(x, y + 1, spillage)
|
||||||
|
}
|
||||||
|
// else, try to fill upward. if there is no space, just discard
|
||||||
|
if (spillage >= 0 && tileUp != null && !tileUp.isSolid()) {
|
||||||
|
pourInternal(x, y - 1, spillage)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -31,8 +31,8 @@ object MapCamera {
|
|||||||
|
|
||||||
var tilesWall: SpriteSheet = SpriteSheet("./assets/graphics/terrain/wall.png", TSIZE, TSIZE)
|
var tilesWall: SpriteSheet = SpriteSheet("./assets/graphics/terrain/wall.png", TSIZE, TSIZE)
|
||||||
private set
|
private set
|
||||||
var tilesTerrain: SpriteSheet = SpriteSheet("./assets/graphics/terrain/terrain.png", TSIZE, TSIZE)
|
var tilesTerrain: SpriteSheet = SpriteSheet("./assets/graphics/terrain/terrain.tga", TSIZE, TSIZE)
|
||||||
private set
|
private set // Slick has some weird quirks with PNG's transparency. I'm using 32-bit targa here.
|
||||||
var tilesWire: SpriteSheet = SpriteSheet("./assets/graphics/terrain/wire.png", TSIZE, TSIZE)
|
var tilesWire: SpriteSheet = SpriteSheet("./assets/graphics/terrain/wire.png", TSIZE, TSIZE)
|
||||||
private set
|
private set
|
||||||
var tilesetBook: Array<SpriteSheet> = arrayOf(tilesWall, tilesTerrain, tilesWire)
|
var tilesetBook: Array<SpriteSheet> = arrayOf(tilesWall, tilesTerrain, tilesWire)
|
||||||
@@ -494,4 +494,7 @@ object MapCamera {
|
|||||||
fun isPlatform(b: Int?): Boolean = TILES_WALL_STICKER_CONNECT_SELF.contains(b)
|
fun isPlatform(b: Int?): Boolean = TILES_WALL_STICKER_CONNECT_SELF.contains(b)
|
||||||
fun isBlendMul(b: Int?): Boolean = TILES_BLEND_MUL.contains(b)
|
fun isBlendMul(b: Int?): Boolean = TILES_BLEND_MUL.contains(b)
|
||||||
|
|
||||||
|
fun tileInCamera(x: Int, y: Int) =
|
||||||
|
x >= cameraX.div(TSIZE) && y >= cameraY.div(TSIZE) &&
|
||||||
|
x <= cameraX.plus(renderWidth).div(TSIZE) && y <= cameraY.plus(renderWidth).div(TSIZE)
|
||||||
}
|
}
|
||||||
@@ -31,13 +31,13 @@ import com.jme3.math.FastMath
|
|||||||
*/
|
*/
|
||||||
object NoiseFilterCubic : NoiseFilter {
|
object NoiseFilterCubic : NoiseFilter {
|
||||||
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
|
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
|
||||||
val graph_gradient = -FastMath.pow(FastMath.pow((1 - MapGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat(), 3f), -1f) * // 1/4 -> 3/4 -> 9/16 -> 16/9
|
val graph_gradient = -FastMath.pow(FastMath.pow((1 - WorldGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat(), 3f), -1f) * // 1/4 -> 3/4 -> 9/16 -> 16/9
|
||||||
(start - end) / FastMath.pow(MapGenerator.HEIGHT.toFloat(), 3f) *
|
(start - end) / FastMath.pow(WorldGenerator.HEIGHT.toFloat(), 3f) *
|
||||||
FastMath.pow((func_argX - MapGenerator.HEIGHT).toFloat(), 3f) + end
|
FastMath.pow((func_argX - WorldGenerator.HEIGHT).toFloat(), 3f) + end
|
||||||
|
|
||||||
if (func_argX < MapGenerator.TERRAIN_AVERAGE_HEIGHT) {
|
if (func_argX < WorldGenerator.TERRAIN_AVERAGE_HEIGHT) {
|
||||||
return start
|
return start
|
||||||
} else if (func_argX >= MapGenerator.HEIGHT) {
|
} else if (func_argX >= WorldGenerator.HEIGHT) {
|
||||||
return end
|
return end
|
||||||
} else {
|
} else {
|
||||||
return graph_gradient
|
return graph_gradient
|
||||||
|
|||||||
@@ -31,13 +31,13 @@ import com.jme3.math.FastMath
|
|||||||
*/
|
*/
|
||||||
object NoiseFilterMinusQuadratic : NoiseFilter {
|
object NoiseFilterMinusQuadratic : NoiseFilter {
|
||||||
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
|
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
|
||||||
val graph_gradient = -FastMath.pow(FastMath.sqr((1 - MapGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()), -1f) * // 1/4 -> 3/4 -> 9/16 -> 16/9
|
val graph_gradient = -FastMath.pow(FastMath.sqr((1 - WorldGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()), -1f) * // 1/4 -> 3/4 -> 9/16 -> 16/9
|
||||||
(start - end) / FastMath.sqr(MapGenerator.HEIGHT.toFloat()) *
|
(start - end) / FastMath.sqr(WorldGenerator.HEIGHT.toFloat()) *
|
||||||
FastMath.sqr((func_argX - MapGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()) + start
|
FastMath.sqr((func_argX - WorldGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()) + start
|
||||||
|
|
||||||
if (func_argX < MapGenerator.TERRAIN_AVERAGE_HEIGHT) {
|
if (func_argX < WorldGenerator.TERRAIN_AVERAGE_HEIGHT) {
|
||||||
return start
|
return start
|
||||||
} else if (func_argX >= MapGenerator.HEIGHT) {
|
} else if (func_argX >= WorldGenerator.HEIGHT) {
|
||||||
return end
|
return end
|
||||||
} else {
|
} else {
|
||||||
return graph_gradient
|
return graph_gradient
|
||||||
|
|||||||
@@ -32,13 +32,13 @@ import com.jme3.math.FastMath
|
|||||||
*/
|
*/
|
||||||
object NoiseFilterQuadratic : NoiseFilter {
|
object NoiseFilterQuadratic : NoiseFilter {
|
||||||
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
|
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
|
||||||
val graph_gradient = FastMath.pow(FastMath.sqr((1 - MapGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()), -1f) * // 1/4 -> 3/4 -> 9/16 -> 16/9
|
val graph_gradient = FastMath.pow(FastMath.sqr((1 - WorldGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()), -1f) * // 1/4 -> 3/4 -> 9/16 -> 16/9
|
||||||
(start - end) / FastMath.sqr(MapGenerator.HEIGHT.toFloat()) *
|
(start - end) / FastMath.sqr(WorldGenerator.HEIGHT.toFloat()) *
|
||||||
FastMath.sqr((func_argX - MapGenerator.HEIGHT).toFloat()) + end
|
FastMath.sqr((func_argX - WorldGenerator.HEIGHT).toFloat()) + end
|
||||||
|
|
||||||
if (func_argX < MapGenerator.TERRAIN_AVERAGE_HEIGHT) {
|
if (func_argX < WorldGenerator.TERRAIN_AVERAGE_HEIGHT) {
|
||||||
return start
|
return start
|
||||||
} else if (func_argX >= MapGenerator.HEIGHT) {
|
} else if (func_argX >= WorldGenerator.HEIGHT) {
|
||||||
return end
|
return end
|
||||||
} else {
|
} else {
|
||||||
return graph_gradient
|
return graph_gradient
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ import com.jme3.math.FastMath
|
|||||||
*/
|
*/
|
||||||
object NoiseFilterSqrt : NoiseFilter {
|
object NoiseFilterSqrt : NoiseFilter {
|
||||||
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
|
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
|
||||||
val graph_gradient = (end - start) / FastMath.sqrt((MapGenerator.HEIGHT - MapGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()) * FastMath.sqrt((func_argX - MapGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()) + start
|
val graph_gradient = (end - start) / FastMath.sqrt((WorldGenerator.HEIGHT - WorldGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()) * FastMath.sqrt((func_argX - WorldGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()) + start
|
||||||
|
|
||||||
if (func_argX < MapGenerator.TERRAIN_AVERAGE_HEIGHT) {
|
if (func_argX < WorldGenerator.TERRAIN_AVERAGE_HEIGHT) {
|
||||||
return start
|
return start
|
||||||
} else if (func_argX >= MapGenerator.HEIGHT) {
|
} else if (func_argX >= WorldGenerator.HEIGHT) {
|
||||||
return end
|
return end
|
||||||
} else {
|
} else {
|
||||||
return graph_gradient
|
return graph_gradient
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ package net.torvald.terrarum.mapgenerator
|
|||||||
* Created by minjaesong on 16-06-13.
|
* Created by minjaesong on 16-06-13.
|
||||||
*/
|
*/
|
||||||
class ThreadProcessNoiseLayers(val startIndex: Int, val endIndex: Int,
|
class ThreadProcessNoiseLayers(val startIndex: Int, val endIndex: Int,
|
||||||
val noiseRecords: Array<MapGenerator.TaggedJoise>) : Runnable {
|
val noiseRecords: Array<WorldGenerator.TaggedJoise>) : Runnable {
|
||||||
|
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
for (record in noiseRecords) {
|
for (record in noiseRecords) {
|
||||||
println("[mapgenerator] ${record.message}...")
|
println("[mapgenerator] ${record.message}...")
|
||||||
for (y in startIndex..endIndex) {
|
for (y in startIndex..endIndex) {
|
||||||
for (x in 0..MapGenerator.WIDTH - 1) {
|
for (x in 0..WorldGenerator.WIDTH - 1) {
|
||||||
val noise: Float = record.noiseModule.get(
|
val noise: Float = record.noiseModule.get(
|
||||||
x.toDouble() / 48.0, // 48: Fixed value
|
x.toDouble() / 48.0, // 48: Fixed value
|
||||||
y.toDouble() / 48.0
|
y.toDouble() / 48.0
|
||||||
@@ -24,11 +24,11 @@ class ThreadProcessNoiseLayers(val startIndex: Int, val endIndex: Int,
|
|||||||
// replace to designated tile
|
// replace to designated tile
|
||||||
is Int -> record.replaceTo as Int
|
is Int -> record.replaceTo as Int
|
||||||
// replace to randomly selected tile from given array of tile IDs
|
// replace to randomly selected tile from given array of tile IDs
|
||||||
is IntArray -> (record.replaceTo as IntArray)[MapGenerator.random.nextInt((record.replaceTo as IntArray).size)]
|
is IntArray -> (record.replaceTo as IntArray)[WorldGenerator.random.nextInt((record.replaceTo as IntArray).size)]
|
||||||
else -> throw IllegalArgumentException("[mapgenerator] Unknown replaceTo tile type '${record.replaceTo.javaClass.canonicalName}': Only 'kotlin.Int' and 'kotlin.IntArray' is valid.")
|
else -> throw IllegalArgumentException("[mapgenerator] Unknown replaceTo tile type '${record.replaceTo.javaClass.canonicalName}': Only 'kotlin.Int' and 'kotlin.IntArray' is valid.")
|
||||||
}
|
}
|
||||||
// replace to ALL? this is bullshit
|
// replace to ALL? this is bullshit
|
||||||
if (to == MapGenerator.TILE_MACRO_ALL) throw IllegalArgumentException("[mapgenerator] Invalid replaceTo: TILE_MACRO_ALL")
|
if (to == WorldGenerator.TILE_MACRO_ALL) throw IllegalArgumentException("[mapgenerator] Invalid replaceTo: TILE_MACRO_ALL")
|
||||||
|
|
||||||
// filtered threshold
|
// filtered threshold
|
||||||
val threshold = record.filter.getGrad(y, record.filterArg1, record.filterArg2)
|
val threshold = record.filter.getGrad(y, record.filterArg1, record.filterArg2)
|
||||||
@@ -38,15 +38,15 @@ class ThreadProcessNoiseLayers(val startIndex: Int, val endIndex: Int,
|
|||||||
for (i in 0..fromTerr.size - 1) {
|
for (i in 0..fromTerr.size - 1) {
|
||||||
val fromTerrVariable = fromTerr[i]
|
val fromTerrVariable = fromTerr[i]
|
||||||
|
|
||||||
if ((MapGenerator.world.getTileFromTerrain(x, y) == fromTerrVariable || fromTerrVariable == MapGenerator.TILE_MACRO_ALL)
|
if ((WorldGenerator.world.getTileFromTerrain(x, y) == fromTerrVariable || fromTerrVariable == WorldGenerator.TILE_MACRO_ALL)
|
||||||
&& (MapGenerator.world.getTileFromWall(x, y) == fromWall || fromWall == MapGenerator.TILE_MACRO_ALL)) {
|
&& (WorldGenerator.world.getTileFromWall(x, y) == fromWall || fromWall == WorldGenerator.TILE_MACRO_ALL)) {
|
||||||
MapGenerator.world.setTileTerrain(x, y, to)
|
WorldGenerator.world.setTileTerrain(x, y, to)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((MapGenerator.world.getTileFromTerrain(x, y) == fromTerr || fromTerr == MapGenerator.TILE_MACRO_ALL)
|
else if ((WorldGenerator.world.getTileFromTerrain(x, y) == fromTerr || fromTerr == WorldGenerator.TILE_MACRO_ALL)
|
||||||
&& (MapGenerator.world.getTileFromWall(x, y) == fromWall || fromWall == MapGenerator.TILE_MACRO_ALL)) {
|
&& (WorldGenerator.world.getTileFromWall(x, y) == fromWall || fromWall == WorldGenerator.TILE_MACRO_ALL)) {
|
||||||
MapGenerator.world.setTileTerrain(x, y, to)
|
WorldGenerator.world.setTileTerrain(x, y, to)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import net.torvald.terrarum.concurrent.ThreadPool
|
|||||||
import net.torvald.terrarum.gameactors.ThreadActorUpdate
|
import net.torvald.terrarum.gameactors.ThreadActorUpdate
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object MapGenerator {
|
object WorldGenerator {
|
||||||
|
|
||||||
internal lateinit var world: GameWorld
|
internal lateinit var world: GameWorld
|
||||||
internal lateinit var random: Random
|
internal lateinit var random: Random
|
||||||
@@ -74,7 +74,7 @@ object MapGenerator {
|
|||||||
|
|
||||||
DIRT_LAYER_DEPTH = (100 * HEIGHT / 1024f).toInt()
|
DIRT_LAYER_DEPTH = (100 * HEIGHT / 1024f).toInt()
|
||||||
minimumFloatingIsleHeight = (25 * (HEIGHT / 1024f)).toInt()
|
minimumFloatingIsleHeight = (25 * (HEIGHT / 1024f)).toInt()
|
||||||
TERRAIN_AVERAGE_HEIGHT = HEIGHT / 4
|
TERRAIN_AVERAGE_HEIGHT = HEIGHT / 3
|
||||||
|
|
||||||
OCEAN_WIDTH = Math.round(OCEAN_WIDTH * widthMulFactor)
|
OCEAN_WIDTH = Math.round(OCEAN_WIDTH * widthMulFactor)
|
||||||
SHORE_WIDTH = Math.round(SHORE_WIDTH * widthMulFactor)
|
SHORE_WIDTH = Math.round(SHORE_WIDTH * widthMulFactor)
|
||||||
@@ -50,14 +50,14 @@
|
|||||||
"12"; "0";"TILE_TORCH" ; "8396808"; "0"; "N/A"; "0"; "0"; "0"; "0"; "11"; "0"; "0"; "0";"16"
|
"12"; "0";"TILE_TORCH" ; "8396808"; "0"; "N/A"; "0"; "0"; "0"; "0"; "11"; "0"; "0"; "0";"16"
|
||||||
"12"; "1";"TILE_TORCH_FROST" ; "8396808"; "0"; "N/A"; "0"; "0"; "0"; "0"; "11"; "1"; "0"; "0";"16"
|
"12"; "1";"TILE_TORCH_FROST" ; "8396808"; "0"; "N/A"; "0"; "0"; "0"; "0"; "11"; "1"; "0"; "0";"16"
|
||||||
"13"; "0";"TILE_ILLUMINATOR_WHITE" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "239319274"; "13"; "0"; "0"; "0";"16"
|
"13"; "0";"TILE_ILLUMINATOR_WHITE" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "239319274"; "13"; "0"; "0"; "0";"16"
|
||||||
"13"; "1";"TILE_ILLUMINATOR_YELLOW" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "246656000"; "13"; "1"; "0"; "0";"16"
|
"13"; "1";"TILE_ILLUMINATOR_YELLOW" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "267607040"; "13"; "1"; "0"; "0";"16"
|
||||||
"13"; "2";"TILE_ILLUMINATOR_ORANGE" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "246602752"; "13"; "2"; "0"; "0";"16"
|
"13"; "2";"TILE_ILLUMINATOR_ORANGE" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "267546624"; "13"; "2"; "0"; "0";"16"
|
||||||
"13"; "3";"TILE_ILLUMINATOR_RED" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "246415360"; "13"; "3"; "0"; "0";"16"
|
"13"; "3";"TILE_ILLUMINATOR_RED" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "246415360"; "13"; "3"; "0"; "0";"16"
|
||||||
"13"; "4";"TILE_ILLUMINATOR_FUCHSIA" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "246415543"; "13"; "4"; "0"; "0";"16"
|
"13"; "4";"TILE_ILLUMINATOR_FUCHSIA" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "246415543"; "13"; "4"; "0"; "0";"16"
|
||||||
"13"; "5";"TILE_ILLUMINATOR_PURPLE" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "191889643"; "13"; "5"; "0"; "0";"16"
|
"13"; "5";"TILE_ILLUMINATOR_PURPLE" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "191889643"; "13"; "5"; "0"; "0";"16"
|
||||||
"13"; "6";"TILE_ILLUMINATOR_BLUE" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "235"; "13"; "6"; "0"; "0";"16"
|
"13"; "6";"TILE_ILLUMINATOR_BLUE" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "52479"; "13"; "6"; "0"; "0";"16"
|
||||||
"13"; "7";"TILE_ILLUMINATOR_CYAN" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "207083"; "13"; "7"; "0"; "0";"16"
|
"13"; "7";"TILE_ILLUMINATOR_CYAN" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "219391"; "13"; "7"; "0"; "0";"16"
|
||||||
"13"; "8";"TILE_ILLUMINATOR_GREEN" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "68364288"; "13"; "8"; "0"; "0";"16"
|
"13"; "8";"TILE_ILLUMINATOR_GREEN" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "56884224"; "13"; "8"; "0"; "0";"16"
|
||||||
"13"; "9";"TILE_ILLUMINATOR_GREEN_DARK";"8396808"; "0"; "N/A"; "0"; "1"; "1"; "33660928"; "13"; "9"; "0"; "0";"16"
|
"13"; "9";"TILE_ILLUMINATOR_GREEN_DARK";"8396808"; "0"; "N/A"; "0"; "1"; "1"; "33660928"; "13"; "9"; "0"; "0";"16"
|
||||||
"13"; "10";"TILE_ILLUMINATOR_BROWN" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "89161728"; "13"; "10"; "0"; "0";"16"
|
"13"; "10";"TILE_ILLUMINATOR_BROWN" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "89161728"; "13"; "10"; "0"; "0";"16"
|
||||||
"13"; "11";"TILE_ILLUMINATOR_TAN" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "157392948"; "13"; "11"; "0"; "0";"16"
|
"13"; "11";"TILE_ILLUMINATOR_TAN" ; "8396808"; "0"; "N/A"; "0"; "1"; "1"; "157392948"; "13"; "11"; "0"; "0";"16"
|
||||||
|
|||||||
|
Can't render this file because it contains an unexpected character in line 1 and column 18.
|
@@ -68,7 +68,7 @@ class BasicDebugInfoWindow : UICanvas {
|
|||||||
val mouseTileX = ((MapCamera.cameraX + gc.input.mouseX / Terrarum.ingame.screenZoom) / MapDrawer.TILE_SIZE).toInt()
|
val mouseTileX = ((MapCamera.cameraX + gc.input.mouseX / Terrarum.ingame.screenZoom) / MapDrawer.TILE_SIZE).toInt()
|
||||||
val mouseTileY = ((MapCamera.cameraY + gc.input.mouseY / Terrarum.ingame.screenZoom) / MapDrawer.TILE_SIZE).toInt()
|
val mouseTileY = ((MapCamera.cameraY + gc.input.mouseY / Terrarum.ingame.screenZoom) / MapDrawer.TILE_SIZE).toInt()
|
||||||
|
|
||||||
g.font = Terrarum.smallNumbers
|
g.font = Terrarum.fontSmallNumbers
|
||||||
g.color = GameFontBase.codeToCol["y"]
|
g.color = GameFontBase.codeToCol["y"]
|
||||||
|
|
||||||
val hitbox = player.hitbox
|
val hitbox = player.hitbox
|
||||||
|
|||||||
@@ -14,4 +14,9 @@ object DrawUtil {
|
|||||||
|
|
||||||
g.drawImage(image, targetW.minus(imageW).ushr(1).toFloat(), screenPosY.toFloat())
|
g.drawImage(image, targetW.minus(imageW).ushr(1).toFloat(), screenPosY.toFloat())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun drawCentered(g: Graphics, image: Image, screenPosY: Int, targetW: Int, offsetX: Int = 0, offsetY: Int = 0) {
|
||||||
|
val imageW = image.width
|
||||||
|
g.drawImage(image, targetW.minus(imageW).ushr(1).toFloat() + offsetX, screenPosY.toFloat() + offsetY)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,5 @@ package net.torvald.terrarum.ui
|
|||||||
*/
|
*/
|
||||||
interface GamepadControlled {
|
interface GamepadControlled {
|
||||||
fun controllerButtonPressed(controller: Int, button: Int)
|
fun controllerButtonPressed(controller: Int, button: Int)
|
||||||
|
|
||||||
fun controllerButtonReleased(controller: Int, button: Int)
|
fun controllerButtonReleased(controller: Int, button: Int)
|
||||||
}
|
}
|
||||||
80
src/net/torvald/terrarum/ui/ItemImageGallery.kt
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import net.torvald.terrarum.gameactors.roundInt
|
||||||
|
import org.newdawn.slick.GameContainer
|
||||||
|
import org.newdawn.slick.Graphics
|
||||||
|
import org.newdawn.slick.Image
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Image gallery. Images will be equally spaced, counted from top-left to bottom-right.
|
||||||
|
* Created by minjaesong on 16-08-08.
|
||||||
|
*/
|
||||||
|
class ItemImageGallery(
|
||||||
|
override var posX: Int,
|
||||||
|
override var posY: Int,
|
||||||
|
val width: Int,
|
||||||
|
val height: Int,
|
||||||
|
val imageList: ArrayList<Image>,
|
||||||
|
val column: Int = 1
|
||||||
|
) : UIItem {
|
||||||
|
|
||||||
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(gc: GameContainer, g: Graphics) {
|
||||||
|
fun column(i: Int) = i % column
|
||||||
|
fun row(i: Int) = i / column
|
||||||
|
|
||||||
|
fun imagePosY(i: Int): Int {
|
||||||
|
val gutter = (height - imageList[i].height.times(imageList.size)).toFloat().div(
|
||||||
|
imageList.size + 1f
|
||||||
|
)
|
||||||
|
return row((gutter * i.plus(1) + imageList[i].height * i).roundInt())
|
||||||
|
}
|
||||||
|
|
||||||
|
imageList.forEachIndexed { i, image ->
|
||||||
|
DrawUtil.drawCentered(g, image,
|
||||||
|
imagePosY(i),
|
||||||
|
width.toFloat().div(column).times(column(i).plus(1)).roundInt(),
|
||||||
|
posX, posY
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun keyPressed(key: Int, c: Char) {
|
||||||
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun keyReleased(key: Int, c: Char) {
|
||||||
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mousePressed(button: Int, x: Int, y: Int) {
|
||||||
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseReleased(button: Int, x: Int, y: Int) {
|
||||||
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseWheelMoved(change: Int) {
|
||||||
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun controllerButtonPressed(controller: Int, button: Int) {
|
||||||
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun controllerButtonReleased(controller: Int, button: Int) {
|
||||||
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,8 +16,8 @@ object ItemSlotImageBuilder {
|
|||||||
const val COLOR_BLACK = 1
|
const val COLOR_BLACK = 1
|
||||||
const val COLOR_WHITE = 2
|
const val COLOR_WHITE = 2
|
||||||
|
|
||||||
private val colourBlack = Color(0x404040)
|
private val colourBlack = Color(0x40, 0x40, 0x40, 0xEE)
|
||||||
private val colourWhite = Color(0xC0C0C0)
|
private val colourWhite = Color(0xC0, 0xC0, 0xC0, 0xEE)
|
||||||
|
|
||||||
private val numberFont = SpriteSheetFont(
|
private val numberFont = SpriteSheetFont(
|
||||||
SpriteSheet("./assets/graphics/fonts/numeric_small.png", 5, 8),
|
SpriteSheet("./assets/graphics/fonts/numeric_small.png", 5, 8),
|
||||||
|
|||||||
@@ -5,6 +5,5 @@ package net.torvald.terrarum.ui
|
|||||||
*/
|
*/
|
||||||
interface KeyboardControlled {
|
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)
|
||||||
}
|
}
|
||||||
@@ -5,12 +5,8 @@ package net.torvald.terrarum.ui
|
|||||||
*/
|
*/
|
||||||
interface MouseControlled {
|
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)
|
||||||
|
|
||||||
fun mousePressed(button: Int, x: Int, y: Int)
|
fun mousePressed(button: Int, x: Int, y: Int)
|
||||||
|
|
||||||
fun mouseReleased(button: Int, x: Int, y: Int)
|
fun mouseReleased(button: Int, x: Int, y: Int)
|
||||||
|
|
||||||
fun mouseWheelMoved(change: Int)
|
fun mouseWheelMoved(change: Int)
|
||||||
}
|
}
|
||||||
@@ -117,10 +117,10 @@ constructor(val UI: UICanvas) {
|
|||||||
fun render(gc: GameContainer, sbg: StateBasedGame, ingameGraphics: Graphics) {
|
fun render(gc: GameContainer, sbg: StateBasedGame, ingameGraphics: Graphics) {
|
||||||
if (isVisible || alwaysVisible) {
|
if (isVisible || alwaysVisible) {
|
||||||
UIGraphicInstance.clear()
|
UIGraphicInstance.clear()
|
||||||
UIGraphicInstance.font = Terrarum.gameFont
|
UIGraphicInstance.font = Terrarum.fontGame
|
||||||
|
|
||||||
UI.render(gc, UIGraphicInstance)
|
UI.render(gc, UIGraphicInstance)
|
||||||
if (sbg.currentStateID == Terrarum.SCENE_ID_GAME) {
|
if (sbg.currentStateID == Terrarum.STATE_ID_GAME) {
|
||||||
ingameGraphics.drawImage(UIDrawnCanvas.getScaledCopy(scale),
|
ingameGraphics.drawImage(UIDrawnCanvas.getScaledCopy(scale),
|
||||||
posX + MapCamera.cameraX * Terrarum.ingame.screenZoom - (UI.width / 2f * scale.minus(1)),
|
posX + MapCamera.cameraX * Terrarum.ingame.screenZoom - (UI.width / 2f * scale.minus(1)),
|
||||||
posY + MapCamera.cameraY * Terrarum.ingame.screenZoom - (UI.height / 2f * scale.minus(1)),
|
posY + MapCamera.cameraY * Terrarum.ingame.screenZoom - (UI.height / 2f * scale.minus(1)),
|
||||||
|
|||||||
@@ -1,13 +1,32 @@
|
|||||||
package net.torvald.terrarum.ui
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import org.newdawn.slick.GameContainer
|
||||||
|
import org.newdawn.slick.Graphics
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 15-12-31.
|
* Created by minjaesong on 15-12-31.
|
||||||
*/
|
*/
|
||||||
class UIItem {
|
interface UIItem {
|
||||||
|
|
||||||
// X/Y Position relative to the containing canvas
|
// X/Y Position relative to the containing canvas
|
||||||
internal var posX: Int = 0
|
var posX: Int
|
||||||
internal var posY: Int = 0
|
var posY: Int
|
||||||
|
|
||||||
|
fun update(gc: GameContainer, delta: Int)
|
||||||
|
fun render(gc: GameContainer, g: Graphics)
|
||||||
|
|
||||||
|
// keyboard controlled
|
||||||
|
fun keyPressed(key: Int, c: Char)
|
||||||
|
fun keyReleased(key: Int, c: Char)
|
||||||
|
|
||||||
|
// mouse controlled
|
||||||
|
fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int)
|
||||||
|
fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int)
|
||||||
|
fun mousePressed(button: Int, x: Int, y: Int)
|
||||||
|
fun mouseReleased(button: Int, x: Int, y: Int)
|
||||||
|
fun mouseWheelMoved(change: Int)
|
||||||
|
|
||||||
|
// gamepad controlled
|
||||||
|
fun controllerButtonPressed(controller: Int, button: Int)
|
||||||
|
fun controllerButtonReleased(controller: Int, button: Int)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ class UIPieMenu : UICanvas {
|
|||||||
if (selection >= 0)
|
if (selection >= 0)
|
||||||
Terrarum.ingame.player.actorValue[AVKey._PLAYER_QUICKBARSEL] =
|
Terrarum.ingame.player.actorValue[AVKey._PLAYER_QUICKBARSEL] =
|
||||||
selection % slotCount
|
selection % slotCount
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(gc: GameContainer, g: Graphics) {
|
override fun render(gc: GameContainer, g: Graphics) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import org.newdawn.slick.Input
|
|||||||
class UIQuickBar : UICanvas, MouseControlled {
|
class UIQuickBar : UICanvas, MouseControlled {
|
||||||
private val gutter = 8
|
private val gutter = 8
|
||||||
override var width: Int = (ItemSlotImageBuilder.slotImageSize + gutter) * SLOT_COUNT
|
override var width: Int = (ItemSlotImageBuilder.slotImageSize + gutter) * SLOT_COUNT
|
||||||
override var height: Int = ItemSlotImageBuilder.slotImageSize + 4 + Terrarum.gameFont.lineHeight
|
override var height: Int = ItemSlotImageBuilder.slotImageSize + 4 + Terrarum.fontGame.lineHeight
|
||||||
/**
|
/**
|
||||||
* In milliseconds
|
* In milliseconds
|
||||||
*/
|
*/
|
||||||
|
|||||||