From 7290d9865db63589c14bc95b02b542a7251716b2 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sun, 12 Jan 2025 23:58:21 +0000 Subject: [PATCH] have enemy physics working and applied to enemy --- fcore/enemy.sml | 21 +++++++++++++-------- fcore/game-type.sml | 6 +++--- oms.mlb | 4 ++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/fcore/enemy.sml b/fcore/enemy.sml index f902f7b..8a4e0bb 100644 --- a/fcore/enemy.sml +++ b/fcore/enemy.sml @@ -28,15 +28,20 @@ struct (* filter out if decrementing health by one = 0 *) acc else - { health = health - 1 - , x = x - , y = y - , id = id - , xAxis = xAxis - , yAxis = yAxis - } :: acc + let + val patches = EnemyPhysics.getPatches enemy + val patches = EnemyPatch.W_HEALTH (health - 1) :: patches + val enemy = EnemyPatch.withPatches (enemy, patches) + in + enemy :: acc + end else - enemy :: acc + let + val patches = EnemyPhysics.getPatches enemy + val enemy = EnemyPatch.withPatches (enemy, patches) + in + enemy :: acc + end end (* filter enemy projectiles when player is not attacking *) diff --git a/fcore/game-type.sml b/fcore/game-type.sml index 255cb26..ff2a00e 100644 --- a/fcore/game-type.sml +++ b/fcore/game-type.sml @@ -157,7 +157,7 @@ struct , y = 945 , health = 5 , xAxis = STAY_STILL - , yAxis = ON_GROUND + , yAxis = FALLING } val enemy2 = { id = 2 @@ -165,7 +165,7 @@ struct , y = 945 , health = 5 , xAxis = STAY_STILL - , yAxis = ON_GROUND + , yAxis = FALLING } val enemy3 = { id = 3 @@ -173,7 +173,7 @@ struct , y = 945 , health = 5 , xAxis = STAY_STILL - , yAxis = ON_GROUND + , yAxis = FALLING } val enemies = Vector.fromList [enemy1, enemy2, enemy3] in diff --git a/oms.mlb b/oms.mlb index 8f792f3..b86b57a 100644 --- a/oms.mlb +++ b/oms.mlb @@ -14,13 +14,13 @@ end fcore/wall.sml fcore/platform.sml -fcore/enemy.sml fcore/game-type.sml fcore/player-patch.sml fcore/enemy-patch.sml - fcore/physics.sml + +fcore/enemy.sml fcore/player.sml fcore/projectile.sml