mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
minor edits
Former-commit-id: 727c880ff913f72cf17f89155c35966f38224c07 Former-commit-id: 65d4bf1045440de7d23efd3ef43176e1cddfa1e4
This commit is contained in:
@@ -29,7 +29,7 @@ open class ActorWithBody : Actor() {
|
|||||||
@Transient internal var sprite: SpriteAnimation? = null
|
@Transient internal var sprite: SpriteAnimation? = null
|
||||||
@Transient internal var spriteGlow: 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
|
@Transient private val world: GameWorld = Terrarum.ingame.world
|
||||||
|
|
||||||
@@ -211,10 +211,7 @@ open class ActorWithBody : Actor() {
|
|||||||
|
|
||||||
@Transient internal val BASE_FRICTION = 0.3
|
@Transient internal val BASE_FRICTION = 0.3
|
||||||
|
|
||||||
@Transient val KINEMATIC = 1 // does not displaced by external forces
|
var collisionType = COLLISION_DYNAMIC
|
||||||
@Transient val DYNAMIC = 2 // displaced by external forces
|
|
||||||
@Transient val STATIC = 3 // does not displaced by external forces, target of collision
|
|
||||||
var collisionType = DYNAMIC
|
|
||||||
|
|
||||||
@Transient private val CCD_TICK = 1.0 / 16.0
|
@Transient private val CCD_TICK = 1.0 / 16.0
|
||||||
@Transient private val CCD_TRY_MAX = 12800
|
@Transient private val CCD_TRY_MAX = 12800
|
||||||
@@ -935,9 +932,9 @@ open class ActorWithBody : Actor() {
|
|||||||
open fun drawBody(gc: GameContainer, g: Graphics) {
|
open fun drawBody(gc: GameContainer, g: Graphics) {
|
||||||
if (isVisible && sprite != null) {
|
if (isVisible && sprite != null) {
|
||||||
when (drawMode) {
|
when (drawMode) {
|
||||||
DrawMode.NORMAL -> blendNormal()
|
BLEND_NORMAL -> blendNormal()
|
||||||
DrawMode.MULTIPLY -> blendMul()
|
BLEND_MULTIPLY -> blendMul()
|
||||||
DrawMode.SCREEN -> blendScreen()
|
BLEND_SCREEN -> blendScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sprite!!.flippedHorizontal()) {
|
if (!sprite!!.flippedHorizontal()) {
|
||||||
@@ -1080,6 +1077,16 @@ open class ActorWithBody : Actor() {
|
|||||||
|
|
||||||
companion object {
|
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
|
@Transient private val TILE_SIZE = MapDrawer.TILE_SIZE
|
||||||
|
|
||||||
private fun div16TruncateToMapWidth(x: Int): Int {
|
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.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
|
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
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class Player(born: GameDate) : ActorHumanoid(born) {
|
|||||||
isVisible = true
|
isVisible = true
|
||||||
referenceID = PLAYER_REF_ID // forcibly set ID
|
referenceID = PLAYER_REF_ID // forcibly set ID
|
||||||
density = BASE_DENSITY
|
density = BASE_DENSITY
|
||||||
collisionType = KINEMATIC
|
collisionType = COLLISION_KINEMATIC
|
||||||
|
|
||||||
try {
|
try {
|
||||||
gamepad = Controllers.getController(0)
|
gamepad = Controllers.getController(0)
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ open class ProjectileSimple(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
collisionType = KINEMATIC
|
collisionType = COLLISION_KINEMATIC
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun update(gc: GameContainer, delta: Int) {
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
|
|||||||
@@ -304,10 +304,22 @@ object LightmapRenderer {
|
|||||||
|
|
||||||
ambient = darkenColoured(ambient, thisTileOpacity) // get real ambient by appling opacity value
|
ambient = darkenColoured(ambient, thisTileOpacity) // get real ambient by appling opacity value
|
||||||
|
|
||||||
// mix and return lightlevel and ambient
|
|
||||||
return lightLevelThis maxBlend 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 {
|
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
|
return lightLevelThis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ import net.torvald.terrarum.blendMul
|
|||||||
import net.torvald.terrarum.blendNormal
|
import net.torvald.terrarum.blendNormal
|
||||||
import net.torvald.terrarum.mapdrawer.MapDrawer.TILE_SIZE
|
import net.torvald.terrarum.mapdrawer.MapDrawer.TILE_SIZE
|
||||||
import org.lwjgl.opengl.GL11
|
import org.lwjgl.opengl.GL11
|
||||||
import org.newdawn.slick.GameContainer
|
import org.newdawn.slick.*
|
||||||
import org.newdawn.slick.Graphics
|
|
||||||
import org.newdawn.slick.SlickException
|
|
||||||
import org.newdawn.slick.SpriteSheet
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -255,17 +252,17 @@ object MapCamera {
|
|||||||
* render to camera
|
* render to camera
|
||||||
*/
|
*/
|
||||||
blendNormal()
|
blendNormal()
|
||||||
drawTiles(WALL, false)
|
drawTiles(g, WALL, false)
|
||||||
drawTiles(TERRAIN, false)
|
drawTiles(g, TERRAIN, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun renderFront(gc: GameContainer, g: Graphics) {
|
fun renderFront(gc: GameContainer, g: Graphics) {
|
||||||
blendMul()
|
blendMul()
|
||||||
drawTiles(TERRAIN, true)
|
drawTiles(g, TERRAIN, true)
|
||||||
blendNormal()
|
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_start = MapCamera.cameraY / TILE_SIZE
|
||||||
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)
|
||||||
|
|
||||||
@@ -275,6 +272,8 @@ object MapCamera {
|
|||||||
// initialise
|
// initialise
|
||||||
MapCamera.tilesetBook[mode].startUse()
|
MapCamera.tilesetBook[mode].startUse()
|
||||||
|
|
||||||
|
var zeroTileCounter = 0
|
||||||
|
|
||||||
// loop
|
// loop
|
||||||
for (y in for_y_start..for_y_end) {
|
for (y in for_y_start..for_y_end) {
|
||||||
for (x in for_x_start..for_x_end - 1) {
|
for (x in for_x_start..for_x_end - 1) {
|
||||||
@@ -294,23 +293,19 @@ object MapCamera {
|
|||||||
// draw
|
// draw
|
||||||
try {
|
try {
|
||||||
if (
|
if (
|
||||||
|
(mode == WALL || mode == TERRAIN) && // not an air tile
|
||||||
(mode == WALL || mode == TERRAIN) // not an air tile
|
(thisTile ?: 0) > 0) //&& // commented out: meh
|
||||||
|
|
||||||
&& (thisTile ?: 0) > 0
|
|
||||||
&&
|
|
||||||
// check if light level of nearby or this tile is illuminated
|
// check if light level of nearby or this tile is illuminated
|
||||||
( LightmapRenderer.getValueFromMap(x, y) ?: 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 + 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, 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 + 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
|
val nearbyTilesInfo: Int
|
||||||
if (isPlatform(thisTile)) {
|
if (isPlatform(thisTile)) {
|
||||||
nearbyTilesInfo = getNearbyTilesInfoPlatform(x, y)
|
nearbyTilesInfo = getNearbyTilesInfoPlatform(x, y)
|
||||||
@@ -346,6 +341,9 @@ object MapCamera {
|
|||||||
// or else they will not look like they should be when backed with wall
|
// or else they will not look like they should be when backed with wall
|
||||||
drawTile(mode, x, y, thisTileX, thisTileY)
|
drawTile(mode, x, y, thisTileX, thisTileY)
|
||||||
}
|
}
|
||||||
|
} // end if (not an air and is illuminated)
|
||||||
|
else {
|
||||||
|
zeroTileCounter++
|
||||||
}
|
}
|
||||||
} catch (e: NullPointerException) {
|
} catch (e: NullPointerException) {
|
||||||
// do nothing. WARNING: This exception handling may hide erratic behaviour completely.
|
// do nothing. WARNING: This exception handling may hide erratic behaviour completely.
|
||||||
|
|||||||
Reference in New Issue
Block a user