mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
blocks camera and framebuffer seems working
This commit is contained in:
@@ -416,24 +416,85 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
|
||||
|
||||
|
||||
worldDrawFrameBuffer.inAction {
|
||||
batch.inUse {
|
||||
camera.position.set(WorldCamera.gdxCamX, WorldCamera.gdxCamY, 0f) // make camara work
|
||||
camera.update()
|
||||
batch.projectionMatrix = camera.combined
|
||||
|
||||
|
||||
|
||||
blendNormal()
|
||||
|
||||
|
||||
|
||||
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()
|
||||
//blendMul()
|
||||
//LightmapRenderer.draw(batch)
|
||||
|
||||
|
||||
|
||||
//////////////////////
|
||||
// draw actor glows //
|
||||
//////////////////////
|
||||
// needs some new blending/shader for glow...
|
||||
|
||||
//actorsRenderMiddle.forEach { it.drawGlow(batch) }
|
||||
//actorsRenderMidTop.forEach { it.drawGlow(batch) }
|
||||
player?.drawGlow(batch)
|
||||
//actorsRenderFront.forEach { it.drawGlow(batch) }
|
||||
// --> blendLightenOnly() <-- introduced by childs of ActorWithBody //
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// draw framebuffers to screen //
|
||||
/////////////////////////////////
|
||||
blendNormal()
|
||||
batch.inUse {
|
||||
camera.position.set(WorldCamera.gdxCamX, WorldCamera.gdxCamY, 0f) // make camara work
|
||||
camera.position.set(TerrarumGDX.HALFW.toFloat(), TerrarumGDX.HALFH.toFloat(), 0f) // make camara work
|
||||
camera.update()
|
||||
batch.projectionMatrix = camera.combined
|
||||
|
||||
WeatherMixer.render(batch) // drawing to gwin so that any lights from lamp wont "leak" to the skybox
|
||||
// e.g. Bright blue light on sunset
|
||||
|
||||
WeatherMixer.render(batch)
|
||||
|
||||
LightmapRenderer.renderLightMap()
|
||||
|
||||
BlocksDrawer.renderWall(batch)
|
||||
BlocksDrawer.renderTerrain(batch)
|
||||
|
||||
|
||||
batch.color = Color.WHITE
|
||||
player?.drawBody(batch)
|
||||
val tex = worldDrawFrameBuffer.colorBufferTexture // TODO zoom!
|
||||
batch.draw(tex, 0f, 0f, Gdx.graphics.width.toFloat(), Gdx.graphics.height.toFloat())
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ fun main(args: Array<String>) {
|
||||
config.height = 742
|
||||
config.backgroundFPS = 9999
|
||||
config.foregroundFPS = 9999
|
||||
//config.useGL30 = true
|
||||
config.title = GAME_NAME
|
||||
|
||||
LwjglApplication(TerrarumGDX, config)
|
||||
@@ -491,7 +492,7 @@ object TerrarumGDX : ApplicationAdapter() {
|
||||
|
||||
}
|
||||
|
||||
inline fun Batch.inUse(action: (Batch) -> Unit) {
|
||||
inline fun SpriteBatch.inUse(action: (SpriteBatch) -> Unit) {
|
||||
this.begin()
|
||||
action(this)
|
||||
this.end()
|
||||
|
||||
@@ -34,7 +34,7 @@ typealias Second = Float
|
||||
open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean = false, physics: Boolean = true) : ActorWithBody(renderOrder) {
|
||||
|
||||
|
||||
val COLLISION_TEST_MODE = true
|
||||
val COLLISION_TEST_MODE = false
|
||||
|
||||
/** !! ActorValue macros are on the very bottom of the source !! **/
|
||||
|
||||
@@ -323,10 +323,6 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
override fun update(delta: Float) {
|
||||
if (isUpdate && !flagDespawn) {
|
||||
|
||||
hitbox.translate(0.0, 2.0)
|
||||
|
||||
|
||||
|
||||
if (!assertPrinted) assertInit()
|
||||
|
||||
if (sprite != null) sprite!!.update(delta)
|
||||
@@ -339,6 +335,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
isNoSubjectToFluidResistance = isPlayerNoClip
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Codes that modifies velocity (moveDelta and externalForce) //
|
||||
////////////////////////////////////////////////////////////////
|
||||
@@ -488,6 +485,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
* Apply only if not grounded; normal force is precessed separately.
|
||||
*/
|
||||
private fun applyGravitation() {
|
||||
|
||||
if (!isNoSubjectToGrav && !(gravitation.y > 0 && walledBottom || gravitation.y < 0 && walledTop)) {
|
||||
//if (!isWalled(hitbox, COLLIDING_BOTTOM)) {
|
||||
/**
|
||||
|
||||
@@ -484,18 +484,11 @@ object BlocksDrawer {
|
||||
else {
|
||||
zeroTileCounter++ // unused for now
|
||||
|
||||
GL11.glColor4f(0f, 0f, 0f, 1f)
|
||||
batch.color = Color.BLACK
|
||||
|
||||
GL11.glTexCoord2f(0f, 0f)
|
||||
GL11.glVertex3f(x * TILE_SIZE.toFloat(), y * TILE_SIZE.toFloat(), 0f)
|
||||
GL11.glTexCoord2f(0f, 0f + TILE_SIZE)
|
||||
GL11.glVertex3f(x * TILE_SIZE.toFloat(), (y + 1) * TILE_SIZE.toFloat(), 0f)
|
||||
GL11.glTexCoord2f(0f + TILE_SIZE, 0f + TILE_SIZE)
|
||||
GL11.glVertex3f((x + 1) * TILE_SIZE.toFloat(), (y + 1) * TILE_SIZE.toFloat(), 0f)
|
||||
GL11.glTexCoord2f(0f + TILE_SIZE, 0f)
|
||||
GL11.glVertex3f((x + 1) * TILE_SIZE.toFloat(), y * TILE_SIZE.toFloat(), 0f)
|
||||
batch.fillRect(x.toFloat(), y.toFloat(), TILE_SIZEF, TILE_SIZEF)
|
||||
|
||||
GL11.glColor4f(1f, 1f, 1f, 1f)
|
||||
batch.color = Color.WHITE
|
||||
}
|
||||
} // end if (not an air)
|
||||
} catch (e: NullPointerException) {
|
||||
|
||||
BIN
work_files/graphics/fonts/furigana.psd
LFS
Normal file
BIN
work_files/graphics/fonts/furigana.psd
LFS
Normal file
Binary file not shown.
Reference in New Issue
Block a user