mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
newfontsystem branch init commit
Former-commit-id: 5f03cdbec6058f90ef1354db5ee1c6dac9755feb Former-commit-id: f132b6c4e1a51146fb7522686e24008640e88c45
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user