From a3bf1ed3f67fafb7fa73b548265b4aa83fbdc775 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 5 Mar 2024 21:20:51 +0900 Subject: [PATCH] d flipflop with full sprite --- assets/mods/basegame/items/items.tga | 2 +- .../sprites/fixtures/signal_latch.tga | 4 +-- .../sprites/fixtures/signal_latch_emsv.tga | 4 +-- .../gameactors/FixtureSignalBlocker.kt | 4 +++ .../gameactors/FixtureSignalLatch.kt | 25 +++++++++++++++---- work_files/graphics/items/basegame_items.kra | 4 +-- .../graphics/wires/wire_single_items.kra | 4 +-- 7 files changed, 33 insertions(+), 14 deletions(-) diff --git a/assets/mods/basegame/items/items.tga b/assets/mods/basegame/items/items.tga index 82157046a..7835ba1b1 100644 --- a/assets/mods/basegame/items/items.tga +++ b/assets/mods/basegame/items/items.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:657154947d1f36431568a9f8625bb7a0d26ebd41c8f7fa38287c0cb36801c46e +oid sha256:be1754a4c1bf9e64a1d5610939983ce19f29f07236a25c56e023720a4a1aab08 size 2408466 diff --git a/assets/mods/basegame/sprites/fixtures/signal_latch.tga b/assets/mods/basegame/sprites/fixtures/signal_latch.tga index 2c7b62c2c..1cbdf08d6 100644 --- a/assets/mods/basegame/sprites/fixtures/signal_latch.tga +++ b/assets/mods/basegame/sprites/fixtures/signal_latch.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:808185b5324f5721093daf9833d0a0302eb1ee6ad2d3530f0643ef9e7278ab9e -size 6162 +oid sha256:11eb913f22690b24f5a5d68022737c1fcddb99983d5f070b659cf79ba6fb820a +size 393234 diff --git a/assets/mods/basegame/sprites/fixtures/signal_latch_emsv.tga b/assets/mods/basegame/sprites/fixtures/signal_latch_emsv.tga index dd60cd863..a4f07654f 100644 --- a/assets/mods/basegame/sprites/fixtures/signal_latch_emsv.tga +++ b/assets/mods/basegame/sprites/fixtures/signal_latch_emsv.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:15f6c66914ec2b6a99657ec3b06e090bd06ca3a92a0831031176b4f18d784150 -size 6162 +oid sha256:a595360bac374a39f6f98469e3d97c4ad5dfbbd6a91db42d4898769e64e36717 +size 393234 diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureSignalBlocker.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureSignalBlocker.kt index 2ec0294aa..fd7a23a49 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureSignalBlocker.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureSignalBlocker.kt @@ -71,10 +71,14 @@ class FixtureSignalBlocker : Electric, Reorientable { override fun orientClockwise() { orientation = (orientation + 1) % 4 + (sprite as SheetSpriteAnimation).currentFrame = orientation + (spriteEmissive as SheetSpriteAnimation).currentFrame = orientation setEmitterAndSink(); updateK() } override fun orientAnticlockwise() { orientation = (orientation - 1) % 4 + (sprite as SheetSpriteAnimation).currentFrame = orientation + (spriteEmissive as SheetSpriteAnimation).currentFrame = orientation setEmitterAndSink(); updateK() } diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureSignalLatch.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureSignalLatch.kt index eeab99eba..9593d3d1a 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureSignalLatch.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureSignalLatch.kt @@ -1,5 +1,6 @@ package net.torvald.terrarum.modulebasegame.gameactors +import net.torvald.spriteanimation.SheetSpriteAnimation import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase @@ -47,10 +48,14 @@ class FixtureSignalLatch : Electric, Reorientable { override fun orientClockwise() { orientation = (orientation + 2) % 4 + (sprite as SheetSpriteAnimation).currentFrame = orientation / 2 + (spriteEmissive as SheetSpriteAnimation).currentFrame = orientation / 2 setEmitterAndSink(); updateQ() } override fun orientAnticlockwise() { orientation = (orientation - 2) % 4 + (sprite as SheetSpriteAnimation).currentFrame = orientation / 2 + (spriteEmissive as SheetSpriteAnimation).currentFrame = orientation / 2 setEmitterAndSink(); updateQ() } @@ -63,12 +68,12 @@ class FixtureSignalLatch : Electric, Reorientable { setHitboxDimension(2*TILE_SIZE, 3*TILE_SIZE, 0, 1) makeNewSprite(TextureRegionPack(itemImage.texture, 2*TILE_SIZE, 3*TILE_SIZE)).let { - it.setRowsAndFrames(16,4) - it.delays = FloatArray(16) { Float.POSITIVE_INFINITY } + it.setRowsAndFrames(32,2) + it.delays = FloatArray(32) { Float.POSITIVE_INFINITY } } makeNewSpriteEmissive(TextureRegionPack(itemImage2.texture, 2*TILE_SIZE, 3*TILE_SIZE)).let { - it.setRowsAndFrames(16,4) - it.delays = FloatArray(16) { Float.POSITIVE_INFINITY } + it.setRowsAndFrames(32,2) + it.delays = FloatArray(32) { Float.POSITIVE_INFINITY } } setEmitterAndSink() @@ -137,7 +142,17 @@ class FixtureSignalLatch : Electric, Reorientable { CLK0old = CLK0 - // TODO update sprite + // update sprite + val one = isSignalHigh(0, 0) + val two = isSignalHigh(1, 0) + val four = isSignalHigh(0, 1) or isSignalHigh(1, 1) + val eight = isSignalHigh(0, 2) + val sixteen = isSignalHigh(1, 2) + + val state = one.toInt(0) or two.toInt(1) or four.toInt(2) or eight.toInt(3) or sixteen.toInt(4) + + (sprite as SheetSpriteAnimation).currentRow = state + (spriteEmissive as SheetSpriteAnimation).currentRow = state } override fun updateSignal() { diff --git a/work_files/graphics/items/basegame_items.kra b/work_files/graphics/items/basegame_items.kra index e62bbba8e..260ea478c 100644 --- a/work_files/graphics/items/basegame_items.kra +++ b/work_files/graphics/items/basegame_items.kra @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:37967211b23bf87bc90280ea9800c243a0b7c59e5e761b72bd028edf0b8d9bf9 -size 1463128 +oid sha256:c5caeaabfde5bf7ac857936fecb6b6563ac8bd544d74bdc09b41ce343dbb2021 +size 1463025 diff --git a/work_files/graphics/wires/wire_single_items.kra b/work_files/graphics/wires/wire_single_items.kra index d9961fc1b..49bde9d77 100644 --- a/work_files/graphics/wires/wire_single_items.kra +++ b/work_files/graphics/wires/wire_single_items.kra @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8575952bba17c6fe9107162fdf9ea8879a7ca98fbc8b1eb6906d59f35478ca80 -size 476723 +oid sha256:e698c347662084aa0eaa4526ff18e77a54e2f07b9a11ce1572d3d05336b20c3a +size 573675