mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
leak patched I guess
This commit is contained in:
@@ -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;*/
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-04-26.
|
||||
* Created by minjaesong on 2017-04-26.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<String>) {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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<Float16Bits> {
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
/**
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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<ImageDesc, Texture>()
|
||||
private val imageDict = HashMap<Long, Texture>()
|
||||
|
||||
|
||||
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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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?,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) =
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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") {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user