mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
the world is being unflipped wip
This commit is contained in:
@@ -131,36 +131,37 @@ class SpriteAnimation(@Transient val parentActor: ActorWithBody) : Disposable {
|
||||
val region = textureRegion.get(currentFrame, currentRow)
|
||||
// batch.color = colorFilter
|
||||
|
||||
//val scale = parentActor.scale.toFloat() // wtf?
|
||||
|
||||
if (flipHorizontal && flipVertical) {
|
||||
// val realTY = (parentActor.hitboxTranslateY + (cellHeight - parentActor.baseHitboxH)) * scale
|
||||
|
||||
if (flipHorizontal && !flipVertical) {
|
||||
batch.draw(region,
|
||||
FastMath.floor(posX).toFloat() + (2f * parentActor.hitboxTranslateX * scale + parentActor.hitbox.width.toFloat()),
|
||||
FastMath.floor(posY).toFloat() + (2f * parentActor.hitboxTranslateY * scale + parentActor.hitbox.height.toFloat()),
|
||||
FastMath.floor(posX).toFloat() + (parentActor.hitboxTranslateX + parentActor.baseHitboxW) * scale,
|
||||
FastMath.floor(posY).toFloat() + (parentActor.hitboxTranslateY + parentActor.baseHitboxH) * scale,
|
||||
-FastMath.floor(cellWidth * scale).toFloat(),
|
||||
-FastMath.floor(cellHeight * scale).toFloat()
|
||||
)
|
||||
}
|
||||
else if (flipHorizontal) {
|
||||
else if (flipHorizontal && flipVertical) {
|
||||
batch.draw(region,
|
||||
FastMath.floor(posX).toFloat() + (2f * parentActor.hitboxTranslateX * scale + parentActor.hitbox.width.toFloat()),
|
||||
FastMath.floor(posY).toFloat(),
|
||||
FastMath.floor(posX).toFloat() + (parentActor.hitboxTranslateX + parentActor.baseHitboxW) * scale,
|
||||
FastMath.floor(posY).toFloat() - (parentActor.hitboxTranslateY) * scale,
|
||||
-FastMath.floor(cellWidth * scale).toFloat(),
|
||||
FastMath.floor(cellHeight * scale).toFloat()
|
||||
)
|
||||
}
|
||||
else if (flipVertical) {
|
||||
else if (!flipHorizontal && !flipVertical) {
|
||||
batch.draw(region,
|
||||
FastMath.floor(posX).toFloat(),
|
||||
FastMath.floor(posY).toFloat() + (2f * parentActor.hitboxTranslateY * scale + parentActor.hitbox.height.toFloat()),
|
||||
FastMath.floor(posX).toFloat() - (parentActor.hitboxTranslateX) * scale,
|
||||
FastMath.floor(posY).toFloat() + (parentActor.hitboxTranslateY + parentActor.baseHitboxH) * scale,
|
||||
FastMath.floor(cellWidth * scale).toFloat(),
|
||||
-FastMath.floor(cellHeight * scale).toFloat()
|
||||
)
|
||||
}
|
||||
else {
|
||||
batch.draw(region,
|
||||
FastMath.floor(posX).toFloat(),
|
||||
FastMath.floor(posY).toFloat(),
|
||||
FastMath.floor(posX).toFloat() - (parentActor.hitboxTranslateX) * scale,
|
||||
FastMath.floor(posY).toFloat() - (parentActor.hitboxTranslateY) * scale,
|
||||
FastMath.floor(cellWidth * scale).toFloat(),
|
||||
FastMath.floor(cellHeight * scale).toFloat()
|
||||
)
|
||||
|
||||
@@ -397,10 +397,13 @@ public class App implements ApplicationListener {
|
||||
|
||||
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, false, false));
|
||||
CommonResourcePool.INSTANCE.addToLoadingList("blockmarkings_common", () -> new TextureRegionPack(Gdx.files.internal("assets/graphics/blocks/block_markings_common.tga"), 16, 16, 0, 0, 0, 0, false, false, true));
|
||||
CommonResourcePool.INSTANCE.addToLoadingList("blockmarking_actor", () -> new BlockMarkerActor());
|
||||
CommonResourcePool.INSTANCE.addToLoadingList("loading_circle_64", () -> new TextureRegionPack(Gdx.files.internal("assets/graphics/gui/loading_circle_64.tga"), 64, 64, 0, 0, 0, 0, false, false, false));
|
||||
CommonResourcePool.INSTANCE.addToLoadingList("inline_loading_spinner", () -> new TextureRegionPack(Gdx.files.internal("assets/graphics/gui/inline_loading_spinner.tga"), 20, 20, 0, 0, 0, 0, false, false, false));
|
||||
CommonResourcePool.INSTANCE.addToLoadingList("loading_circle_64", () -> new TextureRegionPack(Gdx.files.internal("assets/graphics/gui/loading_circle_64.tga"), 64, 64, 0, 0, 0, 0, false, false, true));
|
||||
CommonResourcePool.INSTANCE.addToLoadingList("inline_loading_spinner", () -> new TextureRegionPack(Gdx.files.internal("assets/graphics/gui/inline_loading_spinner.tga"), 20, 20, 0, 0, 0, 0, false, false, true));
|
||||
CommonResourcePool.INSTANCE.addToLoadingList("inventory_category", () -> new TextureRegionPack("./assets/graphics/gui/inventory/category.tga", 20, 20, 0, 0, 0, 0, false, false, true));
|
||||
CommonResourcePool.INSTANCE.addToLoadingList("title_health1", () -> new Texture(Gdx.files.internal("./assets/graphics/gui/health_take_a_break.tga")));
|
||||
CommonResourcePool.INSTANCE.addToLoadingList("title_health2", () -> new Texture(Gdx.files.internal("./assets/graphics/gui/health_distance.tga")));
|
||||
|
||||
newTempFile("wenquanyi.tga"); // temp file required by the font
|
||||
|
||||
@@ -418,9 +421,6 @@ public class App implements ApplicationListener {
|
||||
logo = new TextureRegion(new Texture(Gdx.files.internal("assets/graphics/logo_placeholder.tga")));
|
||||
logo.flip(false, true);
|
||||
|
||||
CommonResourcePool.INSTANCE.addToLoadingList("title_health1", () -> new Texture(Gdx.files.internal("./assets/graphics/gui/health_take_a_break.tga")));
|
||||
CommonResourcePool.INSTANCE.addToLoadingList("title_health2", () -> new Texture(Gdx.files.internal("./assets/graphics/gui/health_distance.tga")));
|
||||
|
||||
// set GL graphics constants
|
||||
for (int i = 0; i < ditherPatterns.length; i++) {
|
||||
Texture t = new Texture(Gdx.files.internal("assets/shaders/dither_512_"+i+".tga"));
|
||||
|
||||
@@ -1650,11 +1650,11 @@ open class ActorWithBody : Actor {
|
||||
protected fun drawSpriteInGoodPosition(sprite: SpriteAnimation, batch: SpriteBatch) {
|
||||
if (world == null) return
|
||||
|
||||
val offsetX = (hitboxTranslateX * scale).toFloat()
|
||||
val offsetY = (sprite.cellHeight * scale - hitbox.height - hitboxTranslateY * scale - 1).toFloat()
|
||||
val offsetX = 0f
|
||||
val offsetY = 1f // plant to the ground
|
||||
|
||||
drawBodyInGoodPosition(hitbox.startX.toFloat(), hitbox.startY.toFloat()) { x, y ->
|
||||
sprite.render(batch, x - offsetX, y - offsetY, scale.toFloat())
|
||||
sprite.render(batch, x + offsetX, y + offsetY, scale.toFloat())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ object IME {
|
||||
}
|
||||
|
||||
|
||||
val iconSheet = TextureRegionPack("assets/graphics/gui/ime_icons_by_language.tga", 20, 20)
|
||||
val iconSheet = TextureRegionPack("assets/graphics/gui/ime_icons_by_language.tga", 20, 20, flipY = true)
|
||||
val iconPixmap = Pixmap(Gdx.files.internal("assets/graphics/gui/ime_icons_by_language.tga"))
|
||||
for (k in 0 until iconPixmap.height step 20) {
|
||||
val langCode = StringBuilder()
|
||||
|
||||
@@ -38,9 +38,6 @@ class EntryPoint : ModuleEntryPoint() {
|
||||
CommonResourcePool.addToLoadingList("$moduleName.items48") {
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items48.tga"), 48, 48, flipY = true)
|
||||
}
|
||||
CommonResourcePool.addToLoadingList("inventory_category") {
|
||||
TextureRegionPack("./assets/graphics/gui/inventory/category.tga", 20, 20, flipY = true)
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class FixtureLogicSignalEmitter : FixtureBase, Electric {
|
||||
init {
|
||||
CommonResourcePool.addToLoadingList("basegame-sprites-fixtures-signal_source.tga") {
|
||||
val t = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "sprites/fixtures/signal_source.tga")))
|
||||
t.flip(false, false)
|
||||
t.flip(false, true)
|
||||
/*return*/t
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
|
||||
@@ -39,7 +39,7 @@ class UIItemSaving(parentUI: UICanvas, initialX: Int, initialY: Int) : UIItem(pa
|
||||
if (index >= 0) {
|
||||
val sx = index % circleSheet.horizontalCount
|
||||
val sy = index / circleSheet.horizontalCount
|
||||
batch.draw(circleSheet.get(sx, sy), (posX + (width - circleSheet.tileW) / 2).toFloat(), posY + height.toFloat(), circleSheet.tileW.toFloat(), circleSheet.tileH * -1f)
|
||||
batch.draw(circleSheet.get(sx, sy), (posX + (width - circleSheet.tileW) / 2).toFloat(), posY.toFloat())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user