mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
somewhat successful walk/idle anim impl
This commit is contained in:
@@ -17,7 +17,6 @@ import java.io.StringReader;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Should be made into its own artifact to build.
|
||||
@@ -129,7 +128,7 @@ public class CSVEditor extends JFrame {
|
||||
|
||||
// then work on the file
|
||||
for (CSVRecord record : records) {
|
||||
Vector newRow = new Vector(columns.length);
|
||||
String[] newRow = new String[columns.length];
|
||||
|
||||
// construct newRow
|
||||
for (String column : columns) {
|
||||
@@ -138,7 +137,7 @@ public class CSVEditor extends JFrame {
|
||||
value = csvFormat.getNullString();
|
||||
}
|
||||
|
||||
newRow.add(spreadsheet.getColumnModel().getColumnIndex(column), value);
|
||||
newRow[spreadsheet.getColumnModel().getColumnIndex(column)] = value;
|
||||
}
|
||||
|
||||
((DefaultTableModel) spreadsheet.getModel()).addRow(newRow);
|
||||
@@ -273,6 +272,9 @@ public class CSVEditor extends JFrame {
|
||||
|
||||
|
||||
statBar.setText(lang.getProperty("STAT_INIT"));
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -274,7 +274,8 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
/** Load rest of the game with GL context */
|
||||
fun postInit() {
|
||||
setTheRealGamerFirstTime(PlayerBuilderSigrid())
|
||||
//setTheRealGamerFirstTime(PlayerBuilderSigrid())
|
||||
setTheRealGamerFirstTime(PlayerBuilderTestSubject1())
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,9 +3,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.bipolarClamp
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameactors.faction.Faction
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
@@ -612,14 +610,15 @@ open class ActorHumanoid(
|
||||
sprite?.update(delta)
|
||||
spriteGlow?.update(delta)
|
||||
|
||||
//println("$this\tsprite current frame: ${sprite!!.currentFrame}")
|
||||
if (walledBottom && controllerMoveDelta?.x != 0.0) {
|
||||
//switch row
|
||||
sprite?.switchRow(SPRITE_ROW_WALK)
|
||||
spriteGlow?.switchRow(SPRITE_ROW_WALK)
|
||||
|
||||
if (walledBottom) {
|
||||
// set anim row
|
||||
if (controllerMoveDelta?.x != 0.0) {
|
||||
sprite?.switchRow(SPRITE_ROW_WALK)
|
||||
spriteGlow?.switchRow(SPRITE_ROW_WALK)
|
||||
}
|
||||
// set anim frame delay
|
||||
// 4f of the divider is a magic number, empirically decided
|
||||
sprite?.delays?.set(SPRITE_ROW_WALK, scale.sqrt().toFloat() / (4f * (controllerMoveDelta?.x ?: 0.0001).abs().toFloat())) // FIXME empirical value
|
||||
spriteGlow?.delays?.set(SPRITE_ROW_WALK, scale.sqrt().toFloat() / (4f * (controllerMoveDelta?.x ?: 0.0001).abs().toFloat())) // FIXME empirical value
|
||||
|
||||
// flipping the sprite
|
||||
if (walkHeading == LEFT) {
|
||||
|
||||
@@ -34,7 +34,6 @@ internal class FixtureTikiTorch : FixtureBase(
|
||||
lightBoxList.add(Hitbox(3.0, 0.0, 4.0, 3.0))
|
||||
|
||||
makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/fixtures/tiki_torch.tga"), 10, 27))
|
||||
sprite!!.delay = 0.2f
|
||||
sprite!!.setRowsAndFrames(1, 1)
|
||||
|
||||
actorValue[AVKey.BASEMASS] = 1.0
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ai.NullAI
|
||||
@@ -28,7 +27,6 @@ object PlayerBuilderCynthia {
|
||||
|
||||
|
||||
p.makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/test_player_2.tga"), 26, 42))
|
||||
p.sprite!!.delay = 0.2f
|
||||
p.sprite!!.setRowsAndFrames(1, 1)
|
||||
|
||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 9, 0)
|
||||
|
||||
@@ -20,11 +20,9 @@ object PlayerBuilderSigrid {
|
||||
|
||||
|
||||
p.makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/test_player.tga"), 28, 51))
|
||||
p.sprite!!.delay = 0.2f
|
||||
p.sprite!!.setRowsAndFrames(1, 1)
|
||||
|
||||
p.makeNewSpriteGlow(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/test_player_glow.tga"), 28, 51))
|
||||
p.spriteGlow!!.delay = 0.2f
|
||||
p.spriteGlow!!.setRowsAndFrames(1, 1)
|
||||
|
||||
p.actorValue[AVKey.SCALE] = 1.0
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
@@ -23,12 +21,12 @@ object PlayerBuilderTestSubject1 {
|
||||
|
||||
|
||||
p.makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/npc_template_anim_prototype.tga"), 48, 52))
|
||||
p.sprite!!.delay = 0.2f
|
||||
p.sprite!!.delays = floatArrayOf(2f, 1f/12f) // second value does nothing -- overridden by ActorHumanoid.updateSprite(float)
|
||||
p.sprite!!.setRowsAndFrames(2, 4)
|
||||
|
||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 21, 0)
|
||||
|
||||
p.setPosition(4096.0 * FeaturesDrawer.TILE_SIZE, 300.0 * FeaturesDrawer.TILE_SIZE)
|
||||
p.setPosition(3.0 * FeaturesDrawer.TILE_SIZE, 3.0 * FeaturesDrawer.TILE_SIZE)
|
||||
|
||||
|
||||
|
||||
|
||||
65
src/net/torvald/terrarum/tests/RGBtoXYZBenchmark.kt
Normal file
65
src/net/torvald/terrarum/tests/RGBtoXYZBenchmark.kt
Normal file
@@ -0,0 +1,65 @@
|
||||
package net.torvald.terrarum.tests
|
||||
|
||||
import net.torvald.colourutil.CIEXYZUtil.linearise
|
||||
import net.torvald.colourutil.CIEXYZUtil.unLinearise
|
||||
import net.torvald.colourutil.ColourUtil.getLuminosity
|
||||
import net.torvald.colourutil.ColourUtil.getLuminosityQuick
|
||||
import net.torvald.colourutil.RGB
|
||||
import net.torvald.random.HQRNG
|
||||
import kotlin.system.measureNanoTime
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2019-01-03.
|
||||
*/
|
||||
class RGBtoXYZBenchmark {
|
||||
|
||||
private val TEST_SIZE = 100000
|
||||
private val TEST_CHUNK = 1000
|
||||
|
||||
operator fun invoke() {
|
||||
val rng = HQRNG()
|
||||
// prepare test sets
|
||||
val testSets = Array(TEST_SIZE) {
|
||||
RGB(rng.nextFloat(), rng.nextFloat(), rng.nextFloat())
|
||||
}
|
||||
// make sure to initialise Util's LUT
|
||||
testSets[rng.nextInt(0, testSets.size)].linearise()
|
||||
testSets[rng.nextInt(0, testSets.size)].unLinearise()
|
||||
|
||||
|
||||
// conduct the experiment
|
||||
val timer1 = ArrayList<Long>()
|
||||
val timer2 = ArrayList<Long>()
|
||||
|
||||
|
||||
for (i in 0 until TEST_SIZE step TEST_CHUNK) {
|
||||
|
||||
val time1 = measureNanoTime {
|
||||
for (c in i until i + TEST_CHUNK) {
|
||||
testSets[c].getLuminosity()
|
||||
}
|
||||
}
|
||||
|
||||
val time2 = measureNanoTime {
|
||||
for (c in i until i + TEST_CHUNK) {
|
||||
testSets[c].getLuminosityQuick()
|
||||
}
|
||||
}
|
||||
|
||||
timer1.add(time1)
|
||||
timer2.add(time2)
|
||||
}
|
||||
|
||||
|
||||
// print out captured data
|
||||
println("with LUT\tno LUT\tmult")
|
||||
for (i in 0 until timer1.size) {
|
||||
println("${timer1[i]}\t${timer2[i]}\t${timer1[i].toFloat() / timer2[i]}")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
RGBtoXYZBenchmark().invoke()
|
||||
}
|
||||
Reference in New Issue
Block a user