minor edits

Former-commit-id: 727c880ff913f72cf17f89155c35966f38224c07
Former-commit-id: 65d4bf1045440de7d23efd3ef43176e1cddfa1e4
This commit is contained in:
Song Minjae
2016-12-18 23:21:51 +09:00
parent ea1e90b035
commit 01def757e9
5 changed files with 52 additions and 39 deletions

View File

@@ -29,7 +29,7 @@ open class ActorWithBody : Actor() {
@Transient internal var sprite: SpriteAnimation? = null
@Transient internal var spriteGlow: SpriteAnimation? = null
protected var drawMode: DrawMode = DrawMode.NORMAL
var drawMode = BLEND_NORMAL
@Transient private val world: GameWorld = Terrarum.ingame.world
@@ -211,10 +211,7 @@ open class ActorWithBody : Actor() {
@Transient internal val BASE_FRICTION = 0.3
@Transient val KINEMATIC = 1 // does not displaced by external forces
@Transient val DYNAMIC = 2 // displaced by external forces
@Transient val STATIC = 3 // does not displaced by external forces, target of collision
var collisionType = DYNAMIC
var collisionType = COLLISION_DYNAMIC
@Transient private val CCD_TICK = 1.0 / 16.0
@Transient private val CCD_TRY_MAX = 12800
@@ -935,9 +932,9 @@ open class ActorWithBody : Actor() {
open fun drawBody(gc: GameContainer, g: Graphics) {
if (isVisible && sprite != null) {
when (drawMode) {
DrawMode.NORMAL -> blendNormal()
DrawMode.MULTIPLY -> blendMul()
DrawMode.SCREEN -> blendScreen()
BLEND_NORMAL -> blendNormal()
BLEND_MULTIPLY -> blendMul()
BLEND_SCREEN -> blendScreen()
}
if (!sprite!!.flippedHorizontal()) {
@@ -1080,6 +1077,16 @@ open class ActorWithBody : Actor() {
companion object {
/**
* Enumerations that exported to JSON
*/
@Transient const val COLLISION_KINEMATIC = 1 // does not displaced by external forces
@Transient const val COLLISION_DYNAMIC = 2 // displaced by external forces
@Transient const val COLLISION_STATIC = 3 // does not displaced by external forces, target of collision
@Transient const val BLEND_NORMAL = 4
@Transient const val BLEND_SCREEN = 5
@Transient const val BLEND_MULTIPLY = 6
@Transient private val TILE_SIZE = MapDrawer.TILE_SIZE
private fun div16TruncateToMapWidth(x: Int): Int {
@@ -1140,7 +1147,3 @@ fun absMax(left: Double, right: Double): Double {
fun Double.magnSqr() = if (this >= 0.0) this.sqr() else -this.sqr()
fun Double.sign() = if (this > 0.0) 1.0 else if (this < 0.0) -1.0 else 0.0
enum class DrawMode {
NORMAL, SCREEN, MULTIPLY
}

View File

@@ -43,7 +43,7 @@ class Player(born: GameDate) : ActorHumanoid(born) {
isVisible = true
referenceID = PLAYER_REF_ID // forcibly set ID
density = BASE_DENSITY
collisionType = KINEMATIC
collisionType = COLLISION_KINEMATIC
try {
gamepad = Controllers.getController(0)

View File

@@ -63,7 +63,7 @@ open class ProjectileSimple(
collisionType = KINEMATIC
collisionType = COLLISION_KINEMATIC
}
override fun update(gc: GameContainer, delta: Int) {

View File

@@ -304,10 +304,22 @@ object LightmapRenderer {
ambient = darkenColoured(ambient, thisTileOpacity) // get real ambient by appling opacity value
// mix and return lightlevel and ambient
return lightLevelThis maxBlend ambient
// mix and return lightlevel and ambient
/*val retLevel = lightLevelThis maxBlend ambient
// hack: make sure (3,3,3) become 0
return if (retLevel.rawR() < 4 && retLevel.rawG() < 4 && retLevel.rawB() < 4)
0
else
retLevel*/
}
else {
// hack: make sure (3,3,3) become 0
/*return if (lightLevelThis.rawR() < 4 && lightLevelThis.rawG() < 4 && lightLevelThis.rawB() < 4)
0
else
lightLevelThis*/
return lightLevelThis
}
}

View File

@@ -11,10 +11,7 @@ import net.torvald.terrarum.blendMul
import net.torvald.terrarum.blendNormal
import net.torvald.terrarum.mapdrawer.MapDrawer.TILE_SIZE
import org.lwjgl.opengl.GL11
import org.newdawn.slick.GameContainer
import org.newdawn.slick.Graphics
import org.newdawn.slick.SlickException
import org.newdawn.slick.SpriteSheet
import org.newdawn.slick.*
import java.util.*
/**
@@ -255,17 +252,17 @@ object MapCamera {
* render to camera
*/
blendNormal()
drawTiles(WALL, false)
drawTiles(TERRAIN, false)
drawTiles(g, WALL, false)
drawTiles(g, TERRAIN, false)
}
fun renderFront(gc: GameContainer, g: Graphics) {
blendMul()
drawTiles(TERRAIN, true)
drawTiles(g, TERRAIN, true)
blendNormal()
}
private fun drawTiles(mode: Int, drawModeTilesBlendMul: Boolean) {
private fun drawTiles(g: Graphics, mode: Int, drawModeTilesBlendMul: Boolean) {
val for_y_start = MapCamera.cameraY / TILE_SIZE
val for_y_end = MapCamera.clampHTile(for_y_start + (MapCamera.renderHeight / TILE_SIZE) + 2)
@@ -275,6 +272,8 @@ object MapCamera {
// initialise
MapCamera.tilesetBook[mode].startUse()
var zeroTileCounter = 0
// loop
for (y in for_y_start..for_y_end) {
for (x in for_x_start..for_x_end - 1) {
@@ -294,23 +293,19 @@ object MapCamera {
// draw
try {
if (
(mode == WALL || mode == TERRAIN) // not an air tile
&& (thisTile ?: 0) > 0
&&
(mode == WALL || mode == TERRAIN) && // not an air tile
(thisTile ?: 0) > 0) //&& // commented out: meh
// check if light level of nearby or this tile is illuminated
( LightmapRenderer.getValueFromMap(x, y) ?: 0 > 0
|| LightmapRenderer.getValueFromMap(x - 1, y) ?: 0 > 0
|| LightmapRenderer.getValueFromMap(x + 1, y) ?: 0 > 0
|| LightmapRenderer.getValueFromMap(x, y - 1) ?: 0 > 0
|| LightmapRenderer.getValueFromMap(x, y + 1) ?: 0 > 0
|| LightmapRenderer.getValueFromMap(x - 1, y - 1) ?: 0 > 0
|| LightmapRenderer.getValueFromMap(x + 1, y + 1) ?: 0 > 0
|| LightmapRenderer.getValueFromMap(x + 1, y - 1) ?: 0 > 0
|| LightmapRenderer.getValueFromMap(x - 1, y + 1) ?: 0 > 0)
) {
/*( LightmapRenderer.getValueFromMap(x, y) ?: 0 > 0 ||
LightmapRenderer.getValueFromMap(x - 1, y) ?: 0 > 0 ||
LightmapRenderer.getValueFromMap(x + 1, y) ?: 0 > 0 ||
LightmapRenderer.getValueFromMap(x, y - 1) ?: 0 > 0 ||
LightmapRenderer.getValueFromMap(x, y + 1) ?: 0 > 0 ||
LightmapRenderer.getValueFromMap(x - 1, y - 1) ?: 0 > 0 ||
LightmapRenderer.getValueFromMap(x + 1, y + 1) ?: 0 > 0 ||
LightmapRenderer.getValueFromMap(x + 1, y - 1) ?: 0 > 0 ||
LightmapRenderer.getValueFromMap(x - 1, y + 1) ?: 0 > 0)
)*/ {
val nearbyTilesInfo: Int
if (isPlatform(thisTile)) {
nearbyTilesInfo = getNearbyTilesInfoPlatform(x, y)
@@ -346,6 +341,9 @@ object MapCamera {
// or else they will not look like they should be when backed with wall
drawTile(mode, x, y, thisTileX, thisTileY)
}
} // end if (not an air and is illuminated)
else {
zeroTileCounter++
}
} catch (e: NullPointerException) {
// do nothing. WARNING: This exception handling may hide erratic behaviour completely.