diff --git a/assets/4096_bayer_skyboxfill.frag b/assets/4096_bayer_skyboxfill.frag index c3dbcdae1..13e3664ac 100644 --- a/assets/4096_bayer_skyboxfill.frag +++ b/assets/4096_bayer_skyboxfill.frag @@ -15,8 +15,18 @@ uniform float gcount = 64.0; // using 64: has less banding and most monitors are uniform float bcount = 64.0; +int bayer[7][7] = { +{32,42,10,27,37,5,15}, +{1,18,28,45,13,23,40}, +{26,36,4,14,31,48,9}, +{44,12,22,39,0,17,34}, +{20,30,47,8,25,35,3}, +{38,6,16,33,43,11,21}, +{7,24,41,2,19,29,46} +}; // I kind of accidentally create it... +float bayerSize = 7.0; -int bayer[9][9] = { +/*int bayer[9][9] = { {50,71,2,23,44,56,77,17,29}, {72,12,33,45,66,6,18,39,60}, {22,43,55,76,16,28,49,70,1}, @@ -27,7 +37,7 @@ int bayer[9][9] = { {78,9,30,51,63,3,24,36,57}, {19,40,61,73,13,34,46,67,7} }; -float bayerSize = 9.0; +float bayerSize = 9.0;*/ diff --git a/assets/graphics/gui/quickbar/item_slot.tga b/assets/graphics/gui/quickbar/item_slot.tga index ca3e3e3d6..a8d4d0c71 100644 --- a/assets/graphics/gui/quickbar/item_slot.tga +++ b/assets/graphics/gui/quickbar/item_slot.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f8fd905db439874eed83e97ebd9163ce52ef5a3d2c61408e8466e2dc7ea04ab3 -size 5794 +oid sha256:61ea0369e5152797fb9ac8a310781b1701b75df405af02351f95f21f0d462ecf +size 63580 diff --git a/assets/graphics/gui/quickbar/item_slot_large.tga b/assets/graphics/gui/quickbar/item_slot_large.tga index 2086c4bb6..4f1b55167 100644 --- a/assets/graphics/gui/quickbar/item_slot_large.tga +++ b/assets/graphics/gui/quickbar/item_slot_large.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a47c225f5d5ce71fbb46438149b97fcca9c9073658e2018e48483095ceb3fa15 -size 5794 +oid sha256:3128102ac06826fbee0cfbc2c6b8191844e99aa843a228534ed924185422f46b +size 63580 diff --git a/assets/modules/basegame/basegame.groovy b/assets/modules/basegame/basegame.groovy index b878c7eb3..6b11c7931 100644 --- a/assets/modules/basegame/basegame.groovy +++ b/assets/modules/basegame/basegame.groovy @@ -1,7 +1,7 @@ import net.torvald.terrarum.ModMgr /** - * Created by SKYHi14 on 2017-04-26. + * Created by minjaesong on 2017-04-26. */ static void invoke(String module) { diff --git a/assets/modules/basegame/items/malicious.groovy b/assets/modules/basegame/items/malicious.groovy index b995606f5..dce7d915c 100644 --- a/assets/modules/basegame/items/malicious.groovy +++ b/assets/modules/basegame/items/malicious.groovy @@ -4,7 +4,7 @@ import org.jetbrains.annotations.NotNull import org.jetbrains.annotations.Nullable /** - * Created by SKYHi14 on 2017-04-28. + * Created by minjaesong on 2017-04-28. */ static GameItem invoke(int id) { diff --git a/assets/modules/basegame/items/testpick.groovy b/assets/modules/basegame/items/testpick.groovy index 7daa4ed7b..6c3ebb2e6 100644 --- a/assets/modules/basegame/items/testpick.groovy +++ b/assets/modules/basegame/items/testpick.groovy @@ -1,6 +1,6 @@ /** - * Created by SKYHi14 on 2017-04-26. + * Created by minjaesong on 2017-04-26. */ diff --git a/src/net/torvald/dataclass/Float16.kt b/src/net/torvald/dataclass/Float16.kt index f04c421c5..aaa45d2e5 100644 --- a/src/net/torvald/dataclass/Float16.kt +++ b/src/net/torvald/dataclass/Float16.kt @@ -5,7 +5,7 @@ import kotlin.experimental.or /** * https://stackoverflow.com/questions/6162651/half-precision-floating-point-in-java#6162687 * - * Created by SKYHi14 on 2017-04-21. + * Created by minjaesong on 2017-04-21. */ typealias Float16Bits = Short diff --git a/src/net/torvald/terrarum/Ingame.kt b/src/net/torvald/terrarum/Ingame.kt index f19171745..ae0faae54 100644 --- a/src/net/torvald/terrarum/Ingame.kt +++ b/src/net/torvald/terrarum/Ingame.kt @@ -364,6 +364,7 @@ class Ingame(val batch: SpriteBatch) : Screen { //uiVitalPrimary, //uiVitalSecondary, //uiVitalItem, + uiPieMenu, uiQuickBar, uiWatchBasic, @@ -841,7 +842,8 @@ class Ingame(val batch: SpriteBatch) : Screen { ///////////////////////////// // draw some overlays (UI) // ///////////////////////////// - uiContainer.forEach { if (it != consoleHandler) it.render(batch, camera) } + + uiContainer.forEach { if (it != consoleHandler) it.render(batch, camera) } // FIXME some of the UIs causes memory leak debugWindow.render(batch, camera) // make sure console draws on top of other UIs @@ -851,167 +853,6 @@ class Ingame(val batch: SpriteBatch) : Screen { blendNormal() } - - - - // ////// //// // //// // // - // // // // // // // // - // //// // // // // // //// - // // // // ////// // // - ////// ////// //// // // //// //// - - - ///////////////////////////// - // draw map related stuffs // - ///////////////////////////// - /*worldDrawFrameBuffer.inAction { - - batch.inUse { - camera.position.set(WorldCamera.x.toFloat(), WorldCamera.y.toFloat(), 0f) // make camara work - camera.update() - batch.projectionMatrix = camera.combined - - - batch.color = Color.WHITE - batch.fillRect(WorldCamera.x.toFloat(), WorldCamera.y.toFloat(), 16f, 16f) - - - - BlocksDrawer.renderWall(batch) - actorsRenderBehind.forEach { it.drawBody(batch) } - actorsRenderBehind.forEach { it.drawGlow(batch) } - particlesContainer.forEach { it.drawBody(batch) } - particlesContainer.forEach { it.drawGlow(batch) } - BlocksDrawer.renderTerrain(batch) - - ///////////////// - // draw actors // - ///////////////// - actorsRenderMiddle.forEach { it.drawBody(batch) } - actorsRenderMidTop.forEach { it.drawBody(batch) } - player.drawBody(batch) - actorsRenderFront.forEach { it.drawBody(batch) } - // --> Change of blend mode <-- introduced by childs of ActorWithBody // - - - ///////////////////////////// - // draw map related stuffs // - ///////////////////////////// - LightmapRenderer.renderLightMap() - - BlocksDrawer.renderFront(batch, false) - // --> blendNormal() <-- by BlocksDrawer.renderFront - FeaturesDrawer.render(batch) - - - FeaturesDrawer.drawEnvOverlay(batch) - - if (!KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) blendMul() - else blendNormal() - LightmapRenderer.draw(batch) - - - ////////////////////// - // draw actor glows // - ////////////////////// - actorsRenderMiddle.forEach { it.drawGlow(batch) } - actorsRenderMidTop.forEach { it.drawGlow(batch) } - player.drawGlow(batch) - actorsRenderFront.forEach { it.drawGlow(batch) } - // --> blendLightenOnly() <-- introduced by childs of ActorWithBody // - - - //////////////////////// - // debug informations // - //////////////////////// - blendNormal() - // draw reference ID if debugWindow is open - if (debugWindow.isVisible) { - actorContainer.forEachIndexed { i, actor -> - if (actor is ActorWithBody) { - batch.color = Color.WHITE - Terrarum.fontSmallNumbers.draw(batch, - actor.referenceID.toString(), - actor.hitbox.startX.toFloat(), - actor.hitbox.canonicalY.toFloat() + 4 - ) - } - } - } - // debug physics - if (KeyToggler.isOn(Key.F11)) { - actorContainer.forEachIndexed { i, actor -> - if (actor is ActorWithPhysics) { - /*shapeRenderer.inUse(ShapeRenderer.ShapeType.Line) { - shapeRenderer.color = Color(1f, 0f, 1f, 1f) - //shapeRenderer.lineWidth = 1f - shapeRenderer.rect( - actor.hitbox.startX.toFloat(), - actor.hitbox.startY.toFloat(), - actor.hitbox.width.toFloat(), - actor.hitbox.height.toFloat() - ) - }*/ - - // velocity - batch.color = Color.CHARTREUSE//GameFontBase.codeToCol["g"] - Terrarum.fontSmallNumbers.draw(batch, - "${0x7F.toChar()}X ${actor.externalForce.x}", - actor.hitbox.startX.toFloat(), - actor.hitbox.canonicalY.toFloat() + 4 + 8 - ) - Terrarum.fontSmallNumbers.draw(batch, - "${0x7F.toChar()}Y ${actor.externalForce.y}", - actor.hitbox.startX.toFloat(), - actor.hitbox.canonicalY.toFloat() + 4 + 8 * 2 - ) - } - } - } - // fluidmap debug - if (KeyToggler.isOn(Key.F4)) - WorldSimulator.drawFluidMapDebug(batch) - - - } - } - ///////////////// - // GUI Predraw // - ///////////////// - //worldG.flush() - batch.inUse { - val tex = backDrawFrameBuffer.colorBufferTexture // TODO zoom! - batch.draw(tex, 0f, 0f) - }*/ - //backG.drawImage(worldDrawFrameBuffer.getScaledCopy(screenZoom), 0f, 0f) - //backG.flush() - - - ///////////////////// - // draw UIs ONLY! // - ///////////////////// - /*batch.inUse { - uiContainer.forEach { if (it != consoleHandler) it.render(batch) } - debugWindow.render(batch) - // make sure console draws on top of other UIs - consoleHandler.render(batch) - notifier.render(batch) - }*/ - - - ////////////////// - // GUI Postdraw // - ////////////////// - //backG.flush() - //gwin.drawImage(backDrawFrameBuffer, 0f, 0f) - - - - // centre marker - /*gwin.color = Color(0x00FFFF) - gwin.lineWidth = 1f - gwin.drawLine(Terrarum.WIDTH / 2f, 0f, Terrarum.WIDTH / 2f, Terrarum.HEIGHT.toFloat()) - gwin.drawLine(0f, Terrarum.HEIGHT / 2f, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT / 2f)*/ } fun processBlur(lightmapFboA: FrameBuffer, lightmapFboB: FrameBuffer, mode: Int) { diff --git a/src/net/torvald/terrarum/ModMgr.kt b/src/net/torvald/terrarum/ModMgr.kt index f9b19c0f2..c186b61cb 100644 --- a/src/net/torvald/terrarum/ModMgr.kt +++ b/src/net/torvald/terrarum/ModMgr.kt @@ -26,7 +26,7 @@ import javax.script.Invocable * is readily available, ditch that Groovy. * * - * Created by SKYHi14 on 2017-04-17. + * Created by minjaesong on 2017-04-17. */ object ModMgr { diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index edf8ae2ae..39d65b854 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -408,20 +408,17 @@ object Terrarum : Game() { - //ingame = Ingame(batch) - //ingame!!.gameLoadInfoPayload = Ingame.NewWorldParameters(8192, 2048, HQRNG().nextLong()) - - // TODO: create world being used by title screen, and serialise it. - //ingame!!.gameLoadInfoPayload = Ingame.NewWorldParameters(2400, 800, HQRNG().nextLong()) - //ingame!!.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW + // jump right into the ingame + ingame = Ingame(batch) + ingame!!.gameLoadInfoPayload = Ingame.NewWorldParameters(2400, 800, HQRNG().nextLong()) + ingame!!.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW + LoadScreen.screenToLoad = ingame!! + super.setScreen(LoadScreen) - //LoadScreen.screenToLoad = ingame!! - super.setScreen(TitleScreen(batch)) - //super.setScreen(LoadScreen) - - //super.setScreen(ingame) + // title screen + //super.setScreen(TitleScreen(batch)) } internal fun changeScreen(screen: Screen) { @@ -697,6 +694,8 @@ inline fun FrameBuffer.inAction(camera: OrthographicCamera?, batch: SpriteBatch? action(this) this.end() camera?.setToOrtho(true, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat()) + camera?.update() + batch?.projectionMatrix = camera?.combined } fun Float.round(): Float { diff --git a/src/net/torvald/terrarum/TitleScreen.kt b/src/net/torvald/terrarum/TitleScreen.kt index d4e3a5318..a3b314953 100644 --- a/src/net/torvald/terrarum/TitleScreen.kt +++ b/src/net/torvald/terrarum/TitleScreen.kt @@ -52,16 +52,19 @@ class TitleScreen(val batch: SpriteBatch) : Screen { private val cameraAI = object : ActorAI { private val axisMax = 1f + private var firstTime = true + override fun update(actor: HumanoidNPC, delta: Float) { // fuck - val avSpeed = 0.66 // FIXME camera goes faster when FPS is high + val avSpeed = 1.0 // FIXME camera goes faster when FPS is high actor.actorValue[AVKey.SPEED] = avSpeed - actor.actorValue[AVKey.ACCEL] = avSpeed / 5.0 + actor.actorValue[AVKey.ACCEL] = avSpeed / 6.0 + // end fuck val tileSize = FeaturesDrawer.TILE_SIZE.toFloat() - val catmullRomTension = 1f + val catmullRomTension = -1f // pan camera actor.moveRight(axisMax) @@ -80,12 +83,16 @@ class TitleScreen(val batch: SpriteBatch) : Screen { val targetYPos = FastMath.interpolateCatmullRom(u, catmullRomTension, cameraNodes[p0], cameraNodes[p1], cameraNodes[p2], cameraNodes[p3]) val yDiff = targetYPos - actor.hitbox.canonicalY - actor.moveDown(yDiff.bipolarClamp(axisMax.toDouble()).toFloat()) + if (!firstTime) { + actor.moveDown(yDiff.bipolarClamp(axisMax.toDouble()).toFloat()) + } + else { + actor.hitbox.setPosition(actor.hitbox.canonicalX, targetYPos.toDouble()) + firstTime = false + } - println("${actor.hitbox.canonicalX}, ${actor.hitbox.canonicalY}") - - //actor.hitbox.setPosition(actor.hitbox.canonicalX, yPos.toDouble()) + //println("${actor.hitbox.canonicalX}, ${actor.hitbox.canonicalY}") } } private lateinit var cameraPlayer: HumanoidNPC @@ -107,7 +114,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen { // construct camera nodes - val nodeCount = 150 + val nodeCount = 60 cameraNodes = kotlin.FloatArray(nodeCount, { it -> val tileXPos = (demoWorld.width.toFloat() * it / nodeCount).floorInt() var travelDownCounter = 0 @@ -123,13 +130,13 @@ class TitleScreen(val batch: SpriteBatch) : Screen { setHitboxDimension(2, 2, 0, 0) hitbox.setPosition( HQRNG().nextInt(demoWorld.width) * FeaturesDrawer.TILE_SIZE.toDouble(), - (demoWorld.height / 3) * 0.75 * FeaturesDrawer.TILE_SIZE.toDouble()//demoWorld.spawnY * FeaturesDrawer.TILE_SIZE.toDouble() + 0.0 // placeholder; camera AI will take it over ) noClip = true } } - demoWorld.time.timeDelta = 60 + demoWorld.time.timeDelta = 150 LightmapRenderer.world = demoWorld @@ -164,14 +171,18 @@ class TitleScreen(val batch: SpriteBatch) : Screen { private var blurWriteBuffer = lightmapFboA private var blurReadBuffer = lightmapFboB - private val minimumIntroTime = 2.0f - private var deltaCounter = 0f + private val minimumIntroTime: Second = 2.0f + private val introUncoverTime: Second = 0.3f + private var showIntroDeltaCounter = 0f + private var introUncoverDeltaCounter = 0f + private var updateDeltaCounter = 0.0 + protected val updateRate = 1.0 / Terrarum.TARGET_INTERNAL_FPS override fun render(delta: Float) { Gdx.gl.glClearColor(.094f, .094f, .094f, 0f) Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) - if (!loadDone || deltaCounter < minimumIntroTime) { + if (!loadDone || showIntroDeltaCounter < minimumIntroTime) { // draw load screen Terrarum.shaderBayerSkyboxFill.begin() Terrarum.shaderBayerSkyboxFill.setUniformMatrix("u_projTrans", camera.combined) @@ -195,52 +206,64 @@ class TitleScreen(val batch: SpriteBatch) : Screen { } } else { - demoWorld.globalLight = WeatherMixer.globalLightNow - demoWorld.updateWorldTime(delta) - WeatherMixer.update(delta, cameraPlayer) - cameraPlayer.update(delta) - // worldcamera update AFTER cameraplayer in this case; the other way is just an exception for actual ingame SFX - WorldCamera.update(demoWorld, cameraPlayer) - - - // update UIs // - uiContainer.forEach { it.update(delta) } - - - if (Terrarum.GLOBAL_RENDER_TIMER % 2 == 1) { - LightmapRenderer.fireRecalculateEvent() - } - - - // render and blur lightmap - processBlur(LightmapRenderer.DRAW_FOR_RGB) - //camera.setToOrtho(true, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat()) - - // render world - batch.inUse { - setCameraPosition(0f, 0f) - batch.color = Color.WHITE - batch.shader = null - camera.position.set(WorldCamera.gdxCamX, WorldCamera.gdxCamY, 0f) // make camara work - camera.update() - batch.projectionMatrix = camera.combined - batch.color = Color.WHITE - blendNormal() - - - - renderDemoWorld() - - renderMenus() - - renderOverlayTexts() + // async update + updateDeltaCounter += delta + while (updateDeltaCounter >= updateRate) { + updateScreen(delta) + updateDeltaCounter -= updateRate } + // render? just do it anyway + renderScreen() } - deltaCounter += delta + showIntroDeltaCounter += delta + } + + fun updateScreen(delta: Float) { + demoWorld.globalLight = WeatherMixer.globalLightNow + demoWorld.updateWorldTime(delta) + WeatherMixer.update(delta, cameraPlayer) + cameraPlayer.update(delta) + // worldcamera update AFTER cameraplayer in this case; the other way is just an exception for actual ingame SFX + WorldCamera.update(demoWorld, cameraPlayer) + + + // update UIs // + uiContainer.forEach { it.update(delta) } + + + if (Terrarum.GLOBAL_RENDER_TIMER % 2 == 1) { + LightmapRenderer.fireRecalculateEvent() + } + } + + fun renderScreen() { + // render and blur lightmap + processBlur(LightmapRenderer.DRAW_FOR_RGB) + //camera.setToOrtho(true, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat()) + + // render world + batch.inUse { + setCameraPosition(0f, 0f) + batch.color = Color.WHITE + batch.shader = null + camera.position.set(WorldCamera.gdxCamX, WorldCamera.gdxCamY, 0f) // make camara work + camera.update() + batch.projectionMatrix = camera.combined + batch.color = Color.WHITE + blendNormal() + + + + renderDemoWorld() + + renderMenus() + + renderOverlayTexts() + } } private fun renderDemoWorld() { diff --git a/src/net/torvald/terrarum/UIItemInventoryElem.kt b/src/net/torvald/terrarum/UIItemInventoryElem.kt index 9860dffe7..381727461 100644 --- a/src/net/torvald/terrarum/UIItemInventoryElem.kt +++ b/src/net/torvald/terrarum/UIItemInventoryElem.kt @@ -13,7 +13,7 @@ import net.torvald.terrarum.ui.UIItemTextButton /*** * Note that the UI will not render if either item or itemImage is null. * - * Created by SKYHi14 on 2017-03-16. + * Created by minjaesong on 2017-03-16. */ class UIItemInventoryElem( parentUI: UIInventory, diff --git a/src/net/torvald/terrarum/console/JavaIMTest.kt b/src/net/torvald/terrarum/console/JavaIMTest.kt index 13351a5ef..1275c146e 100644 --- a/src/net/torvald/terrarum/console/JavaIMTest.kt +++ b/src/net/torvald/terrarum/console/JavaIMTest.kt @@ -3,7 +3,7 @@ package net.torvald.terrarum.console import net.torvald.terrarum.swingapp.IMStringReader /** - * Created by SKYHi14 on 2017-02-05. + * Created by minjaesong on 2017-02-05. */ internal object JavaIMTest : ConsoleCommand { diff --git a/src/net/torvald/terrarum/console/KillActor.kt b/src/net/torvald/terrarum/console/KillActor.kt index 3aad79d21..e04d96e4c 100644 --- a/src/net/torvald/terrarum/console/KillActor.kt +++ b/src/net/torvald/terrarum/console/KillActor.kt @@ -4,7 +4,7 @@ import net.torvald.terrarum.Terrarum import net.torvald.terrarum.langpack.Lang /** - * Created by SKYHi14 on 2017-01-31. + * Created by minjaesong on 2017-01-31. */ internal object KillActor : ConsoleCommand { override fun execute(args: Array) { diff --git a/src/net/torvald/terrarum/gameactors/ActorValue.kt b/src/net/torvald/terrarum/gameactors/ActorValue.kt index ada9da23e..7f1589ddf 100644 --- a/src/net/torvald/terrarum/gameactors/ActorValue.kt +++ b/src/net/torvald/terrarum/gameactors/ActorValue.kt @@ -3,7 +3,7 @@ package net.torvald.terrarum.gameactors import net.torvald.terrarum.KVHashMap /** - * Created by SKYHi14 on 2017-04-28. + * Created by minjaesong on 2017-04-28. */ class ActorValue(val actor: Actor) : KVHashMap() { diff --git a/src/net/torvald/terrarum/gameactors/PlayerBuilderTestSubject1.kt b/src/net/torvald/terrarum/gameactors/PlayerBuilderTestSubject1.kt index eb2a26f93..fab02f739 100644 --- a/src/net/torvald/terrarum/gameactors/PlayerBuilderTestSubject1.kt +++ b/src/net/torvald/terrarum/gameactors/PlayerBuilderTestSubject1.kt @@ -6,7 +6,7 @@ import net.torvald.terrarum.worlddrawer.FeaturesDrawer import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack /** - * Created by SKYHi14 on 2017-02-10. + * Created by minjaesong on 2017-02-10. */ object PlayerBuilderTestSubject1 { operator fun invoke(): Player { diff --git a/src/net/torvald/terrarum/gameactors/ai/LuaAIWrapper.kt b/src/net/torvald/terrarum/gameactors/ai/LuaAIWrapper.kt index 128f5e15e..6d5c721e0 100644 --- a/src/net/torvald/terrarum/gameactors/ai/LuaAIWrapper.kt +++ b/src/net/torvald/terrarum/gameactors/ai/LuaAIWrapper.kt @@ -13,7 +13,7 @@ import java.io.InputStreamReader import java.io.Reader /** - * Created by SKYHi14 on 2017-02-04. + * Created by minjaesong on 2017-02-04. */ class LuaAIWrapper(private val scriptPath: String) : ActorAI { diff --git a/src/net/torvald/terrarum/gameworld/GameEconomy.kt b/src/net/torvald/terrarum/gameworld/GameEconomy.kt index 36f3e35d8..5a0ba1716 100644 --- a/src/net/torvald/terrarum/gameworld/GameEconomy.kt +++ b/src/net/torvald/terrarum/gameworld/GameEconomy.kt @@ -9,7 +9,7 @@ import net.torvald.terrarum.gameactors.ActorID * Design goal: keep the inflation rate low, but not negative (Single market) * OR, give each faction (establishment) its own economy and watch them prosper/doomed (DF style) * - * Created by SKYHi14 on 2017-04-23. + * Created by minjaesong on 2017-04-23. */ class GameEconomy { diff --git a/src/net/torvald/terrarum/gameworld/MapLayerFloat.kt b/src/net/torvald/terrarum/gameworld/MapLayerFloat.kt index caa738dca..0a5c99e54 100644 --- a/src/net/torvald/terrarum/gameworld/MapLayerFloat.kt +++ b/src/net/torvald/terrarum/gameworld/MapLayerFloat.kt @@ -6,7 +6,7 @@ import net.torvald.dataclass.Float16Bits /** * MapLayer that contains raw Float16 values * - * Created by SKYHi14 on 2017-04-21. + * Created by minjaesong on 2017-04-21. */ class MapLayerFloat(val width: Int, val height: Int) : Iterable { diff --git a/src/net/torvald/terrarum/imagefont/NewRunes.kt b/src/net/torvald/terrarum/imagefont/NewRunes.kt index 323577cfb..3d20b01ca 100644 --- a/src/net/torvald/terrarum/imagefont/NewRunes.kt +++ b/src/net/torvald/terrarum/imagefont/NewRunes.kt @@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.g2d.GlyphLayout import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack /** - * Created by SKYHi14 on 2017-03-24. + * Created by minjaesong on 2017-03-24. */ class NewRunes : BitmapFont() { private val runeSize = 12 diff --git a/src/net/torvald/terrarum/itemproperties/Calculate.kt b/src/net/torvald/terrarum/itemproperties/Calculate.kt index fc812937f..8acabf114 100644 --- a/src/net/torvald/terrarum/itemproperties/Calculate.kt +++ b/src/net/torvald/terrarum/itemproperties/Calculate.kt @@ -3,7 +3,7 @@ package net.torvald.terrarum.itemproperties import net.torvald.terrarum.gameactors.* /** - * Created by SKYHi14 on 2017-04-17. + * Created by minjaesong on 2017-04-17. */ object Calculate { /** diff --git a/src/net/torvald/terrarum/itemproperties/ItemEffectsLuaAPI.kt b/src/net/torvald/terrarum/itemproperties/ItemEffectsLuaAPI.kt index 5e6a89e3b..6c355a8c6 100644 --- a/src/net/torvald/terrarum/itemproperties/ItemEffectsLuaAPI.kt +++ b/src/net/torvald/terrarum/itemproperties/ItemEffectsLuaAPI.kt @@ -9,7 +9,7 @@ import org.luaj.vm2.lib.ThreeArgFunction import org.luaj.vm2.lib.ZeroArgFunction /** - * Created by SKYHi14 on 2017-04-16. + * Created by minjaesong on 2017-04-16. */ class ItemEffectsLuaAPI(g: Globals) { diff --git a/src/net/torvald/terrarum/swingapp/IMStringReader.kt b/src/net/torvald/terrarum/swingapp/IMStringReader.kt index fc41ac0ee..be021dc17 100644 --- a/src/net/torvald/terrarum/swingapp/IMStringReader.kt +++ b/src/net/torvald/terrarum/swingapp/IMStringReader.kt @@ -22,7 +22,7 @@ import javax.swing.* * Although admittedly, Korean input does not require this hack, you can just write the Input Method * out of Java/Kotlin as the language does not need conversion (jp. Henkan) exists in Chinese and Japanese. * - * Created by SKYHi14 on 2017-02-05. + * Created by minjaesong on 2017-02-05. */ class IMStringReader(feedInput: (String) -> Unit, message: String? = null) : JFrame() { diff --git a/src/net/torvald/terrarum/ui/AmmoMeterProxy.kt b/src/net/torvald/terrarum/ui/AmmoMeterProxy.kt index 7f980c91c..afd970ec9 100644 --- a/src/net/torvald/terrarum/ui/AmmoMeterProxy.kt +++ b/src/net/torvald/terrarum/ui/AmmoMeterProxy.kt @@ -5,7 +5,7 @@ import net.torvald.terrarum.itemproperties.GameItem import net.torvald.terrarum.ui.UIVitalMetre /** - * Created by SKYHi14 on 2017-04-21. + * Created by minjaesong on 2017-04-21. */ object AmmoMeterProxy { diff --git a/src/net/torvald/terrarum/ui/ItemSlotImageBuilder.kt b/src/net/torvald/terrarum/ui/ItemSlotImageBuilder.kt index cac58c013..6f8ce2507 100644 --- a/src/net/torvald/terrarum/ui/ItemSlotImageBuilder.kt +++ b/src/net/torvald/terrarum/ui/ItemSlotImageBuilder.kt @@ -4,7 +4,9 @@ import com.badlogic.gdx.Gdx import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.Texture +import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.glutils.FrameBuffer +import net.torvald.terrarum.gameactors.ai.toInt import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack @@ -15,90 +17,27 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack */ object ItemSlotImageBuilder { + // FIXME it leaks mem waaaaagh + val colourBlack = Color(0x404040_FF) val colourWhite = Color(0xC0C0C0_FF.toInt()) - private val numberFont = TextureRegionPack( - "./assets/graphics/fonts/numeric_small.tga", 5, 8 - ) - val slotImage = Pixmap(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slot.tga")) // must have same w/h as slotLarge - val slotLarge = Pixmap(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slot_large.tga")) + val slotImage = TextureRegionPack(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slot.tga"), 38, 38) // must have same w/h as slotLarge + val slotLarge = TextureRegionPack(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slot_large.tga"), 38, 38) - private val imageDict = HashMap() + private val imageDict = HashMap() - fun produce(isBlack: Boolean, number: Int = -1): Texture { - val pixmap = Pixmap(slotImage.width, slotImage.height, Pixmap.Format.RGBA8888) - val color = if (isBlack) colourBlack else colourWhite - - - val desc = ImageDesc(color, number, false) - if (imageDict.containsKey(desc)) - return imageDict[desc]!! - - - pixmap.setColor(color) - pixmap.drawPixmap(slotImage, 0, 0) - - - /*if (number >= 0) { - if (isBlack) - pixmap.setColor(colourWhite) - else - pixmap.setColor(colourBlack) - - - pixmap.drawPixmap(fontPixmap, - slotImage.width - 10, - slotImage.height - 13 - ) - }*/ - - - val retTex = Texture(pixmap) - pixmap.dispose() - imageDict.put(desc, retTex) - return retTex + fun produce(isBlack: Boolean, number: Int = 10): TextureRegion { + return slotImage.get(number, 0) } - fun produceLarge(isBlack: Boolean, number: Int = -1): Texture { - val pixmap = Pixmap(slotLarge.width, slotLarge.height, Pixmap.Format.RGBA8888) - val color = if (isBlack) colourBlack else colourWhite - - - val desc = ImageDesc(color, number, false) - if (imageDict.containsKey(desc)) - return imageDict[desc]!! - - - pixmap.setColor(color) - pixmap.drawPixmap(slotLarge, 0, 0) - - - /*if (number >= 0) { - if (isBlack) - pixmap.setColor(colourWhite) - else - pixmap.setColor(colourBlack) - - - pixmap.drawPixmap(fontPixmap, - slotImage.width - 10, - slotImage.height - 13 - ) - }*/ - - - val retTex = Texture(pixmap) - pixmap.dispose() - imageDict.put(desc, retTex) - return retTex + fun produceLarge(isBlack: Boolean, number: Int = 10): TextureRegion { + return slotLarge.get(number, 0) } - private data class ImageDesc(val color: Color, val number: Int, val isLarge: Boolean) - fun dispose() { slotImage.dispose() slotLarge.dispose() diff --git a/src/net/torvald/terrarum/ui/NullUI.kt b/src/net/torvald/terrarum/ui/NullUI.kt index c2e07bd53..6c6fae503 100644 --- a/src/net/torvald/terrarum/ui/NullUI.kt +++ b/src/net/torvald/terrarum/ui/NullUI.kt @@ -3,7 +3,7 @@ package net.torvald.terrarum.ui import com.badlogic.gdx.graphics.g2d.SpriteBatch /** - * Created by SKYHi14 on 2017-03-13. + * Created by minjaesong on 2017-03-13. */ class NullUI : UICanvas() { override var width: Int = 0 diff --git a/src/net/torvald/terrarum/ui/UIInventory.kt b/src/net/torvald/terrarum/ui/UIInventory.kt index 8162e1d55..bcb1e882f 100644 --- a/src/net/torvald/terrarum/ui/UIInventory.kt +++ b/src/net/torvald/terrarum/ui/UIInventory.kt @@ -17,7 +17,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import java.util.* /** - * Created by SKYHi14 on 2017-03-13. + * Created by minjaesong on 2017-03-13. */ class UIInventory( var actor: Pocketed?, diff --git a/src/net/torvald/terrarum/ui/UIItemTextButton.kt b/src/net/torvald/terrarum/ui/UIItemTextButton.kt index 1495e7419..af32f9cfb 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextButton.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextButton.kt @@ -9,7 +9,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch /** * Text button. Height of hitbox is extended (double lineHeight, or 40 px) for better clicking * - * Created by SKYHi14 on 2017-03-13. + * Created by minjaesong on 2017-03-13. */ open class UIItemTextButton( parentUI: UICanvas, diff --git a/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt b/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt index e1b9f1173..b18865ca5 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt @@ -12,7 +12,7 @@ import net.torvald.terrarum.inUse import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack /** - * Created by SKYHi14 on 2017-03-13. + * Created by minjaesong on 2017-03-13. */ class UIItemTextButtonList( parentUI: UICanvas, diff --git a/src/net/torvald/terrarum/ui/UIPieMenu.kt b/src/net/torvald/terrarum/ui/UIPieMenu.kt index 1d96278ec..9d5743d68 100644 --- a/src/net/torvald/terrarum/ui/UIPieMenu.kt +++ b/src/net/torvald/terrarum/ui/UIPieMenu.kt @@ -65,7 +65,7 @@ class UIPieMenu : UICanvas() { else ItemSlotImageBuilder.produce(true, i + 1) - val slotSize = image.width + val slotSize = image.regionWidth val slotX = slotCentrePoint.x.toFloat() - (slotSize / 2) val slotY = slotCentrePoint.y.toFloat() - (slotSize / 2) diff --git a/src/net/torvald/terrarum/ui/UIQuickBar.kt b/src/net/torvald/terrarum/ui/UIQuickBar.kt index 947d22d99..fd369065f 100644 --- a/src/net/torvald/terrarum/ui/UIQuickBar.kt +++ b/src/net/torvald/terrarum/ui/UIQuickBar.kt @@ -14,15 +14,15 @@ import net.torvald.terrarum.itemproperties.ItemCodex */ class UIQuickBar : UICanvas() { private val gutter = 8 - override var width: Int = (ItemSlotImageBuilder.slotImage.width + gutter) * SLOT_COUNT - override var height: Int = ItemSlotImageBuilder.slotImage.height + 4 + Terrarum.fontGame.lineHeight.toInt() + override var width: Int = (ItemSlotImageBuilder.slotImage.tileW + gutter) * SLOT_COUNT + override var height: Int = ItemSlotImageBuilder.slotImage.tileH + 4 + Terrarum.fontGame.lineHeight.toInt() /** * In milliseconds */ override var openCloseTime: Second = 0.16f - private val startPointX = ItemSlotImageBuilder.slotLarge.width / 2 - private val startPointY = ItemSlotImageBuilder.slotLarge.height / 2 + private val startPointX = ItemSlotImageBuilder.slotLarge.tileW / 2 + private val startPointY = ItemSlotImageBuilder.slotLarge.tileH / 2 private var selection: Int get() = Terrarum.ingame!!.player.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0 diff --git a/src/net/torvald/terrarum/ui/UIUtils.kt b/src/net/torvald/terrarum/ui/UIUtils.kt index 63410c3b3..7490fe311 100644 --- a/src/net/torvald/terrarum/ui/UIUtils.kt +++ b/src/net/torvald/terrarum/ui/UIUtils.kt @@ -3,7 +3,7 @@ package net.torvald.terrarum.ui import net.torvald.terrarum.gameactors.sqr /** - * Created by SKYHi14 on 2017-03-14. + * Created by minjaesong on 2017-03-14. */ object UIUtils { fun moveQuick(start: Double, end: Double, timer: Double, duration: Double) = diff --git a/src/net/torvald/terrarum/ui/UIVitalMetre.kt b/src/net/torvald/terrarum/ui/UIVitalMetre.kt index dc5141fe5..74420cfa2 100644 --- a/src/net/torvald/terrarum/ui/UIVitalMetre.kt +++ b/src/net/torvald/terrarum/ui/UIVitalMetre.kt @@ -9,7 +9,7 @@ import net.torvald.terrarum.gameactors.ActorHumanoid import net.torvald.terrarum.gameactors.Second /** - * Created by SKYHi14 on 2017-03-03. + * Created by minjaesong on 2017-03-03. */ class UIVitalMetre( var player: ActorHumanoid, diff --git a/src/net/torvald/terrarum/virtualcomputer/peripheral/PeripheralVideoCard.kt b/src/net/torvald/terrarum/virtualcomputer/peripheral/PeripheralVideoCard.kt index b84e33f0d..477945dc9 100644 --- a/src/net/torvald/terrarum/virtualcomputer/peripheral/PeripheralVideoCard.kt +++ b/src/net/torvald/terrarum/virtualcomputer/peripheral/PeripheralVideoCard.kt @@ -6,7 +6,7 @@ import org.luaj.vm2.lib.* /** * Resolution: 640 x 200, non-square pixels * - * Created by SKYHi14 on 2017-02-08. + * Created by minjaesong on 2017-02-08. */ /*class PeripheralVideoCard(val host: TerrarumComputer, val termW: Int = 80, val termH: Int = 25) : Peripheral("ppu") { diff --git a/src/net/torvald/terrarum/virtualcomputer/terminal/GraphicsTerminal.kt b/src/net/torvald/terrarum/virtualcomputer/terminal/GraphicsTerminal.kt index bd6fd423d..0a2fff5a0 100644 --- a/src/net/torvald/terrarum/virtualcomputer/terminal/GraphicsTerminal.kt +++ b/src/net/torvald/terrarum/virtualcomputer/terminal/GraphicsTerminal.kt @@ -10,7 +10,7 @@ import java.util.* * Printing text using Term API triggers 'compatibility' mode, where you are limited to 16 colours. * Use PPU API for full 64 colours! * - * Created by SKYHi14 on 2017-02-08. + * Created by minjaesong on 2017-02-08. */ /*class GraphicsTerminal(private val host: TerrarumComputer) : Terminal { lateinit var videoCard: PeripheralVideoCard diff --git a/src/net/torvald/terrarum/virtualcomputer/tvd/VDUtil.kt b/src/net/torvald/terrarum/virtualcomputer/tvd/VDUtil.kt index 94c8f777b..0ad73b6b8 100644 --- a/src/net/torvald/terrarum/virtualcomputer/tvd/VDUtil.kt +++ b/src/net/torvald/terrarum/virtualcomputer/tvd/VDUtil.kt @@ -8,7 +8,7 @@ import javax.naming.OperationNotSupportedException import kotlin.collections.ArrayList /** - * Created by SKYHi14 on 2017-04-01. + * Created by minjaesong on 2017-04-01. */ object VDUtil { class VDPath() { diff --git a/src/net/torvald/terrarum/virtualcomputer/tvd/VirtualDisk.kt b/src/net/torvald/terrarum/virtualcomputer/tvd/VirtualDisk.kt index e1c20d7d2..62f586fb7 100644 --- a/src/net/torvald/terrarum/virtualcomputer/tvd/VirtualDisk.kt +++ b/src/net/torvald/terrarum/virtualcomputer/tvd/VirtualDisk.kt @@ -7,7 +7,7 @@ import java.util.function.Consumer import java.util.zip.CRC32 /** - * Created by SKYHi14 on 2017-03-31. + * Created by minjaesong on 2017-03-31. */ typealias EntryID = Int diff --git a/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt b/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt index 1c32acdf3..ae9c09af0 100644 --- a/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt +++ b/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt @@ -105,6 +105,10 @@ object LightmapRenderer { } } + fun fireRecalculateEventtt() { + + } + fun fireRecalculateEvent() { for_x_start = WorldCamera.x / TILE_SIZE - 1 // fix for premature lightmap rendering for_y_start = WorldCamera.y / TILE_SIZE - 1 // on topmost/leftmost side @@ -116,7 +120,7 @@ object LightmapRenderer { * * true: overscanning is limited to 8 tiles in width (overscan_opaque) * * false: overscanning will fully applied to 32 tiles in width (overscan_open) */ - val rect_width = for_x_end - for_x_start + /*val rect_width = for_x_end - for_x_start val rect_height_rem_hbars = for_y_end - for_y_start - 2 val noop_mask = BitSet(2 * (rect_width) + 2 * (rect_height_rem_hbars)) @@ -182,7 +186,7 @@ object LightmapRenderer { val isSolid = BlockCodex[tile].isSolid noop_mask.set(i, isSolid) - } + }*/ /** * Updating order: @@ -263,20 +267,32 @@ object LightmapRenderer { } } + + + private var ambientAccumulator = Color(0f,0f,0f,0f) + private var lightLevelThis = Color(0f,0f,0f,0f) + private var thisTerrain = 0 + private var thisWall = 0 + private var thisTileLuminosity = Color(0f,0f,0f,0f) + private var thisTileOpacity = Color(0f,0f,0f,0f) + private var sunLight = Color(0f,0f,0f,0f) + + private fun calculate(x: Int, y: Int, pass: Int): Color = calculate(x, y, pass, false) private fun calculate(x: Int, y: Int, pass: Int, doNotCalculateAmbient: Boolean): Color { // O(9n) == O(n) where n is a size of the map // TODO devise multithreading on this - var ambientAccumulator = Color(0f,0f,0f,0f) + ambientAccumulator = Color(0f,0f,0f,0f) + + lightLevelThis = Color(0f,0f,0f,0f) + thisTerrain = world.getTileFromTerrain(x, y) ?: Block.STONE + thisWall = world.getTileFromWall(x, y) ?: Block.STONE + thisTileLuminosity = BlockCodex[thisTerrain].luminosity // already been div by four + thisTileOpacity = BlockCodex[thisTerrain].opacity // already been div by four + sunLight = world.globalLight.cpy().mul(DIV_FLOAT) - var lightLevelThis: Color = Color(0f,0f,0f,0f) - val thisTerrain = world.getTileFromTerrain(x, y) - val thisWall = world.getTileFromWall(x, y) - val thisTileLuminosity = BlockCodex[thisTerrain].luminosity // already been div by four - val thisTileOpacity = BlockCodex[thisTerrain].opacity // already been div by four - val sunLight = world.globalLight.cpy().mul(DIV_FLOAT) // MIX TILE // open air