fix a purely visual bug: do not transition to 'DROP_BELOW_PLATFORM state when player is touching ground wall
This commit is contained in:
@@ -52,14 +52,7 @@ struct
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
fun helpAttackEnemies
|
fun helpAttackEnemies
|
||||||
( player
|
(player, defeatedList, enemyMap, fallingMap, enemyTree, pos, boxes) =
|
||||||
, defeatedList
|
|
||||||
, enemyMap
|
|
||||||
, fallingMap
|
|
||||||
, enemyTree
|
|
||||||
, pos
|
|
||||||
, boxes
|
|
||||||
) =
|
|
||||||
if pos = Vector.length boxes then
|
if pos = Vector.length boxes then
|
||||||
let
|
let
|
||||||
val defeatedList = Vector.fromList defeatedList
|
val defeatedList = Vector.fromList defeatedList
|
||||||
@@ -114,14 +107,7 @@ struct
|
|||||||
| FACING_LEFT => Vector.sub (Whip.leftFrames, frame)
|
| FACING_LEFT => Vector.sub (Whip.leftFrames, frame)
|
||||||
in
|
in
|
||||||
helpAttackEnemies
|
helpAttackEnemies
|
||||||
( player
|
(player, [], enemyMap, fallingMap, enemyTree, 0, boxes)
|
||||||
, []
|
|
||||||
, enemyMap
|
|
||||||
, fallingMap
|
|
||||||
, enemyTree
|
|
||||||
, 0
|
|
||||||
, boxes
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
| _ => (player, enemyMap, fallingMap)
|
| _ => (player, enemyMap, fallingMap)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -50,12 +50,34 @@ struct
|
|||||||
if jumpPressed then (* apply gravity *) FALLING else JUMPING 0
|
if jumpPressed then (* apply gravity *) FALLING else JUMPING 0
|
||||||
| _ => prevAxis
|
| _ => prevAxis
|
||||||
|
|
||||||
fun getJumpPatches (player, jumpHeld, downHeld, acc) =
|
fun getJumpPatches (player, jumpHeld, downHeld, acc, wallTree) =
|
||||||
let
|
let
|
||||||
val {yAxis, jumpPressed, ...} = player
|
val {yAxis, jumpPressed, ...} = player
|
||||||
in
|
in
|
||||||
case (jumpHeld, downHeld) of
|
case (jumpHeld, downHeld) of
|
||||||
(false, false) =>
|
(true, false) =>
|
||||||
|
let
|
||||||
|
val yAxis = onJumpPressed (yAxis, jumpPressed)
|
||||||
|
val jumpPressed = true
|
||||||
|
in
|
||||||
|
W_Y_AXIS yAxis :: W_JUMP_PRESSED jumpPressed :: acc
|
||||||
|
end
|
||||||
|
| (false, true) =>
|
||||||
|
let
|
||||||
|
val {x, y, ...} = player
|
||||||
|
val ex = Constants.playerWidth
|
||||||
|
val y = y + Constants.playerHeight
|
||||||
|
val ey = 1
|
||||||
|
val jumpPressed = false
|
||||||
|
val yAxis =
|
||||||
|
if QuadTree.hasCollisionAt (x, y, ex, ey, ~1, wallTree) then
|
||||||
|
ON_GROUND
|
||||||
|
else
|
||||||
|
DROP_BELOW_PLATFORM
|
||||||
|
in
|
||||||
|
W_Y_AXIS yAxis :: W_JUMP_PRESSED jumpPressed :: acc
|
||||||
|
end
|
||||||
|
| (false, false) =>
|
||||||
let
|
let
|
||||||
val yAxis = defaultYAxis yAxis
|
val yAxis = defaultYAxis yAxis
|
||||||
val jumpPressed = false
|
val jumpPressed = false
|
||||||
@@ -66,20 +88,6 @@ struct
|
|||||||
let val yAxis = defaultYAxis yAxis
|
let val yAxis = defaultYAxis yAxis
|
||||||
in W_Y_AXIS yAxis :: acc
|
in W_Y_AXIS yAxis :: acc
|
||||||
end
|
end
|
||||||
| (true, false) =>
|
|
||||||
let
|
|
||||||
val yAxis = onJumpPressed (yAxis, jumpPressed)
|
|
||||||
val jumpPressed = true
|
|
||||||
in
|
|
||||||
W_Y_AXIS yAxis :: W_JUMP_PRESSED jumpPressed :: acc
|
|
||||||
end
|
|
||||||
| (false, true) =>
|
|
||||||
let
|
|
||||||
val jumpPressed = false
|
|
||||||
val yAxis = DROP_BELOW_PLATFORM
|
|
||||||
in
|
|
||||||
W_Y_AXIS yAxis :: W_JUMP_PRESSED jumpPressed :: acc
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
(* called only when player has no projectiles or was not previously attacking *)
|
(* called only when player has no projectiles or was not previously attacking *)
|
||||||
@@ -175,7 +183,7 @@ struct
|
|||||||
else
|
else
|
||||||
helpGetMainAttackPatches (attackHeld, mainAttackPressed, charge, acc)
|
helpGetMainAttackPatches (attackHeld, mainAttackPressed, charge, acc)
|
||||||
|
|
||||||
fun getInputPatches (player: player, input: FrameInputType.t) =
|
fun getInputPatches (player: player, input: FrameInputType.t, wallTree) =
|
||||||
let
|
let
|
||||||
val
|
val
|
||||||
{ x
|
{ x
|
||||||
@@ -212,7 +220,7 @@ struct
|
|||||||
, mainAttackPressed
|
, mainAttackPressed
|
||||||
)
|
)
|
||||||
|
|
||||||
val acc = getJumpPatches (player, jumpHeld, downHeld, acc)
|
val acc = getJumpPatches (player, jumpHeld, downHeld, acc, wallTree)
|
||||||
in
|
in
|
||||||
acc
|
acc
|
||||||
end
|
end
|
||||||
@@ -355,7 +363,7 @@ struct
|
|||||||
|
|
||||||
fun runPhysicsAndInput (game: LevelType.level_type, input) =
|
fun runPhysicsAndInput (game: LevelType.level_type, input) =
|
||||||
let
|
let
|
||||||
val player = #player game
|
val {player, walls, wallTree, platforms, platformTree, ...} = game
|
||||||
|
|
||||||
val oldAnimTimer = #animTimer player
|
val oldAnimTimer = #animTimer player
|
||||||
val oldXAxis = #xAxis player
|
val oldXAxis = #xAxis player
|
||||||
@@ -370,7 +378,7 @@ struct
|
|||||||
* It's important to apply the recoil patches after handling input
|
* It's important to apply the recoil patches after handling input
|
||||||
* because we want to act on the latest recoil state straight away. *)
|
* because we want to act on the latest recoil state straight away. *)
|
||||||
case #recoil player of
|
case #recoil player of
|
||||||
NO_RECOIL => getInputPatches (player, input)
|
NO_RECOIL => getInputPatches (player, input, wallTree)
|
||||||
| _ => []
|
| _ => []
|
||||||
|
|
||||||
val patches =
|
val patches =
|
||||||
@@ -399,7 +407,6 @@ struct
|
|||||||
val patches = PlayerPhysics.getPhysicsPatches player
|
val patches = PlayerPhysics.getPhysicsPatches player
|
||||||
val player = PlayerPatch.withPatches (player, patches)
|
val player = PlayerPatch.withPatches (player, patches)
|
||||||
|
|
||||||
val {walls, wallTree, platforms, platformTree, ...} = game
|
|
||||||
val patches = PlayerPhysics.getEnvironmentPatches
|
val patches = PlayerPhysics.getEnvironmentPatches
|
||||||
(player, walls, wallTree, platforms, platformTree)
|
(player, walls, wallTree, platforms, platformTree)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user