intbox debugger is back

This commit is contained in:
minjaesong
2019-06-09 01:26:14 +09:00
parent b16c23f1f0
commit af29e1b598
7 changed files with 34 additions and 23 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -291,6 +291,7 @@ public class AppLoader implements ApplicationListener {
@Override
public void create() {
resourcePool = CommonResourcePool.INSTANCE;
resourcePool.addToLoadingList("blockmarkings_common", () -> new TextureRegionPack(Gdx.files.internal("assets/graphics/blocks/block_markings_common.tga"), 16, 16, 0, 0, 0, 0, false));
newTempFile("wenquanyi.tga"); // temp file required by the font
@@ -622,7 +623,7 @@ public class AppLoader implements ApplicationListener {
private void setCameraPosition(float newX, float newY) {
camera.position.set((-newX + appConfig.width / 2), (-newY + appConfig.height / 2), 0f);
camera.position.set((-newX + appConfig.width / 2), (-newY + appConfig.height / 2), 0f); // deliberate integer division
camera.update();
logoBatch.setProjectionMatrix(camera.combined);
}

View File

@@ -1,5 +1,7 @@
package net.torvald.terrarum.gameactors
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.spriteanimation.SpriteAnimation
import net.torvald.terrarum.*
@@ -7,6 +9,7 @@ import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.BlockProp
import net.torvald.terrarum.gamecontroller.KeyToggler
import net.torvald.terrarum.gameworld.BlockAddress
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
@@ -1354,25 +1357,33 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
override fun drawBody(batch: SpriteBatch) {
if (isVisible && sprite != null) {
//if (!KeyToggler.isOn(Input.Keys.F12)) {
BlendMode.resolve(drawMode, batch)
drawSpriteInGoodPosition(sprite!!, batch)
/*}
// ye olde tilewiseposition debugger, we don't use it anymore.
else {
batch.color = Color.NAVY
val hb = intTilewiseHitbox
BlendMode.resolve(drawMode, batch)
drawSpriteInGoodPosition(sprite!!, batch)
}
batch.fillRect(
hb.startX.toFloat() * TILE_SIZE,
hb.startY.toFloat() * TILE_SIZE,
hb.width.toFloat() * TILE_SIZE,
hb.height.toFloat() * TILE_SIZE
)
// debug display of hIntTilewiseHitbox
if (KeyToggler.isOn(Input.Keys.F9)) {
val blockMark = AppLoader.resourcePool.getAsTextureRegionPack("blockmarkings_common").get(0, 0)
batch.color = Color.VIOLET
batch.fillRect(hitbox.startX.toFloat(), hitbox.startY.toFloat(), hitbox.width.toFloat(), hitbox.height.toFloat())
}*/
batch.color = Color.MAGENTA
for (y in 0 until intTilewiseHitbox.height.toInt()) {
for (x in 0 until intTilewiseHitbox.width.toInt()) {
batch.draw(blockMark,
(intTilewiseHitbox.startX.toFloat() + x) * TILE_SIZEF,
(intTilewiseHitbox.startY.toFloat() * y) * TILE_SIZEF
)
}
}
batch.color = Color.YELLOW
for (y in 0 until hIntTilewiseHitbox.height.toInt()) {
for (x in 0 until hIntTilewiseHitbox.width.toInt()) {
batch.draw(blockMark,
(hIntTilewiseHitbox.startX.toFloat() + x) * TILE_SIZEF,
(hIntTilewiseHitbox.startY.toFloat() * y) * TILE_SIZEF
)
}
}
}
}

View File

@@ -38,7 +38,6 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable {
* TL;DR: LITTLE ENDIAN PLEASE
*/
constructor(width: Int, height: Int, data: ByteArray) : this(width, height) {
unsafe.allocateMemory(width * height * BYTES_PER_BLOCK.toLong())
data.forEachIndexed { index, byte -> unsafe.putByte(layerPtr + index, byte) }
unsafeArrayInitialised = true
}

View File

@@ -30,7 +30,6 @@ import net.torvald.terrarum.ui.UINSMenu
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
import net.torvald.terrarum.worlddrawer.LightmapRenderer
import net.torvald.terrarum.worlddrawer.WorldCamera
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import java.io.File
import java.io.FileOutputStream
@@ -134,7 +133,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
val selection = ArrayList<Point2i>()
val blockMarkings = TextureRegionPack(Gdx.files.internal("assets/graphics/blocks/block_markings_common.tga"), 16, 16)
val blockMarkings = AppLoader.resourcePool.getAsTextureRegionPack("blockmarkings_common")
internal var showSelection = true
val blockPointingCursor = object : ActorWithBody(Actor.RenderOrder.OVERLAY) {

View File

@@ -27,6 +27,7 @@ object BlockBase {
// check for collision with actors (BLOCK only)
// FIXME properly fix the collision detection: it OVERRIDES the tiki-torches which should not happen AT ALL
// FIXME (h)IntTilewiseHitbox is badly defined
if (gameItem.inventoryCategory == GameItem.Category.BLOCK) {
var ret1 = true
ingame.actorContainerActive.forEach {

Binary file not shown.