diff --git a/README.md b/README.md index 5fd96bb61..8afb8e8c1 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ ## Aperçu ## -This unnamed project is to create a side-view flatformer game, an attempt to create friendlier *Dwarf Fortress* adventurer mode, with more roguelike stuff such as perma-death and randomness and *lots of fun*. +This unnamed project is to create a side-view flatformer game, an attempt to create friendlier *Dwarf Fortress* adventurer mode, with more rogue-like stuff such as permanent death, randomness and *lots of fun*. -This project mainly uses Kotlin and Java, Python/Lua/etc. for tools. +This project mainly uses Kotlin and Python/Lua/etc. for tools. -Documentations and resources for work (such as .psd) are also included in the repo. You will need Mac computer to read and edit documentations in .gcx and .numbers. +Documentations and resources for work (such as .psd) are also included in the repository. You will need Mac computer to read and edit documentations in .gcx and .numbers format. Any contribution in this project must be made sorely in English, so be sure to use English in codes, comments, etc. @@ -32,7 +32,7 @@ Any contribution in this project must be made sorely in English, so be sure to u * Writing text You will need to fiddle with .csv files in ./res/locales * Languagus with apparent grammatical gender -Any gender discrimination should *not* exist in this game, so please choose vocabularies that is gender-neutral. If such behaviour is not possible in the target language, please use male gender. +Any gender discrimination should *not* exist in this game, so please choose vocabularies that is gender-neutral. If such behaviour is not possible in the target language, please use male gender, but try your best to avoid the situation. Note: Right-to-left languages (arabic, hebrew, etc.) are not supported. @@ -43,11 +43,27 @@ Note: Right-to-left languages (arabic, hebrew, etc.) are not supported. * Other community or team contact +## Tags ## + +* Rogue-like +* Adventure +* Procedural Generation +* Open World +* Sandbox +* Survival +* (Crafting) +* 2D +* Singleplayer +* Platformer +* (Atmospheric) +* Indie +* Pixel Graphics + ## 개요 ## 이 변변한 이름 없는 프로젝트는 사이드뷰 발판 게임 형식으로 더 친절한 〈드워프 포트리스〉의 모험가 모드를 지향하는 게임 제작 프로젝트입니다. 영구 사망, 무작위성, __넘쳐나는 재미__와 같이 ‘로그라이크’스러운 요소를 지닙니다. -이 프로젝트는 주 언어로 코틀린·자바를 사용하며 파이선·루아 등으로 작성된 툴을 이용합니다. +이 프로젝트는 주 언어로 코틀린을 사용하며 파이선·루아 등으로 작성된 툴을 이용합니다. 개발 문서와 작업용 리소스(psd 등) 또한 이 저장소에 포함되어 있습니다. gcx와 numbers 형식으로 된 문서를 읽고 수정하기 위해 맥 컴퓨터가 필요할 수 있습니다. diff --git a/src/net/torvald/terrarum/Game.kt b/src/net/torvald/terrarum/Game.kt index b9972fcd9..46576a438 100644 --- a/src/net/torvald/terrarum/Game.kt +++ b/src/net/torvald/terrarum/Game.kt @@ -3,6 +3,7 @@ package net.torvald.terrarum import net.torvald.imagefont.GameFontBase import net.torvald.terrarum.gameactors.* import net.torvald.terrarum.console.Authenticator +import net.torvald.terrarum.gameactors.collisionsolver.CollisionSolver import net.torvald.terrarum.gamecontroller.GameController import net.torvald.terrarum.gamecontroller.Key import net.torvald.terrarum.gamecontroller.KeyMap @@ -82,6 +83,8 @@ constructor() : BasicGameState() { val KEY_LIGHTMAP_RENDER = Key.F7 val KEY_LIGHTMAP_SMOOTH = Key.F8 + var DELTA_T: Int = 0 + @Throws(SlickException::class) override fun init(gameContainer: GameContainer, stateBasedGame: StateBasedGame) { KeyMap.build() @@ -133,6 +136,8 @@ constructor() : BasicGameState() { } override fun update(gc: GameContainer, sbg: StateBasedGame, delta: Int) { + DELTA_T = delta + update_delta = delta setAppTitle() @@ -345,7 +350,8 @@ constructor() : BasicGameState() { i-- // array removed 1 elem, so also decrement counter by 1 } else { - actorContainer[i].update(gc, delta) + //actorContainer[i].update(gc, delta) + actorContainer[i].start() } i++ } diff --git a/src/net/torvald/terrarum/gameactors/Actor.kt b/src/net/torvald/terrarum/gameactors/Actor.kt index 0103916dd..028a69a8a 100644 --- a/src/net/torvald/terrarum/gameactors/Actor.kt +++ b/src/net/torvald/terrarum/gameactors/Actor.kt @@ -7,9 +7,16 @@ import org.newdawn.slick.GameContainer /** * Created by minjaesong on 16-03-14. */ -abstract class Actor : Comparable { +abstract class Actor : Comparable, Runnable { - abstract fun update(gc: GameContainer, delta_t: Int) + abstract protected fun update(gc: GameContainer, delta_t: Int) // use start() for multithreaded env + + protected var thread: Thread? = null + + fun start() { + thread = Thread(this, "ID: $referenceID") + thread!!.run() + } /** * Valid RefID is equal to or greater than 32768. diff --git a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt index bc03208cf..6dddb5935 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt @@ -28,7 +28,7 @@ open class ActorWithBody constructor() : Actor(), Visible { /** * Velocity vector (broken down by axes) for newtonian sim. * Acceleration: used in code like: - * veloY += 3.0 + * veloY += 3.0 * +3.0 is acceleration. You __accumulate__ acceleration to the velocity. */ @Volatile var veloX: Float = 0.toFloat() @@ -121,17 +121,20 @@ open class ActorWithBody constructor() : Actor(), Visible { @Transient internal var eventMoving = EVENT_MOVE_NONE // cannot collide both X-axis and Y-axis, or else jump control breaks up. /** - * in milliseconds + * Post-hit invincibility, in milliseconds */ - @Transient val INVINCIBILITY_TIME = 500 + @Transient val INVINCIBILITY_TIME: Int = 500 @Transient private val map: GameMap - @Transient private val MASS_DEFAULT = 60f + @Transient private val MASS_DEFAULT: Float = 60f internal val physSleep: Boolean get() = veloX.abs() < 0.5 && veloY.abs() < 0.5 + /** + * for collide-to-world compensation + */ @Transient private var posAdjustX = 0 @Transient private var posAdjustY = 0 @@ -187,6 +190,8 @@ open class ActorWithBody constructor() : Actor(), Visible { if (elasticity != 0f) elasticity = 0f } + override fun run() = update(Terrarum.appgc, Terrarum.game.DELTA_T) + override fun update(gc: GameContainer, delta_t: Int) { if (isUpdate) { /** diff --git a/src/net/torvald/terrarum/gameactors/CollisionSolver.kt b/src/net/torvald/terrarum/gameactors/collisionsolver/CollisionSolver.kt similarity index 85% rename from src/net/torvald/terrarum/gameactors/CollisionSolver.kt rename to src/net/torvald/terrarum/gameactors/collisionsolver/CollisionSolver.kt index a21a5967d..2b00e9811 100644 --- a/src/net/torvald/terrarum/gameactors/CollisionSolver.kt +++ b/src/net/torvald/terrarum/gameactors/collisionsolver/CollisionSolver.kt @@ -1,7 +1,8 @@ -package net.torvald.terrarum.gameactors +package net.torvald.terrarum.gameactors.collisionsolver import com.jme3.math.FastMath import net.torvald.terrarum.Terrarum +import net.torvald.terrarum.gameactors.ActorWithBody import java.util.* /** @@ -26,7 +27,8 @@ object CollisionSolver { private val collCandidateStack = Stack() /** - * @link https://www.toptal.com/game/video-game-physics-part-ii-collision-detection-for-solid-objects + * to see what's going on here, visit + * [this link](https://www.toptal.com/game/video-game-physics-part-ii-collision-detection-for-solid-objects) */ fun process() { // clean up before we go @@ -112,15 +114,31 @@ object CollisionSolver { // if they actually makes collision (e.g. player vs ball), solve it if (a makesCollisionWith b) { + // assuming perfect elastic collision; ignoring 'var elasticity' + val ux_1 = a.veloX + val ux_2 = b.veloX + val uy_1 = a.veloY + val uy_2 = b.veloY + val m1 = a.mass + val m2 = b.mass + val vx_1 = (ux_2 * (m1 - m2) + 2 * m2 * ux_2) / (m1 + m2) + val vx_2 = (ux_2 * (m2 - m1) + 2 * m1 * ux_1) / (m1 + m2) + val vy_1 = (uy_2 * (m1 - m2) + 2 * m2 * uy_2) / (m1 + m2) + val vy_2 = (uy_2 * (m2 - m1) + 2 * m1 * uy_1) / (m1 + m2) + + a.veloX = vx_1 + a.veloY = vy_1 + b.veloX = vx_2 + b.veloY = vy_2 } } } private infix fun ActorWithBody.makesCollisionWith(other: ActorWithBody): Boolean { - return false + return true } - + private infix fun ActorWithBody.isCollidingWith(other: ActorWithBody): Boolean { val ax = this.hitbox.centeredX val ay = this.hitbox.centeredY diff --git a/src/net/torvald/terrarum/gameactors/collisionsolver/SolveByUnit.kt b/src/net/torvald/terrarum/gameactors/collisionsolver/SolveByUnit.kt new file mode 100644 index 000000000..7a94529ce --- /dev/null +++ b/src/net/torvald/terrarum/gameactors/collisionsolver/SolveByUnit.kt @@ -0,0 +1,11 @@ +package net.torvald.terrarum.gameactors.collisionsolver + +/** + * multithreaded version of CollisionSolver#solveCollision + * Created by minjaesong on 16-04-26. + */ +internal class SolveByUnit : Runnable { + override fun run() { + throw UnsupportedOperationException() + } +} \ No newline at end of file diff --git a/work_files/phys penetration compensation.numbers b/work_files/phys penetration compensation.numbers new file mode 100644 index 000000000..2ea407539 Binary files /dev/null and b/work_files/phys penetration compensation.numbers differ