Reworked the directories to be a little more machine independent and make the hero snap to grid cells when moving, which improved collision handling.

This commit is contained in:
dalyjame
2019-08-06 20:49:31 -04:00
parent 0071e5af80
commit 2fc918a728
9 changed files with 149 additions and 30 deletions

View File

@@ -1,10 +1,27 @@
package fmon.world
import fmon.draw._
import scalafx.util.Duration
class Actor(val sprite: Sprite, var x: Double, var y: Double) {
import fmon._
import fmon.draw._
import fmon.util.Direction
class Actor(val sprite: Sprite, var pos: Position, var move: Movement) {
def x: Int = pos.x
def y: Int = pos.y
def xreal: Double = x - move.direction.x * move.completion
def yreal: Double = y - move.direction.y * move.completion
def pose: String = sprite.pose
def pose_=(p: String) = {
sprite.pose = p
}
def slide(dt: Duration): Unit = {
move.completion -= dt.toSeconds() * Config.moveSpeed
if (move.completion <= 0) {
//pos += move.direction
move = new Movement(Direction.Stationary, 0)
}
}
}