separated Camera from TileDrawer (was MapCamera)

Former-commit-id: b2fe7716722634b03f3750fade420d26022500f9
Former-commit-id: 521826d176c6902007646e6b9b9c7b5d4f3468cf
This commit is contained in:
Song Minjae
2016-12-30 02:47:15 +09:00
parent 9a8090038e
commit ac05b5edf1
18 changed files with 623 additions and 595 deletions

View File

@@ -17,9 +17,10 @@ import net.torvald.terrarum.gameworld.WorldSimulator
import net.torvald.terrarum.gameworld.WorldTime
import net.torvald.terrarum.mapdrawer.LightmapRenderer
import net.torvald.terrarum.mapdrawer.LightmapRenderer.constructRGBFromInt
import net.torvald.terrarum.mapdrawer.TilesDrawer
import net.torvald.terrarum.mapdrawer.FeaturesDrawer
import net.torvald.terrarum.mapdrawer.FeaturesDrawer.TILE_SIZE
import net.torvald.terrarum.mapdrawer.MapCamera
import net.torvald.terrarum.mapdrawer.MapDrawer
import net.torvald.terrarum.mapdrawer.MapDrawer.TILE_SIZE
import net.torvald.terrarum.mapgenerator.WorldGenerator
import net.torvald.terrarum.mapgenerator.RoguelikeRandomiser
import net.torvald.terrarum.tileproperties.TileCodex
@@ -199,8 +200,9 @@ constructor() : BasicGameState() {
////////////////////////////
// camera-related updates //
////////////////////////////
MapDrawer.update(gc, delta)
MapCamera.update(gc, delta)
FeaturesDrawer.update(gc, delta)
MapCamera.update()
TilesDrawer.update()
///////////////////////////
@@ -288,14 +290,14 @@ constructor() : BasicGameState() {
// make camara work //
// compensate for zoom. UIs must be treated specially! (see UIHandler)
//g.translate(-MapCamera.cameraX * screenZoom, -MapCamera.cameraY * screenZoom)
worldDrawFrameBuffer.graphics.translate(-MapCamera.cameraX.toFloat(), -MapCamera.cameraY.toFloat())
//g.translate(-MapCamera.x * screenZoom, -MapCamera.y * screenZoom)
worldDrawFrameBuffer.graphics.translate(-MapCamera.x.toFloat(), -MapCamera.y.toFloat())
/////////////////////////////
// draw map related stuffs //
/////////////////////////////
MapCamera.renderBehind(gc, worldDrawFrameBuffer.graphics)
TilesDrawer.renderBehind(gc, worldDrawFrameBuffer.graphics)
/////////////////
@@ -316,14 +318,14 @@ constructor() : BasicGameState() {
/////////////////////////////
LightmapRenderer.renderLightMap()
// --> blendMul() <-- by MapCamera.renderFront
MapCamera.renderFront(gc, worldDrawFrameBuffer.graphics)
// --> blendNormal() <-- by MapCamera.renderFront
MapDrawer.render(gc, worldDrawFrameBuffer.graphics)
// --> blendMul() <-- by TilesDrawer.renderFront
TilesDrawer.renderFront(gc, worldDrawFrameBuffer.graphics)
// --> blendNormal() <-- by TilesDrawer.renderFront
FeaturesDrawer.render(gc, worldDrawFrameBuffer.graphics)
// --> blendMul() <-- by MapCamera.drawEnvOverlay
MapDrawer.drawEnvOverlay(worldDrawFrameBuffer.graphics)
// --> blendMul() <-- by TilesDrawer.drawEnvOverlay
FeaturesDrawer.drawEnvOverlay(worldDrawFrameBuffer.graphics)
if (!KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) blendMul()
else blendNormal()
@@ -558,12 +560,12 @@ constructor() : BasicGameState() {
)
private fun distToCameraSqr(a: ActorWithBody) =
min(
(a.hitbox.posX - MapCamera.cameraX).sqr() +
(a.hitbox.posY - MapCamera.cameraY).sqr(),
(a.hitbox.posX - MapCamera.cameraX + world.width * TILE_SIZE).sqr() +
(a.hitbox.posY - MapCamera.cameraY).sqr(),
(a.hitbox.posX - MapCamera.cameraX - world.width * TILE_SIZE).sqr() +
(a.hitbox.posY - MapCamera.cameraY).sqr()
(a.hitbox.posX - MapCamera.x).sqr() +
(a.hitbox.posY - MapCamera.y).sqr(),
(a.hitbox.posX - MapCamera.x + world.width * TILE_SIZE).sqr() +
(a.hitbox.posY - MapCamera.y).sqr(),
(a.hitbox.posX - MapCamera.x - world.width * TILE_SIZE).sqr() +
(a.hitbox.posY - MapCamera.y).sqr()
)
/** whether the actor is within screen */