make it so that player will jump shorter distance if they only press up button for short period of time
This commit is contained in:
@@ -69,10 +69,7 @@ struct
|
|||||||
val collisions = QuadTree.getCollisionSides
|
val collisions = QuadTree.getCollisionSides
|
||||||
(desiredX, y, size, size, 0, 0, 1920, 1080, 0, Wall.tree)
|
(desiredX, y, size, size, 0, 0, 1920, 1080, 0, Wall.tree)
|
||||||
in
|
in
|
||||||
(* using default yAxis of FALLING when on ground
|
checkWalls (yAxis, xAxis, desiredX, y, health, collisions)
|
||||||
* ensures that gravity is applied
|
|
||||||
* when player walks off from platform *)
|
|
||||||
checkWalls (FALLING, xAxis, desiredX, y, health, collisions)
|
|
||||||
end
|
end
|
||||||
| FALLING =>
|
| FALLING =>
|
||||||
let
|
let
|
||||||
@@ -114,7 +111,14 @@ struct
|
|||||||
|
|
||||||
fun getYAxis (uh, dh, yAxis) =
|
fun getYAxis (uh, dh, yAxis) =
|
||||||
case (uh, dh) of
|
case (uh, dh) of
|
||||||
(false, false) => yAxis
|
(false, false) =>
|
||||||
|
(* default yAxis of FALLING does two things:
|
||||||
|
* 1. When player walks off platform, gravity is applied.
|
||||||
|
* 2. When player presses up for a short period of time,
|
||||||
|
* the player makes a shorter jump rather than jumping longer.
|
||||||
|
* *)
|
||||||
|
FALLING
|
||||||
|
| (true, true) => FALLING
|
||||||
| (true, false) =>
|
| (true, false) =>
|
||||||
(case yAxis of
|
(case yAxis of
|
||||||
ON_GROUND => JUMPING 0
|
ON_GROUND => JUMPING 0
|
||||||
@@ -122,7 +126,6 @@ struct
|
|||||||
| (false, true) =>
|
| (false, true) =>
|
||||||
(* todo: should move down if on platform *)
|
(* todo: should move down if on platform *)
|
||||||
yAxis
|
yAxis
|
||||||
| (true, true) => yAxis
|
|
||||||
|
|
||||||
fun move
|
fun move
|
||||||
({x, y, yAxis, health, ...}: t, {leftHeld, rightHeld, upHeld, downHeld}) =
|
({x, y, yAxis, health, ...}: t, {leftHeld, rightHeld, upHeld, downHeld}) =
|
||||||
|
|||||||
Reference in New Issue
Block a user