-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.2.0: Merge improvements made after trying it out with a gamejam ga…
…me (Slime Bath). Remove some the dependency on AssetManager in GameEntity.
- Loading branch information
Showing
45 changed files
with
714 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,7 @@ apply<KorgeGradlePlugin>() | |
|
||
korge { | ||
id = "com.redhue.korgeboot" | ||
|
||
targetJs() | ||
targetJvm() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 5 additions & 9 deletions
14
src/commonMain/kotlin/components/collision/MovesWithoutTilemapCollision.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
package components.collision | ||
|
||
import com.soywiz.klock.DateTime | ||
import com.soywiz.klock.TimeSpan | ||
import com.soywiz.korge.component.UpdateComponent | ||
import com.soywiz.korge.view.HitTestDirection | ||
import containers.GameEntity | ||
import program.LevelManager | ||
import program.Log | ||
import utility.* | ||
import utility.getDeltaScale | ||
|
||
class MovesWithoutTilemapCollision( | ||
override val view: GameEntity | ||
) : UpdateComponent { | ||
override fun update(dt: TimeSpan) { | ||
val delta = getDeltaScale(dt) | ||
|
||
if (view.move.isMovingLeft() || view.move.isMovingRight()) { | ||
view.x += view.move.x * delta | ||
if (view.isMovingLeft() || view.isMovingRight()) { | ||
view.x += view.move.x * delta * view.speedModifier | ||
} | ||
if (view.move.isMovingUp() || view.move.isMovingDown()) { | ||
view.y += view.move.y * delta | ||
if (view.isMovingUp() || view.isMovingDown()) { | ||
view.y += view.move.y * delta * view.speedModifier | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package components.movement | ||
|
||
import com.soywiz.klock.TimeSpan | ||
import com.soywiz.korge.component.UpdateComponent | ||
import containers.GameEntity | ||
|
||
@Suppress("MemberVisibilityCanBePrivate") | ||
class HasFacing( | ||
override val view: GameEntity, | ||
initialDirection: MoveDirection = MoveDirection.DOWN | ||
) : UpdateComponent { | ||
private var facing: MoveDirection = initialDirection | ||
|
||
override fun update(dt: TimeSpan) { | ||
val directions = view.getMoveDirections() | ||
|
||
// Priority order: l+r > u+d | ||
if (directions.contains(MoveDirection.RIGHT)) { | ||
facing = MoveDirection.RIGHT | ||
} else if (directions.contains(MoveDirection.LEFT)) { | ||
facing = MoveDirection.LEFT | ||
} else if (directions.contains(MoveDirection.UP)) { | ||
facing = MoveDirection.UP | ||
} else if (directions.contains(MoveDirection.DOWN)) { | ||
facing = MoveDirection.DOWN | ||
} | ||
} | ||
|
||
fun getFacing(): MoveDirection { | ||
return facing | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package components.movement | ||
|
||
enum class MoveDirection { | ||
UP, DOWN, LEFT, RIGHT | ||
UP, DOWN, LEFT, RIGHT, NONE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.