newfontsystem branch init commit

Former-commit-id: 5f03cdbec6058f90ef1354db5ee1c6dac9755feb
Former-commit-id: f132b6c4e1a51146fb7522686e24008640e88c45
This commit is contained in:
Song Minjae
2017-02-11 16:45:47 +09:00
parent 880d1b7692
commit 71f2aa0e53
15 changed files with 231 additions and 117 deletions

View File

@@ -1,14 +1,15 @@
package net.torvald.imagefont
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.getPixel
import org.lwjgl.opengl.GL11
import org.newdawn.slick.*
import java.util.*
/**
* Created by minjaesong on 16-01-27.
*/
open class GameFontBase @Throws(SlickException::class)
constructor() : Font {
open class GameFontBase : Font {
private fun getHan(hanIndex: Int): IntArray {
val han_x = hanIndex % JONG_COUNT
@@ -54,7 +55,6 @@ constructor() : Font {
}
private fun isAsciiEF(c: Char) = asciiEFList.contains(c)
private fun isExtAEF(c: Char) = extAEFList.contains(c)
private fun isHangul(c: Char) = c.toInt() >= 0xAC00 && c.toInt() < 0xD7A4
private fun isAscii(c: Char) = c.toInt() > 0x20 && c.toInt() <= 0xFF
@@ -143,7 +143,6 @@ constructor() : Font {
private fun keycapIndexY(c: Char) = (c.toInt() - 0xE000) / 16
private val narrowWidthSheets = arrayOf(
SHEET_ASCII_EF,
SHEET_EXTA_EF,
SHEET_CYRILIC_EF,
SHEET_GREEK_EF,
@@ -165,6 +164,7 @@ constructor() : Font {
private fun getWidthSubstr(s: String, endIndex: Int): Int {
var len = 0
for (i in 0..endIndex - 1) {
val chr = s[i]
val ctype = getSheetType(s[i])
/*if (i > 0 && s[i].toInt() > 0x20) {
@@ -183,7 +183,11 @@ constructor() : Font {
}*/
if (zeroWidthSheets.contains(ctype))
if (chr.toInt() == 0x21B) // HAX!
len += 6
else if (ctype == SHEET_ASCII_VARW) // HAX!
len += asciiWidths[chr.toInt()]!!
else if (zeroWidthSheets.contains(ctype))
len += 0
else if (narrowWidthSheets.contains(ctype))
len += W_LATIN_NARROW
@@ -381,10 +385,6 @@ constructor() : Font {
val sheetX: Int
val sheetY: Int
when (prevInstance) {
SHEET_ASCII_EF -> {
sheetX = asciiEFindexX(ch)
sheetY = asciiEFindexY(ch)
}
SHEET_EXTA_EF -> {
sheetX = extAEFindexX(ch)
sheetY = extAEFindexY(ch)
@@ -492,9 +492,7 @@ constructor() : Font {
private fun getSheetType(c: Char): Int {
// EFs
if (isAsciiEF(c))
return SHEET_ASCII_EF
else if (isExtAEF(c))
if (isExtAEF(c))
return SHEET_EXTA_EF
else if (isCyrilicEF(c))
return SHEET_CYRILIC_EF
@@ -513,7 +511,7 @@ constructor() : Font {
else if (isUniHan(c))
return SHEET_UNIHAN
else if (isAscii(c))
return SHEET_ASCII_EM
return SHEET_ASCII_VARW
else if (isExtA(c))
return SHEET_EXTA_EM
else if (isCyrilic(c))
@@ -535,7 +533,7 @@ constructor() : Font {
else if (isKeycap(c))
return SHEET_KEYCAP
else
return SHEET_ASCII_EM// fixed width punctuations
return SHEET_UNKNOWN// fixed width punctuations
// fixed width
// fallback
}
@@ -574,11 +572,45 @@ constructor() : Font {
fun Char.isColourCode() = colourKey.containsKey(this)
/**
* Assumes spritesheet to has 16x16 cells
*/
fun buildAsciiWidthTable() {
val binaryCodeOffset = 16
val cellW = asciiSheet.getSubImage(0, 0).width // should be 16
val cellH = asciiSheet.getSubImage(0, 0).height // should be 20
asciiWidths = HashMap()
// control chars
for (ccode in 0..255) {
val glyphX = ccode % 16
val glyphY = ccode / 16
val codeStartX = (glyphX * cellW) + binaryCodeOffset
val codeStartY = (glyphY * cellH)
var glyphWidth = 0
for (downCtr in 0..3) {
// if alpha is not zero, assume it's 1
if (asciiSheet.texture.getPixel(codeStartX, codeStartY + downCtr)[3] != 0) {
glyphWidth = glyphWidth or (1 shl downCtr)
}
}
println("Char $ccode, width: $glyphWidth")
asciiWidths[ccode] = glyphWidth
}
}
companion object {
lateinit internal var hangulSheet: SpriteSheet
lateinit internal var asciiSheet: SpriteSheet
lateinit internal var asciiSheetEF: SpriteSheet
lateinit internal var asciiWidths: HashMap<Int, Int>
lateinit internal var runicSheet: SpriteSheet
lateinit internal var extASheet: SpriteSheet
lateinit internal var extASheetEF: SpriteSheet
@@ -607,6 +639,7 @@ constructor() : Font {
internal val W_UNIHAN = 16
internal val W_LATIN_WIDE = 9 // width of regular letters, including m
internal val W_LATIN_NARROW = 5 // width of letter f, t, i, l
internal val W_FLAG_VARIABLE: Int = -0x4E0E // neue
internal val H = 20
internal val H_HANGUL = 16
@@ -615,8 +648,7 @@ constructor() : Font {
internal val SIZE_KEYCAP = 18
internal val SHEET_ASCII_EM = 0
internal val SHEET_ASCII_EF = 1
internal val SHEET_ASCII_VARW = 0
internal val SHEET_HANGUL = 2
internal val SHEET_RUNIC = 3
internal val SHEET_EXTA_EM = 4
@@ -637,6 +669,8 @@ constructor() : Font {
internal val SHEET_THAI_EM = 19
internal val SHEET_THAI_EF = 20
internal val SHEET_KEYCAP = 21
internal val SHEET_UNKNOWN = 254
internal val SHEET_COLOURCODE = 255
lateinit internal var sheetKey: Array<SpriteSheet?>
@@ -738,7 +772,6 @@ constructor() : Font {
Pair("x", colourKey[0x1A.toChar()]),
Pair("k", colourKey[0x1B.toChar()])
)
}// end of companion object
}

View File

@@ -12,9 +12,7 @@ class GameFontWhite : GameFontBase() {
GameFontBase.hangulSheet = SpriteSheet(
"./assets/graphics/fonts/hangul_johab.tga", GameFontBase.W_HANGUL, GameFontBase.H_HANGUL)
GameFontBase.asciiSheet = SpriteSheet(
"./assets/graphics/fonts/ascii_fullwidth.tga", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
GameFontBase.asciiSheetEF = SpriteSheet(
"./assets/graphics/fonts/ascii_special_ef.tga", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
"./assets/graphics/fonts/ascii_variable.tga", 16, 20)
GameFontBase.runicSheet = SpriteSheet(
"./assets/graphics/fonts/futhark.tga", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
GameFontBase.extASheet = SpriteSheet(
@@ -59,7 +57,7 @@ class GameFontWhite : GameFontBase() {
val shk = arrayOf(
GameFontBase.asciiSheet,
GameFontBase.asciiSheetEF,
null,
GameFontBase.hangulSheet,
GameFontBase.runicSheet,
GameFontBase.extASheet,
@@ -82,5 +80,8 @@ class GameFontWhite : GameFontBase() {
GameFontBase.keycapSheet
)
GameFontBase.sheetKey = shk
buildAsciiWidthTable()
}
}

View File

@@ -14,13 +14,15 @@ import org.newdawn.slick.SpriteSheet
class SpriteAnimation(val parentActor: ActorWithSprite, val cellWidth: Int, val cellHeight: Int) {
private var spriteImage: SpriteSheet? = null
private var currentFrame = 1 // one-based!
private var currentRow = 1 // one-based!
private var nFrames: Int = 1
private var nRows: Int = 1
private var delay = 200
var currentFrame = 0
var currentRow = 0
var nFrames: Int = 1
private set
var nRows: Int = 1
private set
var delay = 200
private var delta = 0
private val looping = true
val looping = true
private var animationRunning = true
private var flipHorizontal = false
private var flipVertical = false
@@ -48,24 +50,16 @@ class SpriteAnimation(val parentActor: ActorWithSprite, val cellWidth: Int, val
spriteImage = SpriteSheet(image, cellWidth, cellHeight)
}
/**
* Sets animation delay. Will default to 200 if not called.
* @param delay in milliseconds
*/
fun setDelay(delay: Int) {
this.delay = delay
}
/**
* Sets sheet rows and animation frames. Will default to
* 1, 1 (still image of top left from the sheet) if not called.
* @param rows
* @param nRows
* *
* @param frames
* @param nFrames
*/
fun setRowsAndFrames(rows: Int, frames: Int) {
nRows = rows
nFrames = frames
fun setRowsAndFrames(nRows: Int, nFrames: Int) {
this.nRows = nRows
this.nFrames = nFrames
}
fun update(delta: Int) {
@@ -81,7 +75,7 @@ class SpriteAnimation(val parentActor: ActorWithSprite, val cellWidth: Int, val
}
//advance one frame, then reset delta counter
this.currentFrame = this.currentFrame % this.nFrames + 1
this.currentFrame = this.currentFrame % this.nFrames
this.delta = 0
}
}
@@ -125,8 +119,8 @@ class SpriteAnimation(val parentActor: ActorWithSprite, val cellWidth: Int, val
}
}
fun switchSprite(newRow: Int) {
currentRow = newRow
fun switchRow(newRow: Int) {
currentRow = newRow % nRows
//if beyond the frame index then reset
if (currentFrame > nFrames) {
@@ -134,39 +128,12 @@ class SpriteAnimation(val parentActor: ActorWithSprite, val cellWidth: Int, val
}
}
fun switchSprite(newRow: Int, newMax: Int) {
if (newMax > 0) {
nFrames = newMax
}
currentRow = newRow
//if beyond the frame index then reset
if (currentFrame > nFrames) {
reset()
}
}
fun switchSpriteDelay(newDelay: Int) {
fun setSpriteDelay(newDelay: Int) {
if (newDelay > 0) {
delay = newDelay
}
}
fun switchSprite(newRow: Int, newMax: Int, newDelay: Int) {
if (newMax > 0) {
nFrames = newMax
}
if (newDelay > 0) {
delay = newDelay
}
currentRow = newRow
//if beyond the frame index then reset
if (currentFrame > nFrames) {
reset()
else {
throw IllegalArgumentException("Delay equal or less than zero")
}
}
@@ -211,7 +178,7 @@ class SpriteAnimation(val parentActor: ActorWithSprite, val cellWidth: Int, val
}
private fun getScaledSprite(scale: Float): Image {
val selectedImage = spriteImage!!.getSprite(currentFrame - 1, currentRow - 1)
val selectedImage = spriteImage!!.getSprite(currentFrame, currentRow)
selectedImage.filter = Image.FILTER_NEAREST
return selectedImage.getScaledCopy(scale)
}

View File

@@ -10,7 +10,15 @@ import org.newdawn.slick.state.StateBasedGame
* Created by minjaesong on 16-06-28.
*/
class StateFontTester : BasicGameState() {
val textToPrint = "Font printer 서체 인쇄기"
val textToPrint = """
ABCDEFGHIJKLM
NOPQRSTUVWXYZ
abcdefghijklm
nopqrstuvwxyz
1234567890
"""
lateinit var canvas: Graphics
@@ -58,11 +66,72 @@ class StateFontTester : BasicGameState() {
//g.font = Terrarum.fontSmallNumbers
//g.font = segfont
g.font = mtfont
//g.font = mtfont
g.font = Terrarum.fontGame
val line = " **** TERRAN BASIC V0.5 **** "
g.drawString(line, 10f, 10f)
g.drawString("ABCDEFGHIJKLM", 10f, 10f)
g.drawString("NOPQRSTÜVWXYZ", 10f, 30f)
g.drawString("abcdefghijklmno", 160f, 10f)
g.drawString("pqrstuvwxyzߜ", 160f, 30f)
g.drawString("1234567890", 320f, 10f)
g.drawString("minimum kerning keming Nannu Namu", 320f, 30f)
g.drawString("Syö salmiakkia perkele", 480f, 10f)
val text = arrayOf(
"Kedok Ketawa (The Laughing Mask) is a 1940 action film from the Dutch East Indies, in",
"present-day Indonesia. After a young couple falls in love, the title character, a",
"vigilante, helps them fight off criminals who have been sent to kidnap the woman by a",
"rich man who wants her as his wife. It was the first film of Union Films, one of four",
"new production houses established after the country's ailing film industry was revived",
"by the success of Albert Balink's Terang Boelan. Kedok Ketawa was directed by Jo An",
"Djan and stars Basoeki Resobowo, Fatimah, Oedjang (as the vigilante), S Poniman and",
"Eddy Kock. Featuring fighting, comedy, and singing, and advertised as an \"Indonesian",
"cocktail of violent actions ... and sweet romance\", the film received positive",
"reviews, particularly for its cinematography. Following the success of the film, Union",
"produced another six before being shut down in early 1942 during the Japanese",
"occupation. Screened until at least August 1944, the film may be lost."
)
text.forEachIndexed { i, s ->
g.drawString(s, 10f, 70f + 20 * i)
}
/*g.drawString("The Olympic marmot (Marmota olympus) is a rodent in the squirrel family, Sciuridae.", 10f, 70f)
g.drawString("It lives only in the U.S. state of Washington, at middle elevations on the Olympic Peninsula.", 10f, 90f)
g.drawString("About the size of a domestic cat, an adult weighs around 8 kg (18 lb) in summer.", 10f, 110f)
g.drawString("Brná je část statutárního a krajského města Ústí nad Labem v České republice, spadající", 10f, 150f)
g.drawString("pod městský obvod Ústí nad Labem-Střekov. Nachází se asi pět kilometrů jižně od centra", 10f, 170f)
g.drawString("města v Českém středohoří na pravém břehu řeky Labe.", 10f, 190f)
g.drawString("Malaysia er en forholdsvis ung stat. Sin endelige udstrækning fik den først i 1965 efter,", 10f, 230f)
g.drawString("at Singapore trak sig ud. Staten blev grundlagt ved en sammenslutning af flere tidligere", 10f, 250f)
g.drawString("britiske besiddelser, foreløbigt i 1957 og endeligt i 1963.", 10f, 270f)
g.drawString("Ο Αρθούρος Ρεμπώ ήταν Γάλλος ποιητής. Θεωρείται ένας από τους μείζονες εκπροσώπους του", 10f, 310f)
g.drawString("συμβολισμού, με σημαντική επίδραση στη μοντέρνα ποίηση, παρά το γεγονός πως εγκατέλειψε", 10f, 330f)
g.drawString("οριστικά τη λογοτεχνία στην ηλικία των είκοσι ετών.", 10f, 350f)
g.drawString("Discografia Siei se compune din șase albume de studio, șase albume live, treizeci și", 10f, 390f)
g.drawString("patru discuri single (inclusiv unsprezece ca și artist secundar), și cincisprezece", 10f, 410f)
g.drawString("videoclipuri. Până în octombrie 2014, a vândut 25 de milioane de cântece în întreaga lume.", 10f, 430f)
g.drawString("Квинт Серторий — римский политический деятель и военачальник, известный в первую очередь", 10f, 470f)
g.drawString("как руководитель мятежа против сулланского режима в Испании в 80—72 годах до н. э. Квинт", 10f, 490f)
g.drawString("Серторий принадлежал к италийской муниципальной аристократии.", 10f, 510f)
g.drawString("Málið snerist um ofbeldi lögregluþjóna gegn fjölskyldu blökkumanna, en afar sjaldgæft var", 10f, 550f)
g.drawString("á þessum árum að slík mál kæmu fyrir æðstu dómstig. Fordæmið tryggði framgang sambærilegra", 10f, 570f)
g.drawString("mála sem einkenndust af því að opinberir aðilar virtu ekki stjórnarskrárvarin réttindi einstaklingsins.", 10f, 590f)
*/
}
override fun getID(): Int = Terrarum.STATE_ID_TEST_FONT

View File

@@ -130,7 +130,8 @@ class StateInGame : BasicGameState() {
// add new player and put it to actorContainer
playableActorDelegate = PlayableActorDelegate(PlayerBuilderSigrid())
//playableActorDelegate = PlayableActorDelegate(PlayerBuilderSigrid())
playableActorDelegate = PlayableActorDelegate(PlayerBuilderTestSubject1())
addNewActor(player)

View File

@@ -11,6 +11,7 @@ import net.torvald.terrarum.gameworld.toUint
import org.lwjgl.input.Controllers
import org.lwjgl.opengl.*
import org.newdawn.slick.*
import org.newdawn.slick.opengl.Texture
import org.newdawn.slick.state.StateBasedGame
import java.io.File
import java.io.IOException
@@ -127,9 +128,9 @@ constructor(gamename: String) : StateBasedGame(gamename) {
//addState(StateVTTest())
//addState(StateTestingLightning())
addState(StateSplash())
//addState(StateSplash())
//addState(StateMonitorCheck())
//addState(StateFontTester())
addState(StateFontTester())
//addState(StateNoiseTexGen())
//addState(StateBlurTest())
//addState(StateShaderTest())
@@ -302,7 +303,7 @@ constructor(gamename: String) : StateBasedGame(gamename) {
}
catch (ex: SlickException) {
val logger = Logger.getLogger(Terrarum::class.java.name)
val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX")
val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH-mm-ss")
val calendar = Calendar.getInstance()
val filepath = "$defaultDir/crashlog-${dateFormat.format(calendar.time)}.txt"
val fileHandler = FileHandler(filepath)
@@ -312,7 +313,7 @@ constructor(gamename: String) : StateBasedGame(gamename) {
fileHandler.formatter = formatter
//logger.info()
println("The game has been crashed!")
println("The game has crashed!")
println("Crash log were saved to $filepath.")
println("================================================================================")
logger.log(Level.SEVERE, null, ex)
@@ -517,33 +518,35 @@ enum class RunningEnvironment {
}
/** @return Intarray(R, G, B, A) */
fun Image.getPixel(x: Int, y: Int): IntArray {
val textureWidth = this.texture.textureWidth
val hasAlpha = this.texture.hasAlpha()
fun Texture.getPixel(x: Int, y: Int): IntArray {
val textureWidth = this.textureWidth
val hasAlpha = this.hasAlpha()
val offset = (if (hasAlpha) 4 else 3) * (textureWidth * y + x) // 4: # of channels (RGBA)
if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
return intArrayOf(
this.texture.textureData[offset].toUint(),
this.texture.textureData[offset + 1].toUint(),
this.texture.textureData[offset + 2].toUint(),
this.textureData[offset].toUint(),
this.textureData[offset + 1].toUint(),
this.textureData[offset + 2].toUint(),
if (hasAlpha)
this.texture.textureData[offset + 3].toUint()
this.textureData[offset + 3].toUint()
else 255
)
}
else {
return intArrayOf(
this.texture.textureData[offset + 2].toUint(),
this.texture.textureData[offset + 1].toUint(),
this.texture.textureData[offset].toUint(),
this.textureData[offset + 2].toUint(),
this.textureData[offset + 1].toUint(),
this.textureData[offset].toUint(),
if (hasAlpha)
this.texture.textureData[offset + 3].toUint()
this.textureData[offset + 3].toUint()
else 255
)
}
}
/** @return Intarray(R, G, B, A) */
fun Image.getPixel(x: Int, y: Int) = this.texture.getPixel(x, y)
fun Color.toInt() = redByte.shl(16) or greenByte.shl(8) or blueByte
fun Color.to10bit() = redByte.shl(20) or greenByte.shl(10) or blueByte

View File

@@ -79,6 +79,9 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
@Transient internal const val WALK_ACCEL_BASE: Double = 0.67
@Transient const val BASE_HEIGHT = 40
@Transient const val SPRITE_ROW_IDLE = 0
@Transient const val SPRITE_ROW_WALK = 1
}
////////////////////////////////
@@ -499,12 +502,19 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
fun Float.abs() = FastMath.abs(this)
private fun updateSprite(delta: Int) {
sprite!!.update(delta)
if (spriteGlow != null) {
spriteGlow!!.update(delta)
}
if (sprite != null) sprite!!.update(delta)
if (spriteGlow != null) spriteGlow!!.update(delta)
println("$this\tsprite current frame: ${sprite!!.currentFrame}")
if (grounded) {
// set anim row
if (moveDelta.x != 0.0) {
if (sprite != null) sprite!!.switchRow(SPRITE_ROW_WALK)
if (spriteGlow != null) spriteGlow!!.switchRow(SPRITE_ROW_WALK)
}
// flipping the sprite
if (walkHeading == LEFT) {
sprite!!.flip(true, false)
if (spriteGlow != null) {
@@ -518,5 +528,9 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
}
}
}
else {
if (sprite != null) sprite!!.switchRow(SPRITE_ROW_IDLE)
if (spriteGlow != null) spriteGlow!!.switchRow(SPRITE_ROW_IDLE)
}
}
}

View File

@@ -342,6 +342,9 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
if (!assertPrinted) assertInit()
if (sprite != null) sprite!!.update(delta)
if (spriteGlow != null) spriteGlow!!.update(delta)
// make NoClip work for player
if (this is Player) {
isNoSubjectToGrav = isPlayerNoClip
@@ -569,7 +572,7 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
externalForce.x *= -elasticity
if (this is Controllable) walkX *= -elasticity
println("$this\t${externalForce.x}")
//println("$this\t${externalForce.x}")
}
private fun hitAndReflectY() {
@@ -1143,14 +1146,6 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
}
}
open fun updateGlowSprite(gc: GameContainer, delta: Int) {
if (spriteGlow != null) spriteGlow!!.update(delta)
}
open fun updateBodySprite(gc: GameContainer, delta: Int) {
if (sprite != null) sprite!!.update(delta)
}
private fun clampW(x: Double): Double =
if (x < TILE_SIZE + nextHitbox.width / 2) {
TILE_SIZE + nextHitbox.width / 2

View File

@@ -26,7 +26,7 @@ class FixtureTikiTorch : FixtureBase(), Luminous {
lightBoxList.add(Hitbox(3.0, 0.0, 4.0, 3.0))
makeNewSprite(10, 27, "assets/graphics/sprites/fixtures/tiki_torch.tga")
sprite!!.setDelay(200)
sprite!!.delay = 200
sprite!!.setRowsAndFrames(1, 1)
actorValue[AVKey.BASEMASS] = 1.0

View File

@@ -23,7 +23,7 @@ object PlayerBuilderCynthia {
p.makeNewSprite(26, 42, "assets/graphics/sprites/test_player_2.tga")
p.sprite!!.setDelay(200)
p.sprite!!.delay = 200
p.sprite!!.setRowsAndFrames(1, 1)
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 9, 0)

View File

@@ -27,11 +27,11 @@ object PlayerBuilderSigrid {
p.referenceID = 0x51621D // the only constant of this procedural universe
p.makeNewSprite(28, 51, "assets/graphics/sprites/test_player.tga")
p.sprite!!.setDelay(200)
p.sprite!!.delay = 200
p.sprite!!.setRowsAndFrames(1, 1)
p.makeNewSpriteGlow(28, 51, "assets/graphics/sprites/test_player_glow.tga")
p.spriteGlow!!.setDelay(200)
p.spriteGlow!!.delay = 200
p.spriteGlow!!.setRowsAndFrames(1, 1)
p.actorValue = ActorValue()

View File

@@ -0,0 +1,33 @@
package net.torvald.terrarum.gameactors
import net.torvald.terrarum.gameactors.ai.LuaAIWrapper
import net.torvald.terrarum.mapdrawer.FeaturesDrawer
/**
* Created by SKYHi14 on 2017-02-10.
*/
object PlayerBuilderTestSubject1 {
operator fun invoke(): Player {
val p: Player = Player(GameDate(100, 143)) // random value thrown
InjectCreatureRaw(p.actorValue, "CreatureHuman.json")
p.actorValue[AVKey.__PLAYER_QUICKBARSEL] = 0
p.actorValue[AVKey.NAME] = "Test Subject 1"
p.makeNewSprite(48, 52, "assets/graphics/sprites/npc_template_anim_prototype.tga")
p.sprite!!.delay = 200
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)
return p
}
}

View File

@@ -28,8 +28,4 @@ class TapestryObject(val image: Image, val artName: String, val artAuthor: Strin
override fun drawBody(g: Graphics) {
super.drawBody(g)
}
override fun updateBodySprite(gc: GameContainer, delta: Int) {
super.updateBodySprite(gc, delta)
}
}

View File

@@ -23,9 +23,9 @@ abstract class InventoryItem {
/**
* Where to equip the item
*/
var equipPosition: Int = EquipPosition.NULL
open var equipPosition: Int = EquipPosition.NULL
var material: Material? = null
open var material: Material? = null
/**
* Apparent mass of the item. (basemass * scale^3)

View File

@@ -41,6 +41,8 @@ object ItemCodex {
override var baseMass: Double = TileCodex[i].density / 1000.0
override var scale: Double = 1.0 // no need to set setter as scale would not change
override var baseToolSize: Double? = null
override var equipPosition = EquipPosition.HAND_GRIP
override fun primaryUse(gc: GameContainer, delta: Int) {
// TODO base punch attack