working ZOOM IN (zoom out still broken)

Former-commit-id: 40d72f2ebfcaffe40e1875a7a76d05ff06ad0323
Former-commit-id: c5fae728ab10693f0fb7ae1ece109ad88cbedd0c
This commit is contained in:
Song Minjae
2016-12-18 02:41:23 +09:00
parent 011dd5a2d8
commit dcb797114c
2 changed files with 23 additions and 26 deletions

View File

@@ -326,8 +326,7 @@ object LightmapRenderer {
var x = this_x_start var x = this_x_start
while (x < this_x_end) { while (x < this_x_end) {
// smoothing enabled // smoothing enabled
if (Terrarum.ingame.screenZoom >= 1 if (Terrarum.gameConfig.getAsBoolean("smoothlighting") ?: false) {
&& Terrarum.gameConfig.getAsBoolean("smoothlighting") ?: false) {
val thisLightLevel = getLight(x, y) ?: 0 val thisLightLevel = getLight(x, y) ?: 0
@@ -344,10 +343,10 @@ object LightmapRenderer {
g.color = Color(0) g.color = Color(0)
g.fillRect( g.fillRect(
(x.toFloat() * TILE_SIZE.toFloat() * Terrarum.ingame.screenZoom).round().toFloat(), (x.toFloat() * TILE_SIZE).round().toFloat(),
(y.toFloat() * TILE_SIZE.toFloat() * Terrarum.ingame.screenZoom).round().toFloat(), (y.toFloat() * TILE_SIZE).round().toFloat(),
((TILE_SIZE * Terrarum.ingame.screenZoom).ceil() * zeroLevelCounter).toFloat(), (TILE_SIZE * zeroLevelCounter).toFloat(),
(TILE_SIZE * Terrarum.ingame.screenZoom).ceil().toFloat() (TILE_SIZE).toFloat()
) )
x += zeroLevelCounter - 1 x += zeroLevelCounter - 1
@@ -385,12 +384,12 @@ object LightmapRenderer {
g.color = colourMapItoL[iy * 2 + ix].normaliseToColour() g.color = colourMapItoL[iy * 2 + ix].normaliseToColour()
g.fillRect( g.fillRect(
(x.toFloat() * TILE_SIZE.toFloat() * Terrarum.ingame.screenZoom).round() (x.toFloat() * TILE_SIZE).round()
+ ix * TILE_SIZE / 2 * Terrarum.ingame.screenZoom, + ix * TILE_SIZE / 2f,
(y.toFloat() * TILE_SIZE.toFloat() * Terrarum.ingame.screenZoom).round() (y.toFloat() * TILE_SIZE).round()
+ iy * TILE_SIZE / 2 * Terrarum.ingame.screenZoom, + iy * TILE_SIZE / 2f,
(TILE_SIZE * Terrarum.ingame.screenZoom / 2).ceil().toFloat(), (TILE_SIZE / 2f).ceil().toFloat(),
(TILE_SIZE * Terrarum.ingame.screenZoom / 2).ceil().toFloat() (TILE_SIZE / 2f).ceil().toFloat()
) )
} }
} }
@@ -411,10 +410,10 @@ object LightmapRenderer {
g.color = (getLight(x, y) ?: 0).normaliseToColour() g.color = (getLight(x, y) ?: 0).normaliseToColour()
g.fillRect( g.fillRect(
(x.toFloat() * TILE_SIZE.toFloat() * Terrarum.ingame.screenZoom).round().toFloat(), (x.toFloat() * TILE_SIZE).round().toFloat(),
(y.toFloat() * TILE_SIZE.toFloat() * Terrarum.ingame.screenZoom).round().toFloat(), (y.toFloat() * TILE_SIZE).round().toFloat(),
((TILE_SIZE * Terrarum.ingame.screenZoom).ceil() * sameLevelCounter).toFloat(), (TILE_SIZE.toFloat().ceil() * sameLevelCounter).toFloat(),
(TILE_SIZE * Terrarum.ingame.screenZoom).ceil().toFloat() TILE_SIZE.toFloat().ceil().toFloat()
) )
x += sameLevelCounter - 1 x += sameLevelCounter - 1

View File

@@ -246,7 +246,8 @@ object MapCamera {
cameraX = Math.round( // X only: ROUNDWORLD implementation cameraX = Math.round( // X only: ROUNDWORLD implementation
player.hitbox.centeredX.toFloat() - renderWidth / 2) player.hitbox.centeredX.toFloat() - renderWidth / 2)
cameraY = Math.round(FastMath.clamp( cameraY = Math.round(FastMath.clamp(
player.hitbox.centeredY.toFloat() - renderHeight / 2, TILE_SIZE.toFloat(), world.height * TILE_SIZE - renderHeight - TILE_SIZE.toFloat())) player.hitbox.centeredY.toFloat() - renderHeight / 2,
TILE_SIZE.toFloat(), world.height * TILE_SIZE - renderHeight - TILE_SIZE.toFloat()))
} }
@@ -270,7 +271,7 @@ object MapCamera {
val for_y_end = MapCamera.clampHTile(for_y_start + (MapCamera.renderHeight / TILE_SIZE) + 2) val for_y_end = MapCamera.clampHTile(for_y_start + (MapCamera.renderHeight / TILE_SIZE) + 2)
val for_x_start = MapCamera.cameraX / TILE_SIZE - 1 val for_x_start = MapCamera.cameraX / TILE_SIZE - 1
val for_x_end = for_x_start + (MapCamera.renderWidth / TILE_SIZE) + 2 val for_x_end = for_x_start + (MapCamera.renderWidth / TILE_SIZE) + 3
// initialise // initialise
MapCamera.tilesetBook[mode].startUse() MapCamera.tilesetBook[mode].startUse()
@@ -435,14 +436,11 @@ object MapCamera {
} }
private fun drawTile(mode: Int, tilewisePosX: Int, tilewisePosY: Int, sheetX: Int, sheetY: Int) { private fun drawTile(mode: Int, tilewisePosX: Int, tilewisePosY: Int, sheetX: Int, sheetY: Int) {
if (Terrarum.ingame.screenZoom == 1f) { tilesetBook[mode].renderInUse(
tilesetBook[mode].renderInUse( FastMath.floor((tilewisePosX * TILE_SIZE).toFloat()),
FastMath.floor((tilewisePosX * TILE_SIZE).toFloat()), FastMath.floor((tilewisePosY * TILE_SIZE).toFloat()), sheetX, sheetY) FastMath.floor((tilewisePosY * TILE_SIZE).toFloat()),
} else { sheetX, sheetY
tilesetBook[mode].getSprite( )
sheetX, sheetY).drawEmbedded(
Math.round(tilewisePosX.toFloat() * TILE_SIZE.toFloat() * Terrarum.ingame.screenZoom).toFloat(), Math.round(tilewisePosY.toFloat() * TILE_SIZE.toFloat() * Terrarum.ingame.screenZoom).toFloat(), FastMath.ceil(TILE_SIZE * Terrarum.ingame.screenZoom).toFloat(), FastMath.ceil(TILE_SIZE * Terrarum.ingame.screenZoom).toFloat())
}
} }
fun clampH(x: Int): Int { fun clampH(x: Int): Int {