Refactor travis testing
This commit is contained in:
67
projects/flixel-rpg-tutorial/source/Player.kiss
Normal file
67
projects/flixel-rpg-tutorial/source/Player.kiss
Normal file
@@ -0,0 +1,67 @@
|
||||
(defvar &inline :Float SPEED 200)
|
||||
|
||||
(defmethod new [:Float x :Float y]
|
||||
(super x y)
|
||||
(loadGraphic AssetPaths.player__png true 16 16)
|
||||
(setFacingFlip FlxObject.LEFT false false)
|
||||
(setFacingFlip FlxObject.RIGHT true false)
|
||||
(animation.add "lr" [3 4 3 5] 6 false)
|
||||
(animation.add "u" [6 7 6 8] 6 false)
|
||||
(animation.add "d" [0 1 0 2] 6 false)
|
||||
(set drag.x (set drag.y 1600))
|
||||
(setSize 8 8)
|
||||
(offset.set 4 4))
|
||||
|
||||
(defmethod :Void updateMovement []
|
||||
(let [[&mut up &mut down &mut left &mut right]
|
||||
(map [[UP W] [DOWN S] [LEFT A] [RIGHT D]] FlxG.keys.anyPressed)]
|
||||
(when (and up down)
|
||||
(set up (set down false)))
|
||||
(when (and left right)
|
||||
(set left (set right false)))
|
||||
(if (or up down left right)
|
||||
(let [&mut :Float newAngle 0]
|
||||
(cond
|
||||
(up
|
||||
(set newAngle -90)
|
||||
(cond
|
||||
(left
|
||||
(set newAngle (- newAngle 45)))
|
||||
(right
|
||||
(set newAngle (+ newAngle 45))))
|
||||
(set facing FlxObject.UP))
|
||||
(down
|
||||
(set newAngle 90)
|
||||
(cond
|
||||
(left
|
||||
(set newAngle (+ newAngle 45)))
|
||||
(right
|
||||
(set newAngle (- newAngle 45))))
|
||||
(set facing FlxObject.DOWN))
|
||||
(left
|
||||
(set newAngle 180)
|
||||
(set facing FlxObject.LEFT))
|
||||
(right
|
||||
(set newAngle 0)
|
||||
(set facing FlxObject.RIGHT)))
|
||||
(velocity.set SPEED 0)
|
||||
(velocity.rotate (FlxPoint.weak 0 0) newAngle))
|
||||
(when animation.curAnim
|
||||
(set animation.curAnim.curFrame 0)
|
||||
(animation.curAnim.pause)))
|
||||
// TODO != is not implemented. Not sure how it would work as a variadic, because other
|
||||
// Lisps don't have that either
|
||||
(when !(and (= 0 velocity.x) (= 0 velocity.y))
|
||||
(case facing
|
||||
((or FlxObject.LEFT FlxObject.RIGHT)
|
||||
(animation.play "lr"))
|
||||
(FlxObject.UP
|
||||
(animation.play "u"))
|
||||
(FlxObject.DOWN
|
||||
(animation.play "d"))
|
||||
(otherwise
|
||||
(return))))))
|
||||
|
||||
(defmethod &override update [:Float elapsed]
|
||||
(updateMovement)
|
||||
(super.update elapsed))
|
Reference in New Issue
Block a user