diff --git a/fcore/level/player/player-vec.sml b/fcore/level/player/player-vec.sml index f1c629a..ddec9f6 100644 --- a/fcore/level/player/player-vec.sml +++ b/fcore/level/player/player-vec.sml @@ -116,13 +116,20 @@ struct PlayerJumpLeft5.lerp (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) = case #yAxis player of ON_GROUND => getWhenOnGround (player, 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) | 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) = case #facing player of diff --git a/fcore/level/player/player.sml b/fcore/level/player/player.sml index 1dc4040..f16ccba 100644 --- a/fcore/level/player/player.sml +++ b/fcore/level/player/player.sml @@ -432,7 +432,9 @@ struct val newXAxis = #xAxis player val newYAxis = #yAxis player 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 then if oldXAxis = MOVE_RIGHT andalso newXAxis = MOVE_RIGHT then @@ -466,53 +468,6 @@ struct PlayerPatch.withPatches (player, patches) 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 ***) fun getFieldVec (player: player, width, height) = case #mainAttack player of