mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
tilesize declaration refactoring
This commit is contained in:
@@ -37,6 +37,7 @@ import net.torvald.terrarum.worlddrawer.CreateTileAtlas;
|
||||
import net.torvald.terrarumsansbitmap.gdx.GameFontBase;
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack;
|
||||
import net.torvald.util.ArrayListMap;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -92,7 +93,7 @@ public class AppLoader implements ApplicationListener {
|
||||
/**
|
||||
* Initialise the application with the alternative Screen you choose
|
||||
*
|
||||
* @param appConfig LWJGL(2) Application Configuration
|
||||
* @param appConfig LWJGL3 Application Configuration
|
||||
* @param injectScreen GDX Screen you want to run
|
||||
*/
|
||||
public AppLoader(Lwjgl3ApplicationConfiguration appConfig, Screen injectScreen) {
|
||||
@@ -144,9 +145,6 @@ public class AppLoader implements ApplicationListener {
|
||||
public static final boolean is32BitJVM = !System.getProperty("sun.arch.data.model").contains("64");
|
||||
// some JVMs don't have this property, but they probably don't have "sun.misc.Unsafe" either, so it's no big issue \_(ツ)_/
|
||||
|
||||
public static int GL_VERSION;
|
||||
public static final int MINIMAL_GL_VERSION = 320;
|
||||
|
||||
public static final int GLOBAL_FRAMERATE_LIMIT = 300;
|
||||
|
||||
/**
|
||||
@@ -187,6 +185,10 @@ public class AppLoader implements ApplicationListener {
|
||||
|
||||
public static Lwjgl3ApplicationConfiguration appConfig;
|
||||
public static TerrarumScreenSize screenSize;
|
||||
public static TerrarumGLinfo glInfo = new TerrarumGLinfo();
|
||||
|
||||
public static CreateTileAtlas tileMaker;
|
||||
|
||||
public static GameFontBase fontGame;
|
||||
public static TinyAlphNum fontSmallNumbers;
|
||||
|
||||
@@ -349,22 +351,8 @@ public class AppLoader implements ApplicationListener {
|
||||
GAME_LOCALE = getConfigString("language");
|
||||
printdbg(this, "locale = " + GAME_LOCALE);
|
||||
|
||||
String glInfo = Gdx.graphics.getGLVersion().getDebugVersionString();
|
||||
|
||||
GL_VERSION = Gdx.graphics.getGLVersion().getMajorVersion() * 100 +
|
||||
Gdx.graphics.getGLVersion().getMinorVersion() * 10 +
|
||||
Gdx.graphics.getGLVersion().getReleaseVersion();
|
||||
|
||||
System.out.println("GL_VERSION = " + GL_VERSION);
|
||||
System.out.println("GL info:\n" + glInfo); // debug info
|
||||
|
||||
|
||||
if (GL_VERSION < MINIMAL_GL_VERSION) {
|
||||
// TODO notify properly
|
||||
throw new GdxRuntimeException("Graphics device not capable -- device's GL_VERSION: " + GL_VERSION +
|
||||
", required: " + MINIMAL_GL_VERSION);
|
||||
}
|
||||
|
||||
glInfo.create();
|
||||
|
||||
CommonResourcePool.INSTANCE.addToLoadingList("blockmarkings_common", () -> new TextureRegionPack(Gdx.files.internal("assets/graphics/blocks/block_markings_common.tga"), 16, 16, 0, 0, 0, 0, false));
|
||||
|
||||
@@ -482,7 +470,8 @@ public class AppLoader implements ApplicationListener {
|
||||
|
||||
// create tile atlas
|
||||
printdbg(this, "Making terrain textures...");
|
||||
CreateTileAtlas.INSTANCE.invoke(false);
|
||||
tileMaker = new CreateTileAtlas();
|
||||
tileMaker.invoke(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@ object DefaultConfig {
|
||||
jsonObject.addProperty("usevsync", false)
|
||||
jsonObject.addProperty("screenwidth", TerrarumScreenSize.defaultW)
|
||||
jsonObject.addProperty("screenheight", TerrarumScreenSize.defaultH)
|
||||
jsonObject.addProperty("atlastexsize", 2048)
|
||||
|
||||
|
||||
//jsonObject.addProperty("imtooyoungtodie", false) // no perma-death
|
||||
|
||||
@@ -199,7 +199,7 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
private set
|
||||
|
||||
|
||||
private val TILE_SIZEF = CreateTileAtlas.TILE_SIZE.toFloat()
|
||||
private val TILE_SIZEF = TILE_SIZEF
|
||||
|
||||
//////////////
|
||||
// GDX code //
|
||||
@@ -485,8 +485,8 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
// go to spawn position
|
||||
player.setPosition(
|
||||
world.spawnX * CreateTileAtlas.TILE_SIZE.toDouble(),
|
||||
world.spawnY * CreateTileAtlas.TILE_SIZE.toDouble()
|
||||
world.spawnX * TILE_SIZED,
|
||||
world.spawnY * TILE_SIZED
|
||||
)
|
||||
|
||||
addNewActor(player)
|
||||
@@ -1214,18 +1214,18 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
min(// take min of normal position and wrapped (x < 0) position
|
||||
(a.hitbox.centeredX - p.hitbox.centeredX).sqr() +
|
||||
(a.hitbox.centeredY - p.hitbox.centeredY).sqr(),
|
||||
(a.hitbox.centeredX - p.hitbox.centeredX + world.width * CreateTileAtlas.TILE_SIZE).sqr() +
|
||||
(a.hitbox.centeredX - p.hitbox.centeredX + world.width * TILE_SIZE).sqr() +
|
||||
(a.hitbox.centeredY - p.hitbox.centeredY).sqr(),
|
||||
(a.hitbox.centeredX - p.hitbox.centeredX - world.width * CreateTileAtlas.TILE_SIZE).sqr() +
|
||||
(a.hitbox.centeredX - p.hitbox.centeredX - world.width * TILE_SIZE).sqr() +
|
||||
(a.hitbox.centeredY - p.hitbox.centeredY).sqr()
|
||||
)
|
||||
private fun distToCameraSqr(a: ActorWithBody) =
|
||||
min(
|
||||
(a.hitbox.startX - WorldCamera.x).sqr() +
|
||||
(a.hitbox.startY - WorldCamera.y).sqr(),
|
||||
(a.hitbox.startX - WorldCamera.x + world.width * CreateTileAtlas.TILE_SIZE).sqr() +
|
||||
(a.hitbox.startX - WorldCamera.x + world.width * TILE_SIZE).sqr() +
|
||||
(a.hitbox.startY - WorldCamera.y).sqr(),
|
||||
(a.hitbox.startX - WorldCamera.x - world.width * CreateTileAtlas.TILE_SIZE).sqr() +
|
||||
(a.hitbox.startX - WorldCamera.x - world.width * TILE_SIZE).sqr() +
|
||||
(a.hitbox.startY - WorldCamera.y).sqr()
|
||||
)
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ object GlslTilingTest : ApplicationAdapter() {
|
||||
|
||||
lateinit var fucktex: Texture
|
||||
|
||||
val TILE_SIZE = 16
|
||||
val TILE_SIZEF = 16f
|
||||
val TILING_SIZE = 16
|
||||
val TILING_SIZEF = 16f
|
||||
|
||||
|
||||
lateinit var tilesBuffer: Pixmap
|
||||
@@ -64,8 +64,8 @@ object GlslTilingTest : ApplicationAdapter() {
|
||||
|
||||
|
||||
|
||||
val tilesInHorizontal = (Gdx.graphics.width.toFloat() / TILE_SIZE).ceil() + 1f
|
||||
val tilesInVertical = (Gdx.graphics.height.toFloat() / TILE_SIZE).ceil() + 1f
|
||||
val tilesInHorizontal = (Gdx.graphics.width.toFloat() / TILING_SIZE).ceil() + 1f
|
||||
val tilesInVertical = (Gdx.graphics.height.toFloat() / TILING_SIZE).ceil() + 1f
|
||||
|
||||
tilesQuad = Mesh(
|
||||
true, 4, 6,
|
||||
@@ -129,8 +129,8 @@ object GlslTilingTest : ApplicationAdapter() {
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND)
|
||||
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
|
||||
val tilesInHorizontal = (Gdx.graphics.width.toFloat() / TILE_SIZE).ceil() + 1f
|
||||
val tilesInVertical = (Gdx.graphics.height.toFloat() / TILE_SIZE).ceil() + 1f
|
||||
val tilesInHorizontal = (Gdx.graphics.width.toFloat() / TILING_SIZE).ceil() + 1f
|
||||
val tilesInVertical = (Gdx.graphics.height.toFloat() / TILING_SIZE).ceil() + 1f
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.jme3.math.FastMath
|
||||
import net.torvald.UnsafeHelper
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.AppLoader.*
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.ActorID
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
@@ -257,16 +258,16 @@ object Terrarum : Disposable {
|
||||
get() = WorldCamera.zoomedY + (Gdx.input.y - Gdx.input.deltaY) / (ingame?.screenZoom ?: 1f).toDouble()
|
||||
/** Position of the cursor in the world */
|
||||
@JvmStatic val mouseTileX: Int
|
||||
get() = (mouseX / CreateTileAtlas.TILE_SIZE).floorInt()
|
||||
get() = (mouseX / TILE_SIZE).floorInt()
|
||||
/** Position of the cursor in the world */
|
||||
@JvmStatic val mouseTileY: Int
|
||||
get() = (mouseY / CreateTileAtlas.TILE_SIZE).floorInt()
|
||||
get() = (mouseY / TILE_SIZE).floorInt()
|
||||
/** Position of the cursor in the world */
|
||||
@JvmStatic val oldMouseTileX: Int
|
||||
get() = (oldMouseX / CreateTileAtlas.TILE_SIZE).floorInt()
|
||||
get() = (oldMouseX / TILE_SIZE).floorInt()
|
||||
/** Position of the cursor in the world */
|
||||
@JvmStatic val oldMouseTileY: Int
|
||||
get() = (oldMouseY / CreateTileAtlas.TILE_SIZE).floorInt()
|
||||
get() = (oldMouseY / TILE_SIZE).floorInt()
|
||||
inline val mouseScreenX: Int
|
||||
get() = Gdx.input.x
|
||||
inline val mouseScreenY: Int
|
||||
|
||||
@@ -1,42 +1,41 @@
|
||||
package net.torvald.terrarum;
|
||||
package net.torvald.terrarum
|
||||
|
||||
/**
|
||||
* You directly modify the source code to tune the engine to suit your needs.
|
||||
*
|
||||
* Created by minjaesong on 2019-08-15.
|
||||
*/
|
||||
public class TerrarumAppConfiguration {
|
||||
|
||||
object TerrarumAppConfiguration {
|
||||
//////////////////////////////////////
|
||||
// CONFIGURATION FOR THE APP ITSELF //
|
||||
//////////////////////////////////////
|
||||
|
||||
public static final String GAME_NAME = "Terrarum";
|
||||
public static final String COPYRIGHT_DATE_NAME = "Copyright 2013-2021 Torvald (minjaesong)";
|
||||
const val GAME_NAME = "Terrarum"
|
||||
const val COPYRIGHT_DATE_NAME = "Copyright 2013-2021 Torvald (minjaesong)"
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Version numbering that follows Semantic Versioning 2.0.0 (https://semver.org/)
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* Version numbering that follows Semantic Versioning 2.0.0 (https://semver.org/)
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* 0xAA_BB_XXXX, where:
|
||||
* </p>
|
||||
* <li>AA: Major version</li>
|
||||
* <li>BB: Minor version</li>
|
||||
* <li>XXXX: Patch version</li>
|
||||
* <p>
|
||||
*
|
||||
* * AA: Major version
|
||||
* * BB: Minor version
|
||||
* * XXXX: Patch version
|
||||
*
|
||||
*
|
||||
* e.g. 0x02010034 will be translated as 2.1.52
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public static final int VERSION_RAW = 0x00_02_06D3;
|
||||
|
||||
const val VERSION_RAW = 0x000206D3
|
||||
|
||||
//////////////////////////////////
|
||||
// CONFIGURATION FOR TILE MAKER //
|
||||
//////////////////////////////////
|
||||
|
||||
public static final int MAX_TEX_SIZE = 4096;
|
||||
public static final int TILE_SIZE = 16;
|
||||
|
||||
}
|
||||
const val TILE_SIZE = 16
|
||||
const val TILE_SIZEF = TILE_SIZE.toFloat()
|
||||
const val TILE_SIZED = TILE_SIZE.toDouble()
|
||||
}
|
||||
41
src/net/torvald/terrarum/TerrarumGLinfo.kt
Normal file
41
src/net/torvald/terrarum/TerrarumGLinfo.kt
Normal file
@@ -0,0 +1,41 @@
|
||||
package net.torvald.terrarum
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.utils.GdxRuntimeException
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
class TerrarumGLinfo {
|
||||
private var _initialised = false
|
||||
|
||||
// some JVMs don't have this property, but they probably don't have "sun.misc.Unsafe" either, so it's no big issue \_(ツ)_/
|
||||
val MINIMAL_GL_VERSION = 320
|
||||
|
||||
var GL_VERSION = -1; private set
|
||||
get() = if (_initialised) field else throw UninitializedPropertyAccessException()
|
||||
var GL_MAX_TEXTURE_SIZE = -1; private set
|
||||
get() = if (_initialised) field else throw UninitializedPropertyAccessException()
|
||||
|
||||
fun create() {
|
||||
_initialised = true
|
||||
|
||||
|
||||
val glInfo = Gdx.graphics.glVersion.debugVersionString
|
||||
|
||||
GL_VERSION = Gdx.graphics.glVersion.majorVersion * 100 + Gdx.graphics.glVersion.minorVersion * 10 +
|
||||
Gdx.graphics.glVersion.releaseVersion
|
||||
|
||||
println("GL_VERSION = $GL_VERSION")
|
||||
println("GL info:\n$glInfo") // debug info
|
||||
|
||||
|
||||
|
||||
if (GL_VERSION < MINIMAL_GL_VERSION) {
|
||||
// TODO notify properly
|
||||
throw GdxRuntimeException("Graphics device not capable -- device's GL_VERSION: $GL_VERSION, required: $MINIMAL_GL_VERSION")
|
||||
}
|
||||
|
||||
GL_MAX_TEXTURE_SIZE = GL11.glGetInteger(GL11.GL_MAX_TEXTURE_SIZE)
|
||||
println("Maximum Texture Size: $GL_MAX_TEXTURE_SIZE")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import com.jme3.math.FastMath
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.AppLoader.printdbgerr
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameactors.ai.ActorAI
|
||||
@@ -72,7 +74,7 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
|
||||
|
||||
val tileSize = CreateTileAtlas.TILE_SIZE.toFloat()
|
||||
val tileSize = TILE_SIZEF
|
||||
val catmullRomTension = 0f
|
||||
|
||||
// pan camera
|
||||
@@ -117,9 +119,6 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
private lateinit var worldFBO: FrameBuffer
|
||||
|
||||
private val TILE_SIZE = CreateTileAtlas.TILE_SIZE
|
||||
private val TILE_SIZEF = TILE_SIZE.toFloat()
|
||||
|
||||
private fun loadThingsWhileIntroIsVisible() {
|
||||
printdbg(this, "Intro pre-load")
|
||||
|
||||
@@ -139,7 +138,7 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
while (travelDownCounter < demoWorld.height && !BlockCodex[demoWorld.getTileFromTerrain(tileXPos, travelDownCounter)].isSolid) {
|
||||
travelDownCounter += 4
|
||||
}
|
||||
travelDownCounter * CreateTileAtlas.TILE_SIZE.toFloat()
|
||||
travelDownCounter * TILE_SIZEF
|
||||
}
|
||||
|
||||
|
||||
@@ -372,7 +371,7 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
init {
|
||||
hitbox.setPosition(
|
||||
HQRNG().nextInt(demoWorld.width) * CreateTileAtlas.TILE_SIZE.toDouble(),
|
||||
HQRNG().nextInt(demoWorld.width) * TILE_SIZED,
|
||||
0.0 // Y pos: placeholder; camera AI will take it over
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package net.torvald.terrarum.blockstats
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.worlddrawer.BlocksDrawer
|
||||
@@ -15,9 +18,7 @@ import java.util.*
|
||||
object BlockStats {
|
||||
|
||||
private val tilestat = HashMap<ItemID, Int>()
|
||||
|
||||
private val TSIZE = CreateTileAtlas.TILE_SIZE
|
||||
|
||||
|
||||
/**
|
||||
* Update tile stats from tiles on screen
|
||||
*/
|
||||
@@ -34,14 +35,14 @@ object BlockStats {
|
||||
val renderHeight = FastMath.ceil(AppLoader.screenSize.screenHf)
|
||||
|
||||
val noZoomCameraX = Math.round(FastMath.clamp(
|
||||
player.hitbox.centeredX.toFloat() - renderWidth / 2, TSIZE.toFloat(), map.width * TSIZE - renderWidth - TSIZE.toFloat()))
|
||||
player.hitbox.centeredX.toFloat() - renderWidth / 2, TILE_SIZEF, map.width * TILE_SIZE - renderWidth - TILE_SIZEF))
|
||||
val noZoomCameraY = Math.round(FastMath.clamp(
|
||||
player.hitbox.centeredY.toFloat() - renderHeight / 2, TSIZE.toFloat(), map.width * TSIZE - renderHeight - TSIZE.toFloat()))
|
||||
player.hitbox.centeredY.toFloat() - renderHeight / 2, TILE_SIZEF, map.width * TILE_SIZE - renderHeight - TILE_SIZEF))
|
||||
|
||||
val for_x_start = noZoomCameraX / TSIZE
|
||||
val for_y_start = noZoomCameraY / TSIZE
|
||||
val for_y_end = BlocksDrawer.clampHTile(for_y_start + (renderHeight / TSIZE) + 2)
|
||||
val for_x_end = BlocksDrawer.clampWTile(for_x_start + (renderWidth / TSIZE) + 2)
|
||||
val for_x_start = noZoomCameraX / TILE_SIZE
|
||||
val for_y_start = noZoomCameraY / TILE_SIZE
|
||||
val for_y_end = BlocksDrawer.clampHTile(for_y_start + (renderHeight / TILE_SIZE) + 2)
|
||||
val for_x_end = BlocksDrawer.clampWTile(for_x_start + (renderWidth / TILE_SIZE) + 2)
|
||||
|
||||
for (y in for_y_start..for_y_end - 1) {
|
||||
for (x in for_x_start..for_x_end - 1) {
|
||||
|
||||
@@ -136,8 +136,8 @@ object MinimapComposer : Disposable {
|
||||
for (x in if (tileSlotIndexY >= TILES_IN_X / 2) (topLeftX + LIVETILE_SIZE - 1) downTo topLeftX else topLeftX until topLeftX + LIVETILE_SIZE) {
|
||||
val tileTerr = world.getTileFromTerrain(x, y)
|
||||
val wallTerr = world.getTileFromWall(x, y)
|
||||
val colTerr = CreateTileAtlas.terrainTileColourMap.get(tileTerr)!!.toGdxColor()
|
||||
val colWall = CreateTileAtlas.terrainTileColourMap.get(wallTerr)!!.toGdxColor().mul(CreateTileAtlas.wallOverlayColour)
|
||||
val colTerr = AppLoader.tileMaker.terrainTileColourMap.get(tileTerr)!!.toGdxColor()
|
||||
val colWall = AppLoader.tileMaker.terrainTileColourMap.get(wallTerr)!!.toGdxColor().mul(AppLoader.tileMaker.wallOverlayColour)
|
||||
|
||||
val outCol = if (colTerr.a > 0.1f) colTerr else colWall
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.spriteanimation.SpriteAnimation
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.blockproperties.BlockProp
|
||||
@@ -1167,7 +1170,7 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties)
|
||||
private val AUTO_CLIMB_STRIDE: Int
|
||||
get() = (8 * scale).toInt() // number inspired by SM64
|
||||
//private val AUTO_CLIMB_RATE: Int // we'll just climb stairs instantly to make things work wo worrying about the details
|
||||
// get() = Math.min(TILE_SIZE / 8 * Math.sqrt(scale), TILE_SIZE.toDouble()).toInt()
|
||||
// get() = Math.min(TILE_SIZE / 8 * Math.sqrt(scale), TILE_SIZED).toInt()
|
||||
|
||||
/**
|
||||
* @return 0 - no collision, 1 - stair, 2 - "bonk" to the wall
|
||||
@@ -1651,8 +1654,8 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties)
|
||||
else if (x < TILE_SIZE + hitbox.width / 2) {
|
||||
TILE_SIZE + hitbox.width / 2
|
||||
}
|
||||
else if (x >= (world!!.width * TILE_SIZE).toDouble() - TILE_SIZE.toDouble() - hitbox.width / 2) {
|
||||
(world!!.width * TILE_SIZE).toDouble() - 1.0 - TILE_SIZE.toDouble() - hitbox.width / 2
|
||||
else if (x >= (world!!.width * TILE_SIZE).toDouble() - TILE_SIZED - hitbox.width / 2) {
|
||||
(world!!.width * TILE_SIZE).toDouble() - 1.0 - TILE_SIZED - hitbox.width / 2
|
||||
}
|
||||
else {
|
||||
x
|
||||
@@ -1663,8 +1666,8 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties)
|
||||
else if (y < TILE_SIZE + hitbox.height) {
|
||||
TILE_SIZE + hitbox.height
|
||||
}
|
||||
else if (y >= (world!!.height * TILE_SIZE).toDouble() - TILE_SIZE.toDouble() - hitbox.height) {
|
||||
(world!!.height * TILE_SIZE).toDouble() - 1.0 - TILE_SIZE.toDouble() - hitbox.height
|
||||
else if (y >= (world!!.height * TILE_SIZE).toDouble() - TILE_SIZED - hitbox.height) {
|
||||
(world!!.height * TILE_SIZE).toDouble() - 1.0 - TILE_SIZED - hitbox.height
|
||||
}
|
||||
else {
|
||||
y
|
||||
@@ -1843,9 +1846,6 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties)
|
||||
@Transient const val COLLISION_KNOCKBACK_GIVER = 4 // mobs
|
||||
@Transient const val COLLISION_KNOCKBACK_TAKER = 5 // benevolent NPCs
|
||||
|
||||
@Transient val TILE_SIZE = CreateTileAtlas.TILE_SIZE
|
||||
@Transient val TILE_SIZEF = CreateTileAtlas.TILE_SIZE.toFloat()
|
||||
|
||||
private fun div16TruncateToMapWidth(x: Int): Int {
|
||||
if (x < 0)
|
||||
return 0
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.badlogic.gdx.utils.GdxRuntimeException
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.AppLoader.printdbgerr
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.controller.TerrarumController
|
||||
import net.torvald.terrarum.floorInt
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
@@ -40,10 +42,10 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
||||
get() = WorldCamera.y + Gdx.input.y / (terrarumIngame.screenZoom)
|
||||
/** currently pointing tile coordinate */
|
||||
val mouseTileX: Int
|
||||
get() = (mouseX / CreateTileAtlas.TILE_SIZE).floorInt()
|
||||
get() = (mouseX / TILE_SIZE).floorInt()
|
||||
/** currently pointing tile coordinate */
|
||||
val mouseTileY: Int
|
||||
get() = (mouseY / CreateTileAtlas.TILE_SIZE).floorInt()
|
||||
get() = (mouseY / TILE_SIZE).floorInt()
|
||||
|
||||
init {
|
||||
try {
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.gameworld
|
||||
|
||||
import com.badlogic.gdx.utils.Disposable
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.ReferencingRanges
|
||||
import net.torvald.terrarum.Terrarum
|
||||
@@ -146,7 +147,7 @@ open class GameWorld : Disposable {
|
||||
|
||||
tileNumberToNameMap = HashMap<Int, ItemID>()
|
||||
tileNameToNumberMap = HashMap<ItemID, Int>()
|
||||
CreateTileAtlas.tags.forEach {
|
||||
AppLoader.tileMaker.tags.forEach {
|
||||
printdbg(this, "tileNumber ${it.value.tileNumber} <-> tileName ${it.key}")
|
||||
|
||||
tileNumberToNameMap[it.value.tileNumber] = it.key
|
||||
@@ -189,7 +190,7 @@ open class GameWorld : Disposable {
|
||||
// before the renaming, update the name maps
|
||||
tileNumberToNameMap = HashMap<Int, ItemID>()
|
||||
tileNameToNumberMap = HashMap<ItemID, Int>()
|
||||
CreateTileAtlas.tags.forEach {
|
||||
AppLoader.tileMaker.tags.forEach {
|
||||
tileNumberToNameMap[it.value.tileNumber] = it.key
|
||||
tileNameToNumberMap[it.key] = it.value.tileNumber
|
||||
}
|
||||
|
||||
@@ -8,17 +8,11 @@ import net.torvald.terrarum.ReferencingRanges
|
||||
import net.torvald.terrarum.ReferencingRanges.PREFIX_ACTORITEM
|
||||
import net.torvald.terrarum.ReferencingRanges.PREFIX_DYNAMICITEM
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.blockproperties.BlockProp
|
||||
import net.torvald.terrarum.blockproperties.Fluid
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.CanBeAnItem
|
||||
import net.torvald.terrarum.worlddrawer.BlocksDrawer
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.ITEM_ATLAS_TILES_X
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -103,18 +97,18 @@ object ItemCodex {
|
||||
// TODO: wires
|
||||
// wall
|
||||
else if (itemID.startsWith("wall@")) {
|
||||
val itemSheetNumber = CreateTileAtlas.tileIDtoItemSheetNumber(itemID.substring(5))
|
||||
val itemSheetNumber = AppLoader.tileMaker.tileIDtoItemSheetNumber(itemID.substring(5))
|
||||
return BlocksDrawer.tileItemWall.get(
|
||||
itemSheetNumber % ITEM_ATLAS_TILES_X,
|
||||
itemSheetNumber / ITEM_ATLAS_TILES_X
|
||||
itemSheetNumber % AppLoader.tileMaker.ITEM_ATLAS_TILES_X,
|
||||
itemSheetNumber / AppLoader.tileMaker.ITEM_ATLAS_TILES_X
|
||||
)
|
||||
}
|
||||
// terrain
|
||||
else {
|
||||
val itemSheetNumber = CreateTileAtlas.tileIDtoItemSheetNumber(itemID)
|
||||
val itemSheetNumber = AppLoader.tileMaker.tileIDtoItemSheetNumber(itemID)
|
||||
return BlocksDrawer.tileItemTerrain.get(
|
||||
itemSheetNumber % ITEM_ATLAS_TILES_X,
|
||||
itemSheetNumber / ITEM_ATLAS_TILES_X
|
||||
itemSheetNumber % AppLoader.tileMaker.ITEM_ATLAS_TILES_X,
|
||||
itemSheetNumber / AppLoader.tileMaker.ITEM_ATLAS_TILES_X
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockPropUtil
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.badlogic.gdx.utils.ScreenUtils
|
||||
import net.torvald.gdx.graphics.PixmapIO2
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
@@ -726,8 +727,6 @@ object IngameRenderer : Disposable {
|
||||
|
||||
}
|
||||
|
||||
private val TILE_SIZEF = CreateTileAtlas.TILE_SIZE.toFloat()
|
||||
|
||||
override fun dispose() {
|
||||
fboRGB.dispose()
|
||||
fboA.dispose()
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.EMDASH
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.blockproperties.BlockPropUtil
|
||||
import net.torvald.terrarum.blockstats.BlockStats
|
||||
import net.torvald.terrarum.blockstats.MinimapComposer
|
||||
@@ -30,8 +32,6 @@ import net.torvald.terrarum.modulebasegame.worldgenerator.RoguelikeRandomiser
|
||||
import net.torvald.terrarum.modulebasegame.worldgenerator.Worldgen
|
||||
import net.torvald.terrarum.modulebasegame.worldgenerator.WorldgenParams
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
import net.torvald.util.CircularArray
|
||||
@@ -163,8 +163,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
internal set
|
||||
|
||||
|
||||
private val TILE_SIZEF = CreateTileAtlas.TILE_SIZE.toFloat()
|
||||
|
||||
//////////////
|
||||
// GDX code //
|
||||
//////////////
|
||||
@@ -483,8 +481,8 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
if (gameLoadMode == GameLoadMode.CREATE_NEW) {
|
||||
// go to spawn position
|
||||
actorNowPlaying?.setPosition(
|
||||
world.spawnX * CreateTileAtlas.TILE_SIZE.toDouble(),
|
||||
world.spawnY * CreateTileAtlas.TILE_SIZE.toDouble()
|
||||
world.spawnX * TILE_SIZED,
|
||||
world.spawnY * TILE_SIZED
|
||||
)
|
||||
}
|
||||
|
||||
@@ -788,18 +786,18 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
min(// take min of normal position and wrapped (x < 0) position
|
||||
(a.hitbox.centeredX - p.hitbox.centeredX).sqr() +
|
||||
(a.hitbox.centeredY - p.hitbox.centeredY).sqr(),
|
||||
((a.hitbox.centeredX + world.width * CreateTileAtlas.TILE_SIZE) - p.hitbox.centeredX).sqr() +
|
||||
((a.hitbox.centeredX + world.width * TILE_SIZE) - p.hitbox.centeredX).sqr() +
|
||||
(a.hitbox.centeredY - p.hitbox.centeredY).sqr(),
|
||||
((a.hitbox.centeredX - world.width * CreateTileAtlas.TILE_SIZE) - p.hitbox.centeredX).sqr() +
|
||||
((a.hitbox.centeredX - world.width * TILE_SIZE) - p.hitbox.centeredX).sqr() +
|
||||
(a.hitbox.centeredY - p.hitbox.centeredY).sqr()
|
||||
)
|
||||
private fun distToCameraSqr(a: ActorWithBody) =
|
||||
min(
|
||||
(a.hitbox.centeredX - WorldCamera.xCentre).sqr() +
|
||||
(a.hitbox.centeredY - WorldCamera.yCentre).sqr(),
|
||||
((a.hitbox.centeredX + world.width * CreateTileAtlas.TILE_SIZE) - WorldCamera.xCentre).sqr() +
|
||||
((a.hitbox.centeredX + world.width * TILE_SIZE) - WorldCamera.xCentre).sqr() +
|
||||
(a.hitbox.centeredY - WorldCamera.yCentre).sqr(),
|
||||
((a.hitbox.centeredX - world.width * CreateTileAtlas.TILE_SIZE) - WorldCamera.xCentre).sqr() +
|
||||
((a.hitbox.centeredX - world.width * TILE_SIZE) - WorldCamera.xCentre).sqr() +
|
||||
(a.hitbox.centeredY - WorldCamera.yCentre).sqr()
|
||||
)
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ internal object ExportMap : ConsoleCommand {
|
||||
var mapDataPointer = 0
|
||||
|
||||
for (tile in world.terrainIterator()) {
|
||||
val colArray = CreateTileAtlas.terrainTileColourMap.get(tile)!!.toByteArray()
|
||||
val colArray = AppLoader.tileMaker.terrainTileColourMap.get(tile)!!.toByteArray()
|
||||
|
||||
for (i in 0..2) {
|
||||
mapData[mapDataPointer + i] = colArray[i]
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package net.torvald.terrarum.modulebasegame.console
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.serialise.ReadLayerDataZip
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
@@ -25,8 +24,8 @@ object ImportLayerData : ConsoleCommand {
|
||||
|
||||
Terrarum.ingame!!.world = GameWorldExtension(1, layerData, 0, 0, 0) // FIXME null TIME_T for the (partial) test to pass
|
||||
Terrarum.ingame!!.actorNowPlaying?.setPosition(
|
||||
(Terrarum.ingame!!.world).spawnY * CreateTileAtlas.TILE_SIZE.toDouble(),
|
||||
(Terrarum.ingame!!.world).spawnX * CreateTileAtlas.TILE_SIZE.toDouble()
|
||||
(Terrarum.ingame!!.world).spawnY * TILE_SIZED,
|
||||
(Terrarum.ingame!!.world).spawnX * TILE_SIZED
|
||||
)
|
||||
|
||||
Echo("Successfully loaded ${args[1]}")
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package net.torvald.terrarum.modulebasegame.console
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.console.EchoError
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-01-24.
|
||||
@@ -19,8 +20,8 @@ internal object Teleport : ConsoleCommand {
|
||||
val x: Int
|
||||
val y: Int
|
||||
try {
|
||||
x = args[1].toInt() * CreateTileAtlas.TILE_SIZE + CreateTileAtlas.TILE_SIZE / 2
|
||||
y = args[2].toInt() * CreateTileAtlas.TILE_SIZE + CreateTileAtlas.TILE_SIZE / 2
|
||||
x = args[1].toInt() * TILE_SIZE + TILE_SIZE / 2
|
||||
y = args[2].toInt() * TILE_SIZE + TILE_SIZE / 2
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
EchoError("Teleport: wrong number input.")
|
||||
@@ -86,8 +87,8 @@ internal object Teleport : ConsoleCommand {
|
||||
val x: Int
|
||||
val y: Int
|
||||
try {
|
||||
x = args[3].toInt() * CreateTileAtlas.TILE_SIZE + CreateTileAtlas.TILE_SIZE / 2
|
||||
y = args[4].toInt() * CreateTileAtlas.TILE_SIZE + CreateTileAtlas.TILE_SIZE / 2
|
||||
x = args[3].toInt() * TILE_SIZE + TILE_SIZE / 2
|
||||
y = args[4].toInt() * TILE_SIZE + TILE_SIZE / 2
|
||||
val actorID = args[1].toInt()
|
||||
|
||||
if (Terrarum.ingame!!.getActorByID(actorID) !is ActorWithBody) {
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
package net.torvald.terrarum.modulebasegame.debuggerapp
|
||||
|
||||
import net.torvald.EMDASH
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.ccM
|
||||
import net.torvald.terrarum.ccW
|
||||
import net.torvald.terrarum.ccY
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.ActorValue
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.console.SetAV
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.GridLayout
|
||||
import java.awt.event.MouseAdapter
|
||||
@@ -167,8 +164,8 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
|
||||
if (actor != null) {
|
||||
sb.append("toString: ${actor!!}\n")
|
||||
sb.append("X: ${actor!!.hitbox.canonicalX} (${(actor!!.hitbox.canonicalX / CreateTileAtlas.TILE_SIZE).toInt()})\n")
|
||||
sb.append("Y: ${actor!!.hitbox.canonicalY} (${(actor!!.hitbox.canonicalY / CreateTileAtlas.TILE_SIZE).toInt()})")
|
||||
sb.append("X: ${actor!!.hitbox.canonicalX} (${(actor!!.hitbox.canonicalX / TILE_SIZE).toInt()})\n")
|
||||
sb.append("Y: ${actor!!.hitbox.canonicalY} (${(actor!!.hitbox.canonicalY / TILE_SIZE).toInt()})")
|
||||
|
||||
avPosArea.text = "$sb"
|
||||
sb.setLength(0) // clear stringbuffer
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.IngameInstance
|
||||
import net.torvald.terrarum.Point2i
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
@@ -30,9 +31,7 @@ open class FixtureBase(
|
||||
|
||||
private val world: GameWorld
|
||||
get() = Terrarum.ingame!!.world
|
||||
|
||||
private val TSIZE = TILE_SIZE.toDouble()
|
||||
|
||||
|
||||
/**
|
||||
* Block-wise position of this fixture when it's placed on the world. Null if it's not on the world
|
||||
*/
|
||||
@@ -96,7 +95,7 @@ open class FixtureBase(
|
||||
worldBlockPos = Point2i(posX, posY)
|
||||
|
||||
this.isVisible = true
|
||||
this.hitbox.setFromWidthHeight(posX * TSIZE, posY * TSIZE, blockBox.width * TSIZE, blockBox.height * TSIZE)
|
||||
this.hitbox.setFromWidthHeight(posX * TILE_SIZED, posY * TILE_SIZED, blockBox.width * TILE_SIZED, blockBox.height * TILE_SIZED)
|
||||
|
||||
// actually add this actor into the world
|
||||
Terrarum.ingame!!.addNewActor(this)
|
||||
|
||||
@@ -2,15 +2,12 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.Second
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.floorInt
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.PhysProperties
|
||||
import net.torvald.terrarum.modulebasegame.worldgenerator.RoguelikeRandomiser
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.ai.NullAI
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ object PlayerBuilderCynthia {
|
||||
|
||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 9, 0)
|
||||
|
||||
p.setPosition(4096.0 * CreateTileAtlas.TILE_SIZE, 300.0 * CreateTileAtlas.TILE_SIZE)
|
||||
p.setPosition(4096.0 * TILE_SIZE, 300.0 * TILE_SIZE)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
@@ -75,7 +76,7 @@ object PlayerBuilderSigrid {
|
||||
|
||||
fun fillTestInventory(inventory: ActorInventory) {
|
||||
|
||||
CreateTileAtlas.tags.forEach { t, _ ->
|
||||
AppLoader.tileMaker.tags.forEach { t, _ ->
|
||||
inventory.add(t, 9995)
|
||||
try {
|
||||
inventory.add("wall@"+t, 9995) // this code will try to add nonexisting wall items, do not get surprised with NPEs
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.spriteanimation.SpriteAnimation
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
|
||||
@@ -33,7 +34,7 @@ object PlayerBuilderTestSubject1 {
|
||||
p.reassembleSprite(p.sprite!!, p.spriteGlow)
|
||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 21, 0)
|
||||
|
||||
p.setPosition(3.0 * CreateTileAtlas.TILE_SIZE, 3.0 * CreateTileAtlas.TILE_SIZE)
|
||||
p.setPosition(3.0 * TILE_SIZE, 3.0 * TILE_SIZE)
|
||||
|
||||
|
||||
PlayerBuilderSigrid.fillTestInventory(p.inventory)
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.spriteanimation.SpriteAnimation
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
|
||||
@@ -47,7 +48,7 @@ object PlayerBuilderWerebeastTest {
|
||||
p.reassembleSprite(p.sprite!!, p.spriteGlow)
|
||||
p.setHitboxDimension(22, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 30, 0)
|
||||
|
||||
p.setPosition(3.0 * CreateTileAtlas.TILE_SIZE, 3.0 * CreateTileAtlas.TILE_SIZE)
|
||||
p.setPosition(3.0 * TILE_SIZE, 3.0 * TILE_SIZE)
|
||||
|
||||
|
||||
PlayerBuilderSigrid.fillTestInventory(p.inventory)
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Pixmap
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
||||
import net.torvald.terrarum.ceilInt
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameworld
|
||||
|
||||
import com.badlogic.gdx.Input
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.blockproperties.Fluid
|
||||
@@ -11,8 +12,6 @@ import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.gameworld.FluidType
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
||||
import org.khelekore.prtree.*
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@@ -79,8 +78,8 @@ object WorldSimulator {
|
||||
//printdbg(this, "============================")
|
||||
|
||||
if (player != null) {
|
||||
updateXFrom = player.hitbox.centeredX.div(CreateTileAtlas.TILE_SIZE).minus(FLUID_UPDATING_SQUARE_RADIUS).roundToInt()
|
||||
updateYFrom = player.hitbox.centeredY.div(CreateTileAtlas.TILE_SIZE).minus(FLUID_UPDATING_SQUARE_RADIUS).roundToInt()
|
||||
updateXFrom = player.hitbox.centeredX.div(TILE_SIZE).minus(FLUID_UPDATING_SQUARE_RADIUS).roundToInt()
|
||||
updateYFrom = player.hitbox.centeredY.div(TILE_SIZE).minus(FLUID_UPDATING_SQUARE_RADIUS).roundToInt()
|
||||
updateXTo = updateXFrom + DOUBLE_RADIUS
|
||||
updateYTo = updateYFrom + DOUBLE_RADIUS
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.jme3.math.FastMath
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
@@ -146,7 +147,7 @@ internal object WeatherMixer : RNGConsumer {
|
||||
.| = // parallax of +1
|
||||
-+ <- 0.0 =
|
||||
*/
|
||||
val parallax = ((parallaxZeroPos - WorldCamera.gdxCamY.div(CreateTileAtlas.TILE_SIZE.toFloat())) / parallaxDomainSize).times(-1f).coerceIn(-1f, 1f)
|
||||
val parallax = ((parallaxZeroPos - WorldCamera.gdxCamY.div(TILE_SIZEF)) / parallaxDomainSize).times(-1f).coerceIn(-1f, 1f)
|
||||
val parallaxSize = 1f / 3f
|
||||
val parallaxMidpt = (parallax + 1f) / 2f
|
||||
val parallaxTop = (parallaxMidpt - (parallaxSize / 2f)).coerceIn(0f, 1f)
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.torvald.EMDASH
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.Terrarum.mouseTileX
|
||||
import net.torvald.terrarum.Terrarum.mouseTileY
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.controller.TerrarumController
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.imagefont.TinyAlphNum
|
||||
@@ -89,13 +90,13 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
+ ccG
|
||||
+ "${hitbox?.startX}"
|
||||
+ " ("
|
||||
+ "${(hitbox?.startX?.div(CreateTileAtlas.TILE_SIZE))?.toInt()}"
|
||||
+ "${(hitbox?.startX?.div(TILE_SIZE))?.toInt()}"
|
||||
+ ")")
|
||||
printLineColumn(batch, 2, 1, "endX "
|
||||
+ ccG
|
||||
+ "${hitbox?.endX}"
|
||||
+ " ("
|
||||
+ "${(hitbox?.endX?.div(CreateTileAtlas.TILE_SIZE))?.toInt()}"
|
||||
+ "${(hitbox?.endX?.div(TILE_SIZE))?.toInt()}"
|
||||
+ ")")
|
||||
printLineColumn(batch, 3, 1, "camX "
|
||||
+ ccG
|
||||
@@ -104,13 +105,13 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
+ ccG
|
||||
+ "${hitbox?.startY}"
|
||||
+ " ("
|
||||
+ "${(hitbox?.startY?.div(CreateTileAtlas.TILE_SIZE))?.toInt()}"
|
||||
+ "${(hitbox?.startY?.div(TILE_SIZE))?.toInt()}"
|
||||
+ ")")
|
||||
printLineColumn(batch, 2, 2, "endY "
|
||||
+ ccG
|
||||
+ "${hitbox?.endY}"
|
||||
+ " ("
|
||||
+ "${(hitbox?.endY?.div(CreateTileAtlas.TILE_SIZE))?.toInt()}"
|
||||
+ "${(hitbox?.endY?.div(TILE_SIZE))?.toInt()}"
|
||||
+ ")")
|
||||
printLineColumn(batch, 3, 2, "camY "
|
||||
+ ccG
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.badlogic.gdx.math.Matrix4
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
@@ -14,7 +15,6 @@ import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.WorldSimulator
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILES_IN_X
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@@ -35,8 +35,6 @@ internal object BlocksDrawer {
|
||||
/** World change is managed by IngameRenderer.setWorld() */
|
||||
internal var world: GameWorld = GameWorld.makeNullWorld()
|
||||
|
||||
private val TILE_SIZE = CreateTileAtlas.TILE_SIZE
|
||||
private val TILE_SIZEF = CreateTileAtlas.TILE_SIZE.toFloat()
|
||||
|
||||
/**
|
||||
* Widths of the tile atlases must have exactly the same width (height doesn't matter)
|
||||
@@ -98,16 +96,16 @@ internal object BlocksDrawer {
|
||||
|
||||
// create terrain texture from pixmaps
|
||||
weatherTerrains = arrayOf(
|
||||
TextureRegionPack(Texture(CreateTileAtlas.atlasSpring), TILE_SIZE, TILE_SIZE),
|
||||
TextureRegionPack(Texture(CreateTileAtlas.atlas), TILE_SIZE, TILE_SIZE),
|
||||
TextureRegionPack(Texture(CreateTileAtlas.atlasAutumn), TILE_SIZE, TILE_SIZE),
|
||||
TextureRegionPack(Texture(CreateTileAtlas.atlasWinter), TILE_SIZE, TILE_SIZE)
|
||||
TextureRegionPack(Texture(AppLoader.tileMaker.atlasSpring), TILE_SIZE, TILE_SIZE),
|
||||
TextureRegionPack(Texture(AppLoader.tileMaker.atlas), TILE_SIZE, TILE_SIZE),
|
||||
TextureRegionPack(Texture(AppLoader.tileMaker.atlasAutumn), TILE_SIZE, TILE_SIZE),
|
||||
TextureRegionPack(Texture(AppLoader.tileMaker.atlasWinter), TILE_SIZE, TILE_SIZE)
|
||||
)
|
||||
|
||||
//TODO make wire work with the TileAtlas system
|
||||
tilesWire = TextureRegionPack(ModMgr.getGdxFile("basegame", "blocks/wire.tga"), TILE_SIZE, TILE_SIZE)
|
||||
tilesFluid = TextureRegionPack(Texture(CreateTileAtlas.atlasFluid), TILE_SIZE, TILE_SIZE)
|
||||
tilesGlow = TextureRegionPack(Texture(CreateTileAtlas.atlasGlow), TILE_SIZE, TILE_SIZE)
|
||||
tilesFluid = TextureRegionPack(Texture(AppLoader.tileMaker.atlasFluid), TILE_SIZE, TILE_SIZE)
|
||||
tilesGlow = TextureRegionPack(Texture(AppLoader.tileMaker.atlasGlow), TILE_SIZE, TILE_SIZE)
|
||||
|
||||
|
||||
printdbg(this, "Making terrain and wall item textures...")
|
||||
@@ -117,8 +115,8 @@ internal object BlocksDrawer {
|
||||
// test print
|
||||
//PixmapIO2.writeTGA(Gdx.files.absolute("${AppLoader.defaultDir}/terrainitem.tga"), itemTerrainPixmap, false)
|
||||
|
||||
tileItemTerrain = TextureRegionPack(CreateTileAtlas.itemTerrainTexture, TILE_SIZE, TILE_SIZE)
|
||||
tileItemWall = TextureRegionPack(CreateTileAtlas.itemWallTexture, TILE_SIZE, TILE_SIZE)
|
||||
tileItemTerrain = TextureRegionPack(AppLoader.tileMaker.itemTerrainTexture, TILE_SIZE, TILE_SIZE)
|
||||
tileItemWall = TextureRegionPack(AppLoader.tileMaker.itemWallTexture, TILE_SIZE, TILE_SIZE)
|
||||
|
||||
|
||||
|
||||
@@ -321,10 +319,10 @@ internal object BlocksDrawer {
|
||||
0
|
||||
}
|
||||
|
||||
val renderTag = CreateTileAtlas.getRenderTag(thisTile)
|
||||
val renderTag = AppLoader.tileMaker.getRenderTag(thisTile)
|
||||
val tileNumberBase =
|
||||
if (mode == FLUID)
|
||||
CreateTileAtlas.fluidToTileNumber(world.getFluid(x, y))
|
||||
AppLoader.tileMaker.fluidToTileNumber(world.getFluid(x, y))
|
||||
else if (mode == WIRE)
|
||||
0 // TODO need new wire storing format
|
||||
else
|
||||
@@ -343,8 +341,8 @@ internal object BlocksDrawer {
|
||||
else -> throw IllegalArgumentException("Unknown mask type: ${renderTag.maskType}")
|
||||
}
|
||||
|
||||
var thisTileX = tileNumber % TILES_IN_X
|
||||
var thisTileY = tileNumber / TILES_IN_X
|
||||
var thisTileX = tileNumber % AppLoader.tileMaker.TILES_IN_X
|
||||
var thisTileY = tileNumber / AppLoader.tileMaker.TILES_IN_X
|
||||
|
||||
if (mode == FLUID && thisTileX == 22 && thisTileY == 3) {
|
||||
//println("tileNumberBase = $tileNumberBase, tileNumber = $tileNumber, fluid = ${world.getFluid(x, y)}")
|
||||
@@ -442,7 +440,7 @@ internal object BlocksDrawer {
|
||||
var ret = 0
|
||||
for (i in nearbyTiles.indices) {
|
||||
val fluid = world.getFluid(nearbyPos[i].x, nearbyPos[i].y)
|
||||
if (BlockCodex[nearbyTiles[i]].isSolid || (fluid.isFluid() && 0 < CreateTileAtlas.fluidFillToTileLevel(fluid.amount))) {
|
||||
if (BlockCodex[nearbyTiles[i]].isSolid || (fluid.isFluid() && 0 < AppLoader.tileMaker.fluidFillToTileLevel(fluid.amount))) {
|
||||
ret += (1 shl i) // add 1, 2, 4, 8 for i = 0, 1, 2, 3
|
||||
}
|
||||
}
|
||||
@@ -579,7 +577,7 @@ internal object BlocksDrawer {
|
||||
}
|
||||
val vertexColour = when (mode) {
|
||||
TERRAIN, WIRE, FLUID -> Color.WHITE
|
||||
WALL -> CreateTileAtlas.wallOverlayColour
|
||||
WALL -> AppLoader.tileMaker.wallOverlayColour
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
|
||||
@@ -729,7 +727,7 @@ internal object BlocksDrawer {
|
||||
tilesQuad.dispose()
|
||||
shader.dispose()
|
||||
|
||||
CreateTileAtlas.dispose()
|
||||
AppLoader.tileMaker.dispose()
|
||||
}
|
||||
|
||||
fun getRenderStartX(): Int = WorldCamera.x / TILE_SIZE
|
||||
@@ -738,10 +736,10 @@ internal object BlocksDrawer {
|
||||
fun getRenderEndX(): Int = clampWTile(getRenderStartX() + (WorldCamera.width / TILE_SIZE) + 2)
|
||||
fun getRenderEndY(): Int = clampHTile(getRenderStartY() + (WorldCamera.height / TILE_SIZE) + 2)
|
||||
|
||||
fun isConnectSelf(b: ItemID): Boolean = CreateTileAtlas.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_SELF
|
||||
fun isConnectMutual(b: ItemID): Boolean = CreateTileAtlas.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_MUTUAL
|
||||
fun isWallSticker(b: ItemID): Boolean = CreateTileAtlas.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_WALL_STICKER
|
||||
fun isPlatform(b: ItemID): Boolean = CreateTileAtlas.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_WALL_STICKER_CONNECT_SELF
|
||||
fun isConnectSelf(b: ItemID): Boolean = AppLoader.tileMaker.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_SELF
|
||||
fun isConnectMutual(b: ItemID): Boolean = AppLoader.tileMaker.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_MUTUAL
|
||||
fun isWallSticker(b: ItemID): Boolean = AppLoader.tileMaker.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_WALL_STICKER
|
||||
fun isPlatform(b: ItemID): Boolean = AppLoader.tileMaker.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_WALL_STICKER_CONNECT_SELF
|
||||
//fun isBlendMul(b: Int): Boolean = TILES_BLEND_MUL.contains(b)
|
||||
|
||||
fun tileInCamera(x: Int, y: Int) =
|
||||
|
||||
@@ -25,8 +25,8 @@ object BlocksDrawerOLD {
|
||||
lateinit var world: GameWorld
|
||||
|
||||
|
||||
private val TILE_SIZE = CreateTileAtlas.TILE_SIZE
|
||||
private val TILE_SIZEF = CreateTileAtlas.TILE_SIZE.toFloat()
|
||||
private val TILE_SIZE = TILE_SIZE
|
||||
private val TILE_SIZEF = TILE_SIZEF
|
||||
|
||||
// TODO modular
|
||||
//val tilesTerrain = SpriteSheet(ModMgr.getPath("basegame", "blocks/terrain.tga.gz"), TILE_SIZE, TILE_SIZE) // 64 MB
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.badlogic.gdx.utils.GdxRuntimeException
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.blockproperties.Fluid
|
||||
@@ -26,13 +27,12 @@ import kotlin.math.roundToInt
|
||||
*
|
||||
* Created by minjaesong on 2019-02-28.
|
||||
*/
|
||||
object CreateTileAtlas {
|
||||
class CreateTileAtlas {
|
||||
|
||||
const val MAX_TEX_SIZE = TerrarumAppConfiguration.MAX_TEX_SIZE
|
||||
const val TILE_SIZE = TerrarumAppConfiguration.TILE_SIZE
|
||||
const val TILES_IN_X = MAX_TEX_SIZE / TILE_SIZE
|
||||
val MAX_TEX_SIZE = AppLoader.getConfigInt("atlastexsize").coerceIn(1024, AppLoader.glInfo.GL_MAX_TEXTURE_SIZE)
|
||||
val TILES_IN_X = MAX_TEX_SIZE / TILE_SIZE
|
||||
|
||||
const val ITEM_ATLAS_TILES_X = 16
|
||||
val ITEM_ATLAS_TILES_X = 16
|
||||
|
||||
private val TOTAL_TILES = TILES_IN_X * TILES_IN_X
|
||||
|
||||
@@ -150,15 +150,15 @@ object CreateTileAtlas {
|
||||
val itemTerrainPixmap = Pixmap(16 * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888)
|
||||
val itemWallPixmap = Pixmap(16 * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888)
|
||||
|
||||
CreateTileAtlas.tags.toMap().forEach { id, tag ->
|
||||
tags.toMap().forEach { id, tag ->
|
||||
val tilePosFromAtlas = tag.tileNumber + maskTypetoTileIDForItemImage(tag.maskType)
|
||||
val srcX = (tilePosFromAtlas % TILES_IN_X) * TILE_SIZE
|
||||
val srcY = (tilePosFromAtlas / TILES_IN_X) * TILE_SIZE
|
||||
val t = tileIDtoItemSheetNumber(id)
|
||||
val destX = (t % ITEM_ATLAS_TILES_X) * TILE_SIZE
|
||||
val destY = (t / ITEM_ATLAS_TILES_X) * TILE_SIZE
|
||||
itemTerrainPixmap.drawPixmap(CreateTileAtlas.atlas, srcX, srcY, TILE_SIZE, TILE_SIZE, destX, destY, TILE_SIZE, TILE_SIZE)
|
||||
itemWallPixmap.drawPixmap(CreateTileAtlas.atlas, srcX, srcY, TILE_SIZE, TILE_SIZE, destX, destY, TILE_SIZE, TILE_SIZE)
|
||||
itemTerrainPixmap.drawPixmap(atlas, srcX, srcY, TILE_SIZE, TILE_SIZE, destX, destY, TILE_SIZE, TILE_SIZE)
|
||||
itemWallPixmap.drawPixmap(atlas, srcX, srcY, TILE_SIZE, TILE_SIZE, destX, destY, TILE_SIZE, TILE_SIZE)
|
||||
}
|
||||
// darken things for the wall
|
||||
for (y in 0 until itemWallPixmap.height) {
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.colourutil.ColourTemp
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockstats.BlockStats
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2015-12-31.
|
||||
@@ -17,7 +17,7 @@ object FeaturesDrawer {
|
||||
/** World change is managed by IngameRenderer.setWorld() */
|
||||
internal var world: GameWorld = GameWorld.makeNullWorld()
|
||||
|
||||
//const val TILE_SIZE = CreateTileAtlas.TILE_SIZE
|
||||
//const val TILE_SIZE = TILE_SIZE
|
||||
|
||||
private val ENV_COLTEMP_LOWEST = 5500
|
||||
private val ENV_COLTEMP_HIGHEST = 7500
|
||||
@@ -45,7 +45,7 @@ object FeaturesDrawer {
|
||||
* usually targeted for the environmental temperature (desert/winterland), hence the name.
|
||||
*/
|
||||
fun drawEnvOverlay(batch: SpriteBatch) {
|
||||
val onscreen_tiles_max = FastMath.ceil(AppLoader.screenSize.screenH * AppLoader.screenSize.screenW / FastMath.sqr (TILE_SIZE.toFloat())) * 2
|
||||
val onscreen_tiles_max = FastMath.ceil(AppLoader.screenSize.screenH * AppLoader.screenSize.screenW / FastMath.sqr(TILE_SIZEF)) * 2
|
||||
val onscreen_tiles_cap = onscreen_tiles_max / 4f
|
||||
val onscreen_cold_tiles = BlockStats.getCount(*TILES_COLD).toFloat()
|
||||
val onscreen_warm_tiles = BlockStats.getCount(*TILES_WARM).toFloat()
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.gdx.graphics.UnsafeCvecArray
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.blockproperties.Fluid
|
||||
@@ -34,7 +35,6 @@ import kotlin.system.exitProcess
|
||||
* own ingame renderer
|
||||
*/
|
||||
object LightmapRenderer {
|
||||
private const val TILE_SIZE = CreateTileAtlas.TILE_SIZE
|
||||
|
||||
/** World change is managed by IngameRenderer.setWorld() */
|
||||
private var world: GameWorld = GameWorld.makeNullWorld()
|
||||
@@ -91,7 +91,7 @@ object LightmapRenderer {
|
||||
|
||||
private const val AIR = Block.AIR
|
||||
|
||||
const val DRAW_TILE_SIZE: Float = CreateTileAtlas.TILE_SIZE / IngameRenderer.lightmapDownsample
|
||||
const val DRAW_TILE_SIZE: Float = TILE_SIZE / IngameRenderer.lightmapDownsample
|
||||
|
||||
internal var for_x_start = 0
|
||||
internal var for_y_start = 0
|
||||
|
||||
@@ -3,6 +3,8 @@ package net.torvald.terrarum.worlddrawer
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
||||
import net.torvald.terrarum.ceilInt
|
||||
import net.torvald.terrarum.floorInt
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
@@ -13,7 +15,6 @@ import org.dyn4j.geometry.Vector2
|
||||
* Created by minjaesong on 2016-12-30.
|
||||
*/
|
||||
object WorldCamera {
|
||||
private val TILE_SIZE = CreateTileAtlas.TILE_SIZE
|
||||
|
||||
//val zoom: Float
|
||||
// get() = Terrarum.ingame?.screenZoom ?: 1f
|
||||
@@ -82,8 +83,8 @@ object WorldCamera {
|
||||
|
||||
y = (FastMath.clamp(
|
||||
(player.hitbox.centeredY - pVecSum.y).toFloat() - height / 2,
|
||||
TILE_SIZE.toFloat(),
|
||||
world.height * TILE_SIZE - height - TILE_SIZE.toFloat()
|
||||
TILE_SIZEF,
|
||||
world.height * TILE_SIZE - height - TILE_SIZEF
|
||||
)).floorInt().clampCameraY(world)
|
||||
|
||||
xEnd = x + width
|
||||
|
||||
Reference in New Issue
Block a user