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:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user