diff --git a/assets/graphics/sprites/test_player.png b/assets/graphics/sprites/test_player.png index 58fff107f..63601a254 100644 Binary files a/assets/graphics/sprites/test_player.png and b/assets/graphics/sprites/test_player.png differ diff --git a/assets/graphics/terrain/fluid.png b/assets/graphics/terrain/fluid.png deleted file mode 100755 index c86589cc9..000000000 Binary files a/assets/graphics/terrain/fluid.png and /dev/null differ diff --git a/assets/graphics/terrain/grassplusplus.png b/assets/graphics/terrain/grassplusplus.png deleted file mode 100644 index 14b8e1fde..000000000 Binary files a/assets/graphics/terrain/grassplusplus.png and /dev/null differ diff --git a/assets/graphics/terrain/terrain12.raw b/assets/graphics/terrain/terrain12.raw deleted file mode 100644 index 467da8ce5..000000000 Binary files a/assets/graphics/terrain/terrain12.raw and /dev/null differ diff --git a/assets/graphics/terrain/terrain_12.raw b/assets/graphics/terrain/terrain_12.raw deleted file mode 100644 index d50befdb1..000000000 Binary files a/assets/graphics/terrain/terrain_12.raw and /dev/null differ diff --git a/assets/graphics/terrain/wall.png b/assets/graphics/terrain/wall.png deleted file mode 100644 index bbd263fb5..000000000 Binary files a/assets/graphics/terrain/wall.png and /dev/null differ diff --git a/src/com/jme3/math/FastMath.java b/src/com/jme3/math/FastMath.java index 9dc9066da..56b708d49 100644 --- a/src/com/jme3/math/FastMath.java +++ b/src/com/jme3/math/FastMath.java @@ -99,7 +99,7 @@ final public class FastMath { * @param number The number to obtain the POT for. * @return The next power of two. */ - public static int nearestPowerOfTwo(int number) { + public static int nextPowerOfTwo(int number) { number--; number |= number >> 1; number |= number >> 2; diff --git a/src/net/torvald/spriteanimation/SpriteAnimation.kt b/src/net/torvald/spriteanimation/SpriteAnimation.kt index b160d0479..572493bae 100644 --- a/src/net/torvald/spriteanimation/SpriteAnimation.kt +++ b/src/net/torvald/spriteanimation/SpriteAnimation.kt @@ -126,15 +126,13 @@ class SpriteAnimation(val parentActor: ActorWithBody) { } val flippedImage = currentImage!!.getFlippedCopy(flipHorizontal, flipVertical) - - flippedImage.startUse() - flippedImage.drawEmbedded( + + flippedImage.draw( Math.round(posX).toFloat(), FastMath.floor(posY).toFloat(), FastMath.floor(width * scale).toFloat(), FastMath.floor(height * scale).toFloat() ) - flippedImage.endUse() } } diff --git a/src/net/torvald/terrarum/StateInGame.kt b/src/net/torvald/terrarum/StateInGame.kt index b16eb1be2..0e0d8fe9b 100644 --- a/src/net/torvald/terrarum/StateInGame.kt +++ b/src/net/torvald/terrarum/StateInGame.kt @@ -291,7 +291,12 @@ constructor() : BasicGameState() { blendNormal() - drawSkybox(worldDrawFrameBuffer.graphics) + drawSkybox(gwin) + /*drawSkybox(worldDrawFrameBuffer.graphics) + uisDrawFrameBuffer.graphics.color = Color(255, 255, 255, 0) + uisDrawFrameBuffer.graphics.fillRect( + 0f, 0f, uisDrawFrameBuffer.width.toFloat(), uisDrawFrameBuffer.height.toFloat() + )*/ // make camara work // @@ -304,20 +309,19 @@ constructor() : BasicGameState() { // draw map related stuffs // ///////////////////////////// TilesDrawer.renderBehind(gc, worldDrawFrameBuffer.graphics) + // --> blendNormal() <-- by TilesDrawer.renderBehind ///////////////// // draw actors // ///////////////// - // --> Change of blend mode <-- introduced by ActorWithBody // actorContainer.forEach { actor -> if (actor is ActorWithBody && actor.inScreen() && actor !is Player && !actor.drawTopmost) { actor.drawBody(gc, worldDrawFrameBuffer.graphics) } } - // --> Change of blend mode <-- introduced by ActorWithBody // player.drawBody(gc, worldDrawFrameBuffer.graphics) - // --> Change of blend mode <-- introduced by ActorWithBody // + // actors that are drawTopmost actorContainer.forEach { actor -> if (actor is ActorWithBody && actor.inScreen() && actor !is Player && actor.drawTopmost) { actor.drawBody(gc, worldDrawFrameBuffer.graphics) @@ -331,13 +335,11 @@ constructor() : BasicGameState() { ///////////////////////////// LightmapRenderer.renderLightMap() - // --> blendMul() <-- by TilesDrawer.renderFront - TilesDrawer.renderFront(gc, worldDrawFrameBuffer.graphics) + TilesDrawer.renderFront(gc, worldDrawFrameBuffer.graphics, false) // --> blendNormal() <-- by TilesDrawer.renderFront FeaturesDrawer.render(gc, worldDrawFrameBuffer.graphics) - // --> blendMul() <-- by TilesDrawer.drawEnvOverlay FeaturesDrawer.drawEnvOverlay(worldDrawFrameBuffer.graphics) if (!KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) blendMul() @@ -348,14 +350,19 @@ constructor() : BasicGameState() { ////////////////////// // draw actor glows // ////////////////////// - // --> blendLightenOnly() <-- introduced by ActorWithBody // actorContainer.forEach { actor -> if (actor is ActorWithBody && actor.inScreen() && actor !is Player) { actor.drawGlow(gc, worldDrawFrameBuffer.graphics) } } - // --> blendLightenOnly() <-- introduced by ActorWithBody // player.drawGlow(gc, worldDrawFrameBuffer.graphics) + // actors that are drawTopmost + actorContainer.forEach { actor -> + if (actor is ActorWithBody && actor.inScreen() && actor !is Player && actor.drawTopmost) { + actor.drawGlow(gc, worldDrawFrameBuffer.graphics) + } + } + // --> blendLightenOnly() <-- introduced by ActorWithBody // //////////////////////// diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index 20f414768..df98c38c6 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -460,7 +460,7 @@ fun blendNormal() { // semitransparent textures working as intended with this, // but needs further investigation in the case of: - // TODO blend semitransparent over semitransparent + // TODO test blend in the situation of semitransparent over semitransparent GL14.glBlendFuncSeparate( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, // blend func for RGB channels GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA // blend func for alpha channels @@ -469,14 +469,9 @@ fun blendNormal() { fun blendLightenOnly() { GL11.glEnable(GL11.GL_BLEND) - GL14.glBlendFuncSeparate( - GL11.GL_ONE, GL11.GL_ONE, // blend func for RGB channels - GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA // blend func for alpha channels - ) - GL20.glBlendEquationSeparate( - GL14.GL_MAX, - GL14.GL_FUNC_ADD - ) + GL11.glColorMask(true, true, true, false) + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE) + GL14.glBlendEquation(GL14.GL_MAX) } fun blendAlphaMap() { diff --git a/src/net/torvald/terrarum/gameactors/FixtureBase.kt b/src/net/torvald/terrarum/gameactors/FixtureBase.kt index 9f7360e67..8b63f814e 100644 --- a/src/net/torvald/terrarum/gameactors/FixtureBase.kt +++ b/src/net/torvald/terrarum/gameactors/FixtureBase.kt @@ -12,23 +12,18 @@ open class FixtureBase : ActorWithBody() { * 2: Platform; can be stood on, press DOWN to go down. Also allows other blocks can be places on top of it (e.g. torch) * 3: Wall_left; blocks rightward movement * 4: Wall_right: blocks leftward movement + * 5: Same as 2 but player CANNOT go down * For example, flag of 4 is good for tables; player can stand on, which means * downward movement is blocked within the fixtures' AABB. */ var collisionFlag: Int = 0 - /** - * Normally if player is standing on the fixtures (with flag 2 -- COLLISION_PLATFORM), - * pressing DOWN wiil allow player to get down. - * Setting this flag TRUE will block such movement (player cannot get down) - */ - var cannotPassThru = false - companion object { val COLLISION_OPEN = 0 val COLLISION_BLOCKED = 1 val COLLISION_PLATFORM = 2 val COLLISION_WALL_LEFT = 3 val COLLISION_WALL_RIGHT = 4 + val COLLISION_PLATFORM_NOGODOWN = 5 } } \ No newline at end of file diff --git a/src/net/torvald/terrarum/mapdrawer/TilesDrawer.kt b/src/net/torvald/terrarum/mapdrawer/TilesDrawer.kt index 35be2eb72..1a23ef502 100644 --- a/src/net/torvald/terrarum/mapdrawer/TilesDrawer.kt +++ b/src/net/torvald/terrarum/mapdrawer/TilesDrawer.kt @@ -6,6 +6,7 @@ import net.torvald.terrarum.Terrarum import net.torvald.terrarum.tileproperties.Tile import net.torvald.terrarum.tileproperties.TileCodex import com.jme3.math.FastMath +import net.torvald.terrarum.blendAlphaMap import net.torvald.terrarum.concurrent.ThreadParallel import net.torvald.terrarum.blendMul import net.torvald.terrarum.blendNormal @@ -25,14 +26,10 @@ object TilesDrawer { private val world: GameWorld = Terrarum.ingame.world private val TILE_SIZE = FeaturesDrawer.TILE_SIZE - var tilesWall: SpriteSheet = SpriteSheet("./assets/graphics/terrain/wall.png", TILE_SIZE, TILE_SIZE) - private set var tilesTerrain: SpriteSheet = SpriteSheet("./assets/graphics/terrain/terrain.tga", TILE_SIZE, TILE_SIZE) private set // Slick has some weird quirks with PNG's transparency. I'm using 32-bit targa here. var tilesWire: SpriteSheet = SpriteSheet("./assets/graphics/terrain/wire.png", TILE_SIZE, TILE_SIZE) private set - var tilesetBook: Array = arrayOf(tilesWall, tilesTerrain, tilesWire) - private set val WALL = GameWorld.WALL val TERRAIN = GameWorld.TERRAIN @@ -229,18 +226,45 @@ object TilesDrawer { val player = Terrarum.ingame.player } + val wallOverlayColour = Color(2f/3f, 2f/3f, 2f/3f, 1f) + fun renderBehind(gc: GameContainer, g: Graphics) { /** * render to camera */ blendNormal() + + tilesTerrain.startUse() drawTiles(g, WALL, false) + tilesTerrain.endUse() // you absolutely need this + + blendMul() + + g.color = wallOverlayColour + g.fillRect(MapCamera.x.toFloat(), MapCamera.y.toFloat(), + MapCamera.width.toFloat() + 1, MapCamera.height.toFloat() + 1 + ) + + blendNormal() + + tilesTerrain.startUse() // you absolutely need this drawTiles(g, TERRAIN, false) + tilesTerrain.endUse() } - fun renderFront(gc: GameContainer, g: Graphics) { + fun renderFront(gc: GameContainer, g: Graphics, drawWires: Boolean) { blendMul() + + tilesTerrain.startUse() drawTiles(g, TERRAIN, true) + tilesTerrain.endUse() + + if (drawWires) { + tilesWire.startUse() + drawTiles(g, WIRE, false) + tilesWire.endUse() + } + blendNormal() } @@ -251,9 +275,6 @@ object TilesDrawer { val for_x_start = x / TILE_SIZE - 1 val for_x_end = for_x_start + (width / TILE_SIZE) + 3 - // initialise - TilesDrawer.tilesetBook[mode].startUse() - var zeroTileCounter = 0 // loop @@ -333,8 +354,6 @@ object TilesDrawer { } } - - TilesDrawer.tilesetBook[mode].endUse() } /** @@ -461,11 +480,20 @@ object TilesDrawer { } private fun drawTile(mode: Int, tilewisePosX: Int, tilewisePosY: Int, sheetX: Int, sheetY: Int) { - tilesetBook[mode].renderInUse( - FastMath.floor((tilewisePosX * TILE_SIZE).toFloat()), - FastMath.floor((tilewisePosY * TILE_SIZE).toFloat()), - sheetX, sheetY - ) + if (mode == TERRAIN || mode == WALL) + tilesTerrain.renderInUse( + FastMath.floor((tilewisePosX * TILE_SIZE).toFloat()), + FastMath.floor((tilewisePosY * TILE_SIZE).toFloat()), + sheetX, sheetY + ) + else if (mode == WIRE) + tilesWire.renderInUse( + FastMath.floor((tilewisePosX * TILE_SIZE).toFloat()), + FastMath.floor((tilewisePosY * TILE_SIZE).toFloat()), + sheetX, sheetY + ) + else + throw IllegalArgumentException() } fun clampH(x: Int): Int { diff --git a/src/net/torvald/terrarum/weather/WeatherMixer.kt b/src/net/torvald/terrarum/weather/WeatherMixer.kt index 45acf169a..4b138ff65 100644 --- a/src/net/torvald/terrarum/weather/WeatherMixer.kt +++ b/src/net/torvald/terrarum/weather/WeatherMixer.kt @@ -82,15 +82,14 @@ object WeatherMixer { val skyColourFill = GradientFill( 0f, 0f, getGradientColour(skyboxColourMap, 0, timeNow), - 0f, Terrarum.HEIGHT / Terrarum.ingame.screenZoom, + 0f, Terrarum.HEIGHT.toFloat(),// / Terrarum.ingame.screenZoom, getGradientColour(skyboxColourMap, 1, timeNow) ) g.fill(Rectangle( 0f, 0f, - Terrarum.WIDTH / Terrarum.ingame.screenZoom, - Terrarum.HEIGHT / Terrarum.ingame.screenZoom), - skyColourFill - ) + Terrarum.WIDTH.toFloat(),// / Terrarum.ingame.screenZoom, + Terrarum.HEIGHT.toFloat()// / Terrarum.ingame.screenZoom + ),skyColourFill) // calculate global light val gradCol = getGradientColour(lightColourMap, 0, timeNow) diff --git a/work_files/graphics/paintings/.gitattributes b/work_files/graphics/tapestries/.gitattributes similarity index 100% rename from work_files/graphics/paintings/.gitattributes rename to work_files/graphics/tapestries/.gitattributes diff --git a/assets/graphics/terrain/terrain_old.png b/work_files/graphics/terrain/terrain_old.png old mode 100755 new mode 100644 similarity index 100% rename from assets/graphics/terrain/terrain_old.png rename to work_files/graphics/terrain/terrain_old.png diff --git a/assets/graphics/terrain/terrain_ref.png b/work_files/graphics/terrain/terrain_ref.png old mode 100755 new mode 100644 similarity index 100% rename from assets/graphics/terrain/terrain_ref.png rename to work_files/graphics/terrain/terrain_ref.png diff --git a/assets/graphics/terrain/wall_old.png b/work_files/graphics/terrain/wall_old.png old mode 100755 new mode 100644 similarity index 100% rename from assets/graphics/terrain/wall_old.png rename to work_files/graphics/terrain/wall_old.png