use player jumping sprites when player drops below platform
This commit is contained in:
@@ -116,13 +116,20 @@ struct
|
|||||||
PlayerJumpLeft5.lerp
|
PlayerJumpLeft5.lerp
|
||||||
(rx, ry, dw, dh, ww, wh, 1.0, 1.0, 1.0)
|
(rx, ry, dw, dh, ww, wh, 1.0, 1.0, 1.0)
|
||||||
|
|
||||||
|
fun getWhenDropping (player, rx, ry, dw, dh, ww, wh) =
|
||||||
|
let
|
||||||
|
val animTimer = #animTimer player
|
||||||
|
in
|
||||||
|
getWhenJumping (player, animTimer, rx, ry, dw, dh, ww, wh)
|
||||||
|
end
|
||||||
|
|
||||||
fun getWhenNotAttacked (player, rx, ry, dw, dh, ww, wh) =
|
fun getWhenNotAttacked (player, rx, ry, dw, dh, ww, wh) =
|
||||||
case #yAxis player of
|
case #yAxis player of
|
||||||
ON_GROUND => getWhenOnGround (player, rx, ry, dw, dh, ww, wh)
|
ON_GROUND => getWhenOnGround (player, rx, ry, dw, dh, ww, wh)
|
||||||
| JUMPING amt => getWhenJumping (player, amt, rx, ry, dw, dh, ww, wh)
|
| JUMPING amt => getWhenJumping (player, amt, rx, ry, dw, dh, ww, wh)
|
||||||
| FALLING => getWhenFalling (player, rx, ry, dw, dh, ww, wh)
|
| FALLING => getWhenFalling (player, rx, ry, dw, dh, ww, wh)
|
||||||
| FLOATING _ => getWhenFalling (player, rx, ry, dw, dh, ww, wh)
|
| FLOATING _ => getWhenFalling (player, rx, ry, dw, dh, ww, wh)
|
||||||
| _ => PlayerStandingRight.lerp (rx, ry, dw, dh, ww, wh, 1.0, 1.0, 1.0)
|
| DROP_BELOW_PLATFORM => getWhenDropping (player, rx, ry, dw, dh, ww, wh)
|
||||||
|
|
||||||
fun getWhenAttacked (player, amt, rx, ry, dw, dh, ww, wh) =
|
fun getWhenAttacked (player, amt, rx, ry, dw, dh, ww, wh) =
|
||||||
case #facing player of
|
case #facing player of
|
||||||
|
|||||||
@@ -432,7 +432,9 @@ struct
|
|||||||
val newXAxis = #xAxis player
|
val newXAxis = #xAxis player
|
||||||
val newYAxis = #yAxis player
|
val newYAxis = #yAxis player
|
||||||
in
|
in
|
||||||
if
|
if oldYAxis = DROP_BELOW_PLATFORM andalso newYAxis = DROP_BELOW_PLATFORM then
|
||||||
|
PlayerPatch.withPatch (player, W_ANIM_TIMER (oldAnimTimer + 1))
|
||||||
|
else if
|
||||||
oldYAxis = ON_GROUND andalso newYAxis = ON_GROUND
|
oldYAxis = ON_GROUND andalso newYAxis = ON_GROUND
|
||||||
then
|
then
|
||||||
if oldXAxis = MOVE_RIGHT andalso newXAxis = MOVE_RIGHT then
|
if oldXAxis = MOVE_RIGHT andalso newXAxis = MOVE_RIGHT then
|
||||||
@@ -466,53 +468,6 @@ struct
|
|||||||
PlayerPatch.withPatches (player, patches)
|
PlayerPatch.withPatches (player, patches)
|
||||||
end
|
end
|
||||||
|
|
||||||
(* todo: check which enemies are being attacked by player,
|
|
||||||
* updating player's 'defeatedEnemies' field (if enemy's health would reach 0)
|
|
||||||
* and updating enemy (if enemy's health wouldn't reach 0, decrement health)
|
|
||||||
val patches =
|
|
||||||
(* if player is attacking, check if enemies collide with attack *)
|
|
||||||
case #mainAttack player of
|
|
||||||
MAIN_ATTACKING {length, ...} =>
|
|
||||||
let
|
|
||||||
val height = Constants.playerSize
|
|
||||||
val {x, y, facing, enemies, ...} = player
|
|
||||||
val x =
|
|
||||||
(case facing of
|
|
||||||
FACING_RIGHT => x + Constants.playerSize
|
|
||||||
| FACING_LEFT => x - length)
|
|
||||||
|
|
||||||
val state = []
|
|
||||||
(* detect collisions from enemies who are hit by attack *)
|
|
||||||
val newDefeated = AttackEnemies.foldRegion
|
|
||||||
(x, y, length, height, (), state, enemyTree)
|
|
||||||
|
|
||||||
(* detect collisions from falling enemies too *)
|
|
||||||
val fallingTree =
|
|
||||||
FallingEnemies.generateTree (#fallingEnemies game)
|
|
||||||
val newDefeated = AttackEnemies.foldRegion
|
|
||||||
(x, y, length, height, (), newDefeated, fallingTree)
|
|
||||||
|
|
||||||
val allDefeated =
|
|
||||||
Vector.concat [Vector.fromList newDefeated, enemies]
|
|
||||||
in
|
|
||||||
W_ENEMIES allDefeated :: patches
|
|
||||||
end
|
|
||||||
| _ => patches
|
|
||||||
in
|
|
||||||
PlayerPatch.withPatches (player, patches)
|
|
||||||
end
|
|
||||||
*)
|
|
||||||
|
|
||||||
(* todo: add attacked enemies to player's 'enemies' field *)
|
|
||||||
fun concatAttackedEnemies (player: player, enemyCollisions) =
|
|
||||||
let
|
|
||||||
val newDefeated = Vector.map (fn id => {angle = 360}) enemyCollisions
|
|
||||||
val oldDefeated = #enemies player
|
|
||||||
val allDefeated = Vector.concat [oldDefeated, newDefeated]
|
|
||||||
in
|
|
||||||
PlayerPatch.withPatch (player, W_ENEMIES allDefeated)
|
|
||||||
end
|
|
||||||
|
|
||||||
(*** DRAWING FUNCTIONS ***)
|
(*** DRAWING FUNCTIONS ***)
|
||||||
fun getFieldVec (player: player, width, height) =
|
fun getFieldVec (player: player, width, height) =
|
||||||
case #mainAttack player of
|
case #mainAttack player of
|
||||||
|
|||||||
Reference in New Issue
Block a user