differentiate 'upHeld' from 'jumpHeld' (we may want a different button for going up/down menu and a different button for jumping)
This commit is contained in:
@@ -50,11 +50,11 @@ struct
|
||||
if jumpPressed then (* apply gravity *) FALLING else JUMPING 0
|
||||
| _ => prevAxis
|
||||
|
||||
fun getJumpPatches (player, upHeld, downHeld, acc) =
|
||||
fun getJumpPatches (player, jumpHeld, downHeld, acc) =
|
||||
let
|
||||
val {yAxis, jumpPressed, ...} = player
|
||||
in
|
||||
case (upHeld, downHeld) of
|
||||
case (jumpHeld, downHeld) of
|
||||
(false, false) =>
|
||||
let
|
||||
val yAxis = defaultYAxis yAxis
|
||||
@@ -205,7 +205,7 @@ struct
|
||||
, ...
|
||||
} = player
|
||||
|
||||
val {leftHeld, rightHeld, upHeld, downHeld, attackHeld} = input
|
||||
val {leftHeld, rightHeld, upHeld, downHeld, attackHeld, jumpHeld} = input
|
||||
|
||||
val xAxis = getXAxis (leftHeld, rightHeld)
|
||||
val facing = getFacing (facing, xAxis)
|
||||
@@ -225,7 +225,7 @@ struct
|
||||
, mainAttackPressed
|
||||
)
|
||||
|
||||
val acc = getJumpPatches (player, upHeld, downHeld, acc)
|
||||
val acc = getJumpPatches (player, jumpHeld, downHeld, acc)
|
||||
in
|
||||
acc
|
||||
end
|
||||
|
||||
@@ -15,6 +15,7 @@ struct
|
||||
, rightHeld = ref false
|
||||
, upHeld = ref false
|
||||
, downHeld = ref false
|
||||
, jumpHeld = ref false
|
||||
, attackHeld = ref false
|
||||
, width = ref (1920.0 : Real32.real)
|
||||
, height = ref (1080.0 : Real32.real)
|
||||
@@ -26,6 +27,7 @@ struct
|
||||
, upHeld = !(#upHeld state)
|
||||
, downHeld = !(#downHeld state)
|
||||
, attackHeld = !(#attackHeld state)
|
||||
, jumpHeld = !(#jumpHeld state)
|
||||
}
|
||||
|
||||
fun actionToBool action = action = Input.PRESS
|
||||
@@ -42,7 +44,7 @@ struct
|
||||
else if code = right then #rightHeld state := action
|
||||
else if code = down then #downHeld state := action
|
||||
else if code = attack then #attackHeld state := action
|
||||
else if code = jump then #upHeld state := action
|
||||
else if code = jump then #jumpHeld state := action
|
||||
else ()
|
||||
end
|
||||
| NONE => ()
|
||||
|
||||
Reference in New Issue
Block a user