mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-09 13:21:51 +09:00
PNG -> TGA
Former-commit-id: 394d3af24b5f1a125c40197a09f47867cc6fc566 Former-commit-id: 5428b1d2d7370b5a912851d5f5aa9f6b036f64f5
This commit is contained in:
@@ -33,7 +33,7 @@ class ColouredFastFont(val vt: Terminal, fontRef: String, val fontW: Int, val fo
|
||||
sheetImageBuffer = Image(sheetW, sheetH)
|
||||
|
||||
for (i in 0..vt.coloursCount - 1) {
|
||||
val sheet = SpriteSheet("$fontRef.$i.png", fontW, fontH)
|
||||
val sheet = SpriteSheet("$fontRef.$i.tga", fontW, fontH)
|
||||
colouredSheet.add(sheet)
|
||||
|
||||
//sheetImageBuffer.graphics.clear()
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.torvald.colourutil.CIEXYZUtil.toColor
|
||||
* Created by minjaesong on 16-07-26.
|
||||
*/
|
||||
object ColourTemp {
|
||||
private var envOverlayColourmap = Image("./assets/graphics/colourmap/black_body_col_1000_40000_K.png")
|
||||
private var envOverlayColourmap = Image("./assets/graphics/colourmap/black_body_col_1000_40000_K.tga")
|
||||
|
||||
private fun colTempToImagePos(K: Int): Int {
|
||||
if (K < 1000 || K >= 40000) throw IllegalArgumentException("K: out of range. ($K)")
|
||||
|
||||
@@ -10,52 +10,52 @@ class GameFontWhite : GameFontBase() {
|
||||
init {
|
||||
|
||||
GameFontBase.hangulSheet = SpriteSheet(
|
||||
"./assets/graphics/fonts/hangul_johab.png", GameFontBase.W_HANGUL, GameFontBase.H_HANGUL)
|
||||
"./assets/graphics/fonts/hangul_johab.tga", GameFontBase.W_HANGUL, GameFontBase.H_HANGUL)
|
||||
GameFontBase.asciiSheet = SpriteSheet(
|
||||
"./assets/graphics/fonts/ascii_fullwidth.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
"./assets/graphics/fonts/ascii_fullwidth.tga", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
GameFontBase.asciiSheetEF = SpriteSheet(
|
||||
"./assets/graphics/fonts/ascii_special_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
|
||||
"./assets/graphics/fonts/ascii_special_ef.tga", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
|
||||
GameFontBase.runicSheet = SpriteSheet(
|
||||
"./assets/graphics/fonts/futhark.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
"./assets/graphics/fonts/futhark.tga", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
GameFontBase.extASheet = SpriteSheet(
|
||||
"./assets/graphics/fonts/LatinExtA_fullwidth.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
"./assets/graphics/fonts/LatinExtA_fullwidth.tga", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
GameFontBase.extASheetEF = SpriteSheet(
|
||||
"./assets/graphics/fonts/LatinExtA_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
|
||||
"./assets/graphics/fonts/LatinExtA_ef.tga", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
|
||||
GameFontBase.kanaSheet = SpriteSheet(
|
||||
"./assets/graphics/fonts/kana.png", GameFontBase.W_KANA, GameFontBase.H_KANA)
|
||||
"./assets/graphics/fonts/kana.tga", GameFontBase.W_KANA, GameFontBase.H_KANA)
|
||||
GameFontBase.cjkPunct = SpriteSheet(
|
||||
"./assets/graphics/fonts/cjkpunct.png", GameFontBase.W_ASIAN_PUNCT, GameFontBase.H_KANA)
|
||||
"./assets/graphics/fonts/cjkpunct.tga", GameFontBase.W_ASIAN_PUNCT, GameFontBase.H_KANA)
|
||||
/*uniHan = new SpriteSheet(
|
||||
"./assets/graphics/fonts/unifont_unihan"
|
||||
+ ((!terrarum.gameLocale.contains("zh"))
|
||||
? "_ja" : "")
|
||||
+".png"
|
||||
+".tga"
|
||||
, W_UNIHAN, H_UNIHAN
|
||||
);*/
|
||||
GameFontBase.cyrilic = SpriteSheet(
|
||||
"./assets/graphics/fonts/cyrilic_fullwidth.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
"./assets/graphics/fonts/cyrilic_fullwidth.tga", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
GameFontBase.cyrilicEF = SpriteSheet(
|
||||
"./assets/graphics/fonts/cyrilic_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
|
||||
"./assets/graphics/fonts/cyrilic_ef.tga", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
|
||||
GameFontBase.fullwidthForms = SpriteSheet(
|
||||
"./assets/graphics/fonts/fullwidth_forms.png", GameFontBase.W_UNIHAN, GameFontBase.H_UNIHAN)
|
||||
"./assets/graphics/fonts/fullwidth_forms.tga", GameFontBase.W_UNIHAN, GameFontBase.H_UNIHAN)
|
||||
GameFontBase.uniPunct = SpriteSheet(
|
||||
"./assets/graphics/fonts/unipunct.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
"./assets/graphics/fonts/unipunct.tga", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
GameFontBase.wenQuanYi_1 = SpriteSheet(
|
||||
"./assets/graphics/fonts/wenquanyi_11pt_part1.png", 16, 18, 2)
|
||||
"./assets/graphics/fonts/wenquanyi_11pt_part1.tga", 16, 18, 2)
|
||||
GameFontBase.wenQuanYi_2 = SpriteSheet(
|
||||
"./assets/graphics/fonts/wenquanyi_11pt_part2.png", 16, 18, 2)
|
||||
"./assets/graphics/fonts/wenquanyi_11pt_part2.tga", 16, 18, 2)
|
||||
GameFontBase.greekSheet = SpriteSheet(
|
||||
"./assets/graphics/fonts/greek_fullwidth.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
"./assets/graphics/fonts/greek_fullwidth.tga", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
GameFontBase.greekSheetEF = SpriteSheet(
|
||||
"./assets/graphics/fonts/greek_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
|
||||
"./assets/graphics/fonts/greek_ef.tga", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
|
||||
GameFontBase.romanianSheet = SpriteSheet(
|
||||
"./assets/graphics/fonts/romana_fullwidth.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
"./assets/graphics/fonts/romana_fullwidth.tga", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
GameFontBase.romanianSheetEF = SpriteSheet(
|
||||
"./assets/graphics/fonts/romana_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
|
||||
"./assets/graphics/fonts/romana_ef.tga", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
|
||||
GameFontBase.thaiSheet = SpriteSheet(
|
||||
"./assets/graphics/fonts/thai_fullwidth.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
"./assets/graphics/fonts/thai_fullwidth.tga", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
|
||||
GameFontBase.keycapSheet = SpriteSheet(
|
||||
"./assets/graphics/fonts/puae000-e07f.png", GameFontBase.SIZE_KEYCAP, GameFontBase.SIZE_KEYCAP)
|
||||
"./assets/graphics/fonts/puae000-e07f.tga", GameFontBase.SIZE_KEYCAP, GameFontBase.SIZE_KEYCAP)
|
||||
|
||||
val shk = arrayOf(
|
||||
GameFontBase.asciiSheet,
|
||||
|
||||
@@ -28,7 +28,7 @@ class TinyAlphNum : Font {
|
||||
private val mappingTable = HashMap<Int, Int>()*/
|
||||
|
||||
init {
|
||||
fontSheet = SpriteSheet("./assets/graphics/fonts/milky.png", W, H)
|
||||
fontSheet = SpriteSheet("./assets/graphics/fonts/milky.tga", W, H)
|
||||
//chars.forEachIndexed { i, c -> mappingTable[c.toInt()] = i }
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.nio.ByteOrder
|
||||
class StateBlurTest : BasicGameState() {
|
||||
|
||||
/** Warning: the image must have a bit depth of 32! (use 32-bit PNG or TGA) */
|
||||
private val testImage = Image("./assets/testimage_resized.png")
|
||||
private val testImage = Image("./assets/testimage_resized.tga")
|
||||
private val bluredImage = ImageBuffer(testImage.width, testImage.height)
|
||||
|
||||
override fun init(gc: GameContainer, sbg: StateBasedGame) {
|
||||
|
||||
@@ -22,7 +22,7 @@ class StateFontTester : BasicGameState() {
|
||||
Terrarum.gameLocale = "fiFI"
|
||||
|
||||
segfont = SpriteSheetFont(
|
||||
SpriteSheet("./assets/graphics/fonts/24-seg_red.png", 22, 31),
|
||||
SpriteSheet("./assets/graphics/fonts/24-seg_red.tga", 22, 31),
|
||||
' '
|
||||
)
|
||||
}
|
||||
|
||||
@@ -56,6 +56,11 @@ constructor() : BasicGameState() {
|
||||
val actorContainerInactive = ArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
val uiContainer = ArrayList<UIHandler>()
|
||||
|
||||
private val actorsRenderBehind = ArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
private val actorsRenderMiddle = ArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
private val actorsRenderMidTop = ArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
private val actorsRenderFront = ArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
|
||||
lateinit var consoleHandler: UIHandler
|
||||
lateinit var debugWindow: UIHandler
|
||||
lateinit var notifier: UIHandler
|
||||
@@ -72,7 +77,9 @@ constructor() : BasicGameState() {
|
||||
val ZOOM_MIN = 0.5f
|
||||
|
||||
val worldDrawFrameBuffer = Image(Terrarum.WIDTH.div(ZOOM_MIN).ceilInt(), Terrarum.HEIGHT.div(ZOOM_MIN).ceilInt())
|
||||
val worldG = worldDrawFrameBuffer.graphics
|
||||
val uisDrawFrameBuffer = Image(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||
val uiG = uisDrawFrameBuffer.graphics
|
||||
|
||||
//private lateinit var shader12BitCol: Shader // grab LibGDX if you want some shader
|
||||
//private lateinit var shaderBlur: Shader
|
||||
@@ -285,48 +292,35 @@ constructor() : BasicGameState() {
|
||||
|
||||
override fun render(gc: GameContainer, sbg: StateBasedGame, gwin: Graphics) {
|
||||
// clean the shit beforehand
|
||||
worldDrawFrameBuffer.graphics.clear()
|
||||
uisDrawFrameBuffer.graphics.clear()
|
||||
worldG.clear()
|
||||
uiG.clear()
|
||||
|
||||
blendNormal()
|
||||
|
||||
|
||||
drawSkybox(gwin)
|
||||
/*drawSkybox(worldDrawFrameBuffer.graphics)
|
||||
uisDrawFrameBuffer.graphics.color = Color(255, 255, 255, 0)
|
||||
uisDrawFrameBuffer.graphics.fillRect(
|
||||
0f, 0f, uisDrawFrameBuffer.width.toFloat(), uisDrawFrameBuffer.height.toFloat()
|
||||
)*/
|
||||
|
||||
|
||||
// make camara work //
|
||||
// compensate for zoom. UIs must be treated specially! (see UIHandler)
|
||||
//g.translate(-MapCamera.x * screenZoom, -MapCamera.y * screenZoom)
|
||||
worldDrawFrameBuffer.graphics.translate(-MapCamera.x.toFloat(), -MapCamera.y.toFloat())
|
||||
worldG.translate(-MapCamera.x.toFloat(), -MapCamera.y.toFloat())
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// draw map related stuffs //
|
||||
/////////////////////////////
|
||||
TilesDrawer.renderBehind(gc, worldDrawFrameBuffer.graphics)
|
||||
// --> blendNormal() <-- by TilesDrawer.renderBehind
|
||||
|
||||
TilesDrawer.renderWall(worldG)
|
||||
actorsRenderBehind.forEach { actor -> actor.drawBody(worldG) }
|
||||
actorsRenderBehind.forEach { actor -> actor.drawGlow(worldG) }
|
||||
TilesDrawer.renderTerrain(worldG)
|
||||
|
||||
/////////////////
|
||||
// draw actors //
|
||||
/////////////////
|
||||
actorContainer.forEach { actor ->
|
||||
if (actor is ActorWithBody && actor.inScreen() && actor !is Player && !actor.drawTopmost) {
|
||||
actor.drawBody(gc, worldDrawFrameBuffer.graphics)
|
||||
}
|
||||
}
|
||||
player.drawBody(gc, worldDrawFrameBuffer.graphics)
|
||||
// actors that are drawTopmost
|
||||
actorContainer.forEach { actor ->
|
||||
if (actor is ActorWithBody && actor.inScreen() && actor !is Player && actor.drawTopmost) {
|
||||
actor.drawBody(gc, worldDrawFrameBuffer.graphics)
|
||||
}
|
||||
}
|
||||
actorsRenderMiddle.forEach { actor -> actor.drawBody(worldG) }
|
||||
actorsRenderMidTop.forEach { actor -> actor.drawBody(worldG) }
|
||||
player.drawBody(worldG)
|
||||
actorsRenderFront.forEach { actor -> actor.drawBody(worldG) }
|
||||
// --> Change of blend mode <-- introduced by ActorWithBody //
|
||||
|
||||
|
||||
@@ -335,33 +329,25 @@ constructor() : BasicGameState() {
|
||||
/////////////////////////////
|
||||
LightmapRenderer.renderLightMap()
|
||||
|
||||
TilesDrawer.renderFront(gc, worldDrawFrameBuffer.graphics, false)
|
||||
TilesDrawer.renderFront(worldG, false)
|
||||
// --> blendNormal() <-- by TilesDrawer.renderFront
|
||||
FeaturesDrawer.render(gc, worldDrawFrameBuffer.graphics)
|
||||
FeaturesDrawer.render(gc, worldG)
|
||||
|
||||
|
||||
FeaturesDrawer.drawEnvOverlay(worldDrawFrameBuffer.graphics)
|
||||
FeaturesDrawer.drawEnvOverlay(worldG)
|
||||
|
||||
if (!KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) blendMul()
|
||||
else blendNormal()
|
||||
LightmapRenderer.draw(worldDrawFrameBuffer.graphics)
|
||||
LightmapRenderer.draw(worldG)
|
||||
|
||||
|
||||
//////////////////////
|
||||
// draw actor glows //
|
||||
//////////////////////
|
||||
actorContainer.forEach { actor ->
|
||||
if (actor is ActorWithBody && actor.inScreen() && actor !is Player) {
|
||||
actor.drawGlow(gc, worldDrawFrameBuffer.graphics)
|
||||
}
|
||||
}
|
||||
player.drawGlow(gc, worldDrawFrameBuffer.graphics)
|
||||
// actors that are drawTopmost
|
||||
actorContainer.forEach { actor ->
|
||||
if (actor is ActorWithBody && actor.inScreen() && actor !is Player && actor.drawTopmost) {
|
||||
actor.drawGlow(gc, worldDrawFrameBuffer.graphics)
|
||||
}
|
||||
}
|
||||
actorsRenderMiddle.forEach { actor -> actor.drawGlow(worldG) }
|
||||
actorsRenderMidTop.forEach { actor -> actor.drawGlow(worldG) }
|
||||
player.drawGlow(worldG)
|
||||
actorsRenderFront.forEach { actor -> actor.drawGlow(worldG) }
|
||||
// --> blendLightenOnly() <-- introduced by ActorWithBody //
|
||||
|
||||
|
||||
@@ -373,17 +359,17 @@ constructor() : BasicGameState() {
|
||||
if (debugWindow.isVisible) {
|
||||
actorContainer.forEachIndexed { i, actor ->
|
||||
if (actor is ActorWithBody) {
|
||||
worldDrawFrameBuffer.graphics.color = Color.white
|
||||
worldDrawFrameBuffer.graphics.font = Terrarum.fontSmallNumbers
|
||||
worldDrawFrameBuffer.graphics.drawString(
|
||||
worldG.color = Color.white
|
||||
worldG.font = Terrarum.fontSmallNumbers
|
||||
worldG.drawString(
|
||||
actor.referenceID.toString(),
|
||||
actor.hitbox.posX.toFloat(),
|
||||
actor.hitbox.pointedY.toFloat() + 4
|
||||
)
|
||||
|
||||
if (DEBUG_ARRAY) {
|
||||
worldDrawFrameBuffer.graphics.color = GameFontBase.codeToCol["g"]
|
||||
worldDrawFrameBuffer.graphics.drawString(
|
||||
worldG.color = GameFontBase.codeToCol["g"]
|
||||
worldG.drawString(
|
||||
i.toString(),
|
||||
actor.hitbox.posX.toFloat(),
|
||||
actor.hitbox.pointedY.toFloat() + 4 + 10
|
||||
@@ -394,16 +380,16 @@ constructor() : BasicGameState() {
|
||||
}
|
||||
// fluidmap debug
|
||||
if (KeyToggler.isOn(Key.F4))
|
||||
WorldSimulator.drawFluidMapDebug(worldDrawFrameBuffer.graphics)
|
||||
WorldSimulator.drawFluidMapDebug(worldG)
|
||||
|
||||
|
||||
//////////////
|
||||
// draw UIs //
|
||||
//////////////
|
||||
uiContainer.forEach { ui -> ui.render(gc, sbg, uisDrawFrameBuffer.graphics) }
|
||||
debugWindow.render(gc, sbg, uisDrawFrameBuffer.graphics)
|
||||
consoleHandler.render(gc, sbg, uisDrawFrameBuffer.graphics)
|
||||
notifier.render(gc, sbg, uisDrawFrameBuffer.graphics)
|
||||
uiContainer.forEach { ui -> ui.render(gc, sbg, uiG) }
|
||||
debugWindow.render(gc, sbg, uiG)
|
||||
consoleHandler.render(gc, sbg, uiG)
|
||||
notifier.render(gc, sbg, uiG)
|
||||
|
||||
|
||||
/////////////////
|
||||
@@ -609,7 +595,7 @@ constructor() : BasicGameState() {
|
||||
else
|
||||
actorContainer.binarySearch(ID) >= 0
|
||||
|
||||
fun removeActor(actor: Actor) = removeActor(actor.referenceID)
|
||||
fun removeActor(ID: Int) = removeActor(getActorByID(ID))
|
||||
/**
|
||||
* get index of the actor and delete by the index.
|
||||
* we can do this as the list is guaranteed to be sorted
|
||||
@@ -618,10 +604,35 @@ constructor() : BasicGameState() {
|
||||
* Any values behind the index will be automatically pushed to front.
|
||||
* This is how remove function of [java.util.ArrayList] is defined.
|
||||
*/
|
||||
fun removeActor(ID: Int) {
|
||||
if (ID == player.referenceID) throw RuntimeException("Attempted to remove player.")
|
||||
val indexToDelete = actorContainer.binarySearch(ID)
|
||||
if (indexToDelete >= 0) actorContainer.removeAt(indexToDelete)
|
||||
fun removeActor(actor: Actor) {
|
||||
if (actor.referenceID == player.referenceID) throw RuntimeException("Attempted to remove player.")
|
||||
val indexToDelete = actorContainer.binarySearch(actor.referenceID)
|
||||
if (indexToDelete >= 0) {
|
||||
actorContainer.removeAt(indexToDelete)
|
||||
|
||||
// indexToDelete >= 0 means that the actor certainly exists in the game
|
||||
// which means we don't need to check if i >= 0 again
|
||||
if (actor is ActorWithBody) {
|
||||
when (actor.renderOrder) {
|
||||
ActorOrder.BEHIND -> {
|
||||
val i = actorsRenderBehind.binarySearch(actor.referenceID)
|
||||
actorsRenderBehind.removeAt(i)
|
||||
}
|
||||
ActorOrder.MIDDLE -> {
|
||||
val i = actorsRenderMiddle.binarySearch(actor.referenceID)
|
||||
actorsRenderMiddle.removeAt(i)
|
||||
}
|
||||
ActorOrder.MIDTOP -> {
|
||||
val i = actorsRenderMidTop.binarySearch(actor.referenceID)
|
||||
actorsRenderMidTop.removeAt(i)
|
||||
}
|
||||
ActorOrder.FRONT -> {
|
||||
val i = actorsRenderFront.binarySearch(actor.referenceID)
|
||||
actorsRenderFront.removeAt(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -632,6 +643,15 @@ constructor() : BasicGameState() {
|
||||
throw RuntimeException("Actor with ID ${actor.referenceID} already exists.")
|
||||
actorContainer.add(actor)
|
||||
insertionSortLastElem(actorContainer) // we can do this as we are only adding single actor
|
||||
|
||||
if (actor is ActorWithBody) {
|
||||
when (actor.renderOrder) {
|
||||
ActorOrder.BEHIND -> actorsRenderBehind.add(actor)
|
||||
ActorOrder.MIDDLE -> actorsRenderMiddle.add(actor)
|
||||
ActorOrder.MIDTOP -> actorsRenderMidTop.add(actor)
|
||||
ActorOrder.FRONT -> actorsRenderFront.add(actor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -668,9 +688,9 @@ constructor() : BasicGameState() {
|
||||
arr[j + 1] = x
|
||||
}
|
||||
|
||||
private fun ArrayList<Actor>.binarySearch(actor: Actor) = this.binarySearch(actor.referenceID)
|
||||
private fun ArrayList<out Actor>.binarySearch(actor: Actor) = this.binarySearch(actor.referenceID)
|
||||
|
||||
private fun ArrayList<Actor>.binarySearch(ID: Int): Int {
|
||||
private fun ArrayList<out Actor>.binarySearch(ID: Int): Int {
|
||||
// code from collections/Collections.kt
|
||||
var low = 0
|
||||
var high = actorContainer.size - 1
|
||||
|
||||
@@ -53,10 +53,10 @@ class StateMonitorCheck : BasicGameState() {
|
||||
|
||||
init {
|
||||
if (Terrarum.gameLocale.length >= 4 && Terrarum.gameLocale.contains(maru_alt))
|
||||
pictograms.add(Image("./assets/graphics/gui/monitor_good_alt_maru.png"))
|
||||
pictograms.add(Image("./assets/graphics/gui/monitor_good_alt_maru.tga"))
|
||||
else
|
||||
pictograms.add(Image("./assets/graphics/gui/monitor_good.png"))
|
||||
pictograms.add(Image("./assets/graphics/gui/monitor_bad.png"))
|
||||
pictograms.add(Image("./assets/graphics/gui/monitor_good.tga"))
|
||||
pictograms.add(Image("./assets/graphics/gui/monitor_bad.tga"))
|
||||
|
||||
imageGallery = ItemImageGallery(0, instructionY, Terrarum.WIDTH, anykeyY - instructionY, pictograms)
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ class StateSplash : BasicGameState() {
|
||||
// pre-load lang
|
||||
Lang["MENU_LANGUAGE_THIS"]
|
||||
|
||||
pictogramCollection.add(Image("./assets/graphics/gui/health_take_a_break.png"))
|
||||
pictogramCollection.add(Image("./assets/graphics/gui/health_distance.png"))
|
||||
pictogramCollection.add(Image("./assets/graphics/gui/health_take_a_break.tga"))
|
||||
pictogramCollection.add(Image("./assets/graphics/gui/health_distance.tga"))
|
||||
|
||||
fadeSheet = Image(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||
thisG = fadeSheet.graphics
|
||||
|
||||
@@ -82,8 +82,8 @@ internal object ExportMap : ConsoleCommand {
|
||||
|
||||
try {
|
||||
RasterWriter.writePNG_RGB(
|
||||
Terrarum.ingame.world.width, Terrarum.ingame.world.height, mapData, dir + args[1] + ".png")
|
||||
Echo("ExportMap: exported to " + args[1] + ".png")
|
||||
Terrarum.ingame.world.width, Terrarum.ingame.world.height, mapData, dir + args[1] + ".tga")
|
||||
Echo("ExportMap: exported to " + args[1] + ".tga")
|
||||
|
||||
}
|
||||
catch (e: IOException) {
|
||||
|
||||
@@ -192,7 +192,9 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
sb.append("$key = $value ($type)\n")
|
||||
}
|
||||
|
||||
sb.deleteCharAt(sb.length - 1) // delete trailing \n
|
||||
if (sb.isNotEmpty()) {
|
||||
sb.deleteCharAt(sb.length - 1) // delete trailing \n
|
||||
}
|
||||
|
||||
avInfoArea.text = "$sb"
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import org.newdawn.slick.GameContainer
|
||||
|
||||
/**
|
||||
* @param renderOrder invisible/technical -> ActorOrder.MIDDLE
|
||||
*
|
||||
* Created by minjaesong on 15-12-31.
|
||||
*/
|
||||
abstract class Actor : Comparable<Actor>, Runnable {
|
||||
abstract class Actor(val renderOrder: ActorOrder) : Comparable<Actor>, Runnable {
|
||||
|
||||
abstract fun update(gc: GameContainer, delta: Int)
|
||||
|
||||
@@ -37,10 +39,29 @@ abstract class Actor : Comparable<Actor>, Runnable {
|
||||
* override var referenceID: Int = generateUniqueReferenceID()
|
||||
*/
|
||||
fun generateUniqueReferenceID(): Int {
|
||||
fun checkForCollision(value: Int) =
|
||||
Terrarum.ingame.hasActor(value) ||
|
||||
value < ItemCodex.ITEM_COUNT_MAX ||
|
||||
value < when (renderOrder) {
|
||||
ActorOrder.BEHIND -> ItemCodex.ITEM_COUNT_MAX
|
||||
ActorOrder.MIDDLE -> 0x10000000
|
||||
ActorOrder.MIDTOP -> 0x60000000
|
||||
ActorOrder.FRONT -> 0x70000000
|
||||
} ||
|
||||
value > when (renderOrder) {
|
||||
ActorOrder.BEHIND -> 0x0FFFFFFF
|
||||
ActorOrder.MIDDLE -> 0x5FFFFFFF
|
||||
ActorOrder.MIDTOP -> 0x6FFFFFFF
|
||||
ActorOrder.FRONT -> 0x7FFFFFFF
|
||||
}
|
||||
|
||||
var ret: Int
|
||||
do {
|
||||
ret = HQRNG().nextInt().and(0x7FFFFFFF) // set new ID
|
||||
} while (Terrarum.ingame.hasActor(ret) || ret < ItemCodex.ITEM_COUNT_MAX) // check for collision
|
||||
} while (checkForCollision(ret)) // check for collision
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum class ActorOrder { BEHIND, MIDDLE, MIDTOP, FRONT }
|
||||
@@ -21,7 +21,7 @@ import java.util.*
|
||||
*
|
||||
* Created by minjaesong on 16-01-13.
|
||||
*/
|
||||
open class ActorWithBody : Actor() {
|
||||
open class ActorWithBody(renderOrder: ActorOrder) : Actor(renderOrder) {
|
||||
|
||||
|
||||
/** !! ActorValue macros are on the very bottom of the source !! **/
|
||||
@@ -32,8 +32,6 @@ open class ActorWithBody : Actor() {
|
||||
@Transient internal var spriteGlow: SpriteAnimation? = null
|
||||
|
||||
var drawMode = BLEND_NORMAL
|
||||
/** for fake tiles. Draw on top of player(s) */
|
||||
var drawTopmost = false
|
||||
|
||||
@Transient private val world: GameWorld = Terrarum.ingame.world
|
||||
|
||||
@@ -909,7 +907,7 @@ open class ActorWithBody : Actor() {
|
||||
|
||||
private fun updateHitbox() = hitbox.reassign(nextHitbox)
|
||||
|
||||
open fun drawGlow(gc: GameContainer, g: Graphics) {
|
||||
open fun drawGlow(g: Graphics) {
|
||||
if (isVisible && spriteGlow != null) {
|
||||
blendLightenOnly()
|
||||
|
||||
@@ -952,7 +950,7 @@ open class ActorWithBody : Actor() {
|
||||
}
|
||||
}
|
||||
|
||||
open fun drawBody(gc: GameContainer, g: Graphics) {
|
||||
open fun drawBody(g: Graphics) {
|
||||
if (isVisible && sprite != null) {
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ object CreatureBuilder {
|
||||
*/
|
||||
@Throws(IOException::class, SlickException::class)
|
||||
operator fun invoke(jsonFileName: String): ActorWithBody {
|
||||
val actor = ActorWithBody()
|
||||
val actor = ActorWithBody(ActorOrder.MIDDLE)
|
||||
InjectCreatureRaw(actor.actorValue, jsonFileName)
|
||||
|
||||
return actor
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.newdawn.slick.Graphics
|
||||
/**
|
||||
* Created by minjaesong on 16-03-15.
|
||||
*/
|
||||
class DroppedItem(private val item: InventoryItem) : ActorWithBody() {
|
||||
class DroppedItem(private val item: InventoryItem) : ActorWithBody(ActorOrder.MIDTOP) {
|
||||
|
||||
init {
|
||||
if (item.id >= ItemCodex.ITEM_COUNT_MAX)
|
||||
@@ -29,7 +29,7 @@ class DroppedItem(private val item: InventoryItem) : ActorWithBody() {
|
||||
item.effectWhenEquipped(gc, delta)
|
||||
}
|
||||
|
||||
override fun drawBody(gc: GameContainer, g: Graphics) {
|
||||
override fun drawBody(g: Graphics) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import net.torvald.spriteanimation.SpriteAnimation
|
||||
/**
|
||||
* Created by minjaesong on 16-06-17.
|
||||
*/
|
||||
open class FixtureBase : ActorWithBody() {
|
||||
open class FixtureBase : ActorWithBody(ActorOrder.BEHIND) {
|
||||
/**
|
||||
* 0: Open
|
||||
* 1: Blocked
|
||||
|
||||
@@ -26,7 +26,7 @@ class FixtureTikiTorch : FixtureBase(), Luminous {
|
||||
lightBoxList.add(Hitbox(3.0, 0.0, 4.0, 3.0))
|
||||
|
||||
makeNewSprite(10, 27)
|
||||
sprite!!.setSpriteImage("assets/graphics/sprites/fixtures/tiki_torch.png")
|
||||
sprite!!.setSpriteImage("assets/graphics/sprites/fixtures/tiki_torch.tga")
|
||||
sprite!!.setDelay(200)
|
||||
sprite!!.setRowsAndFrames(1, 1)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.newdawn.slick.Input
|
||||
*
|
||||
* Created by minjaesong on 16-10-10.
|
||||
*/
|
||||
open class HistoricalFigure(val born: GameDate, val dead: GameDate? = null) : ActorWithBody() {
|
||||
open class HistoricalFigure(val born: GameDate, val dead: GameDate? = null) : ActorWithBody(ActorOrder.MIDDLE) {
|
||||
|
||||
init {
|
||||
this.actorValue["_bornyear"] = born.year
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.newdawn.slick.Graphics
|
||||
/**
|
||||
* Created by minjaesong on 16-03-05.
|
||||
*/
|
||||
class PhysTestBall : ActorWithBody() {
|
||||
class PhysTestBall : ActorWithBody(ActorOrder.MIDDLE) {
|
||||
|
||||
private var color = Color.orange
|
||||
|
||||
@@ -22,7 +22,7 @@ class PhysTestBall : ActorWithBody() {
|
||||
color = RoguelikeRandomiser.composeColourFrom(RoguelikeRandomiser.POTION_PRIMARY_COLSET)
|
||||
}
|
||||
|
||||
override fun drawBody(gc: GameContainer, g: Graphics) {
|
||||
override fun drawBody(g: Graphics) {
|
||||
g.color = color
|
||||
g.fillOval(
|
||||
hitbox.posX.toFloat(),
|
||||
|
||||
@@ -20,7 +20,7 @@ object PlayerBuilderCynthia {
|
||||
|
||||
|
||||
p.makeNewSprite(26, 42)
|
||||
p.sprite!!.setSpriteImage("assets/graphics/sprites/test_player_2.png")
|
||||
p.sprite!!.setSpriteImage("assets/graphics/sprites/test_player_2.tga")
|
||||
p.sprite!!.setDelay(200)
|
||||
p.sprite!!.setRowsAndFrames(1, 1)
|
||||
|
||||
@@ -31,7 +31,7 @@ object PlayerBuilderCynthia {
|
||||
|
||||
|
||||
|
||||
p.referenceID = 12345678
|
||||
p.referenceID = 321321321
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -27,12 +27,12 @@ object PlayerBuilderSigrid {
|
||||
p.referenceID = 0x51621D // the only constant of this procedural universe
|
||||
|
||||
p.makeNewSprite(28, 51)
|
||||
p.sprite!!.setSpriteImage("assets/graphics/sprites/test_player.png")
|
||||
p.sprite!!.setSpriteImage("assets/graphics/sprites/test_player.tga")
|
||||
p.sprite!!.setDelay(200)
|
||||
p.sprite!!.setRowsAndFrames(1, 1)
|
||||
|
||||
p.makeNewSpriteGlow(28, 51)
|
||||
p.spriteGlow!!.setSpriteImage("assets/graphics/sprites/test_player_glow.png")
|
||||
p.spriteGlow!!.setSpriteImage("assets/graphics/sprites/test_player_glow.tga")
|
||||
p.spriteGlow!!.setDelay(200)
|
||||
p.spriteGlow!!.setRowsAndFrames(1, 1)
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ open class ProjectileSimple(
|
||||
private val type: Int,
|
||||
fromPoint: Vector2, // projected coord
|
||||
toPoint: Vector2 // arriving coord
|
||||
) : ActorWithBody(), Luminous, Projectile {
|
||||
) : ActorWithBody(ActorOrder.MIDTOP), Luminous, Projectile {
|
||||
|
||||
val damage: Int
|
||||
val displayColour: Color
|
||||
@@ -76,7 +76,7 @@ open class ProjectileSimple(
|
||||
super.update(gc, delta)
|
||||
}
|
||||
|
||||
override fun drawBody(gc: GameContainer, g: Graphics) {
|
||||
override fun drawBody(g: Graphics) {
|
||||
val colourTail = displayColour.darker(0f) // clone a colour
|
||||
colourTail.a = 0.16f
|
||||
|
||||
@@ -92,7 +92,7 @@ open class ProjectileSimple(
|
||||
)
|
||||
}
|
||||
|
||||
override fun drawGlow(gc: GameContainer, g: Graphics) = drawBody(gc, g)
|
||||
override fun drawGlow(g: Graphics) = drawBody(g)
|
||||
|
||||
companion object {
|
||||
val OFFSET_DAMAGE = 0
|
||||
|
||||
@@ -24,8 +24,8 @@ class TapestryObject(val image: Image, val artName: String, val artAuthor: Strin
|
||||
super.update(gc, delta)
|
||||
}
|
||||
|
||||
override fun drawBody(gc: GameContainer, g: Graphics) {
|
||||
super.drawBody(gc, g)
|
||||
override fun drawBody(g: Graphics) {
|
||||
super.drawBody(g)
|
||||
}
|
||||
|
||||
override fun updateBodySprite(gc: GameContainer, delta: Int) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.gameactors
|
||||
/**
|
||||
* Created by minjaesong on 16-04-26.
|
||||
*/
|
||||
class WeaponSwung(val itemID: Int) : ActorWithBody(), Luminous {
|
||||
class WeaponSwung(val itemID: Int) : ActorWithBody(ActorOrder.MIDTOP), Luminous {
|
||||
// just let the solver use AABB; it's cheap but works just enough
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,7 @@ object TilesDrawer {
|
||||
|
||||
var tilesTerrain: SpriteSheet = SpriteSheet("./assets/graphics/terrain/terrain.tga", TILE_SIZE, TILE_SIZE)
|
||||
private set // Slick has some weird quirks with PNG's transparency. I'm using 32-bit targa here.
|
||||
var tilesWire: SpriteSheet = SpriteSheet("./assets/graphics/terrain/wire.png", TILE_SIZE, TILE_SIZE)
|
||||
var tilesWire: SpriteSheet = SpriteSheet("./assets/graphics/terrain/wire.tga", TILE_SIZE, TILE_SIZE)
|
||||
private set
|
||||
|
||||
val WALL = GameWorld.WALL
|
||||
@@ -228,7 +228,7 @@ object TilesDrawer {
|
||||
|
||||
val wallOverlayColour = Color(2f/3f, 2f/3f, 2f/3f, 1f)
|
||||
|
||||
fun renderBehind(gc: GameContainer, g: Graphics) {
|
||||
fun renderWall(g: Graphics) {
|
||||
/**
|
||||
* render to camera
|
||||
*/
|
||||
@@ -236,7 +236,7 @@ object TilesDrawer {
|
||||
|
||||
tilesTerrain.startUse()
|
||||
drawTiles(g, WALL, false)
|
||||
tilesTerrain.endUse() // you absolutely need this
|
||||
tilesTerrain.endUse()
|
||||
|
||||
blendMul()
|
||||
|
||||
@@ -246,17 +246,27 @@ object TilesDrawer {
|
||||
)
|
||||
|
||||
blendNormal()
|
||||
}
|
||||
|
||||
tilesTerrain.startUse() // you absolutely need this
|
||||
drawTiles(g, TERRAIN, false)
|
||||
fun renderTerrain(g: Graphics) {
|
||||
/**
|
||||
* render to camera
|
||||
*/
|
||||
blendNormal()
|
||||
|
||||
tilesTerrain.startUse()
|
||||
drawTiles(g, TERRAIN, false) // regular tiles
|
||||
tilesTerrain.endUse()
|
||||
}
|
||||
|
||||
fun renderFront(gc: GameContainer, g: Graphics, drawWires: Boolean) {
|
||||
fun renderFront(g: Graphics, drawWires: Boolean) {
|
||||
/**
|
||||
* render to camera
|
||||
*/
|
||||
blendMul()
|
||||
|
||||
tilesTerrain.startUse()
|
||||
drawTiles(g, TERRAIN, true)
|
||||
drawTiles(g, TERRAIN, true) // blendmul tiles
|
||||
tilesTerrain.endUse()
|
||||
|
||||
if (drawWires) {
|
||||
|
||||
@@ -20,11 +20,11 @@ object ItemSlotImageBuilder {
|
||||
private val colourWhite = Color(0xC0, 0xC0, 0xC0, 0xEE)
|
||||
|
||||
private val numberFont = SpriteSheetFont(
|
||||
SpriteSheet("./assets/graphics/fonts/numeric_small.png", 5, 8),
|
||||
SpriteSheet("./assets/graphics/fonts/numeric_small.tga", 5, 8),
|
||||
'0'
|
||||
)
|
||||
val slotImage = Image("./assets/graphics/gui/quickbar/item_slot.png") // must have same w/h as slotLarge
|
||||
val slotLarge = Image("./assets/graphics/gui/quickbar/item_slot_large.png")
|
||||
val slotImage = Image("./assets/graphics/gui/quickbar/item_slot.tga") // must have same w/h as slotLarge
|
||||
val slotLarge = Image("./assets/graphics/gui/quickbar/item_slot_large.tga")
|
||||
private val canvas = Image(slotImage.width, slotImage.height)
|
||||
private val canvasLarge = Image(slotLarge.width, slotLarge.height)
|
||||
|
||||
|
||||
@@ -121,10 +121,8 @@ constructor(val UI: UICanvas) {
|
||||
|
||||
UI.render(gc, UIGraphicInstance)
|
||||
|
||||
ingameGraphics.drawImage(UIDrawnCanvas.getScaledCopy(scale),
|
||||
posX.toFloat() - (UI.width / 2f * scale.minus(1)),
|
||||
posY.toFloat() - (UI.height / 2f * scale.minus(1)),
|
||||
Color(1f, 1f, 1f, opacity)
|
||||
ingameGraphics.drawImage(
|
||||
UIDrawnCanvas, posX.toFloat(), posY.toFloat(), Color(1f, 1f, 1f, opacity)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,9 +86,9 @@ open class SimpleTextTerminal(
|
||||
|
||||
open protected val fontRef =
|
||||
"./assets/graphics/fonts/${
|
||||
if (hires) "milky.png"
|
||||
else if (phosphor == GREEN || phosphor == AMBER) "MDA.png"
|
||||
else "milkymda.png"
|
||||
if (hires) "milky.tga"
|
||||
else if (phosphor == GREEN || phosphor == AMBER) "MDA.tga"
|
||||
else "milkymda.tga"
|
||||
}"
|
||||
open protected val fontImg = Image(fontRef)
|
||||
open val fontW = fontImg.width / 16
|
||||
|
||||
@@ -192,7 +192,7 @@ class TeletypeTerminal : Teletype {
|
||||
private val mappingTable = HashMap<Int, Int>()
|
||||
|
||||
init {
|
||||
fontSheet = SpriteSheet("./assets/graphics/fonts/teletype_9x12.png", W, H)
|
||||
fontSheet = SpriteSheet("./assets/graphics/fonts/teletype_9x12.tga", W, H)
|
||||
chars.forEachIndexed { i, c -> mappingTable[c.toInt()] = i }
|
||||
}
|
||||
|
||||
|
||||
@@ -147,14 +147,14 @@ object WeatherMixer {
|
||||
fun readFromJson(path: String): BaseModularWeather {
|
||||
/* JSON structure:
|
||||
{
|
||||
"globalLight": "colourmap/sky_colour.png", // integer for static, string (path to image) for dynamic
|
||||
"skyboxGradColourMap": "colourmap/sky_colour.png", // integer for static, string (path to image) for dynamic
|
||||
"globalLight": "colourmap/sky_colour.tga", // integer for static, string (path to image) for dynamic
|
||||
"skyboxGradColourMap": "colourmap/sky_colour.tga", // integer for static, string (path to image) for dynamic
|
||||
"extraImages": [
|
||||
// if any, it will be like:
|
||||
sun01.png,
|
||||
clouds01.png,
|
||||
clouds02.png,
|
||||
auroraBlueViolet.png
|
||||
sun01.tga,
|
||||
clouds01.tga,
|
||||
clouds02.tga,
|
||||
auroraBlueViolet.tga
|
||||
]
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user