From 27fbe1c12e3df75efa4b23031df2c0cbadeda928 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sun, 12 Jan 2025 23:28:03 +0000 Subject: [PATCH] create enemy patch structure --- fcore/enemy-patch.sml | 32 ++++++++++++++++++++++++++++++++ oms.mlb | 1 + 2 files changed, 33 insertions(+) create mode 100644 fcore/enemy-patch.sml diff --git a/fcore/enemy-patch.sml b/fcore/enemy-patch.sml new file mode 100644 index 0000000..f66d853 --- /dev/null +++ b/fcore/enemy-patch.sml @@ -0,0 +1,32 @@ +structure EnemyPatch = +struct + datatype enemy_patch = + W_HEALTH of int + | W_X of int + | W_Y of int + | W_X_AXIS of GameType.x_axis + | W_Y_AXIS of GameType.y_axis + + fun mkEnemy (id, health, x, y, xAxis, yAxis) = + {id = id, health = health, x = x, y = y, xAxis = xAxis, yAxis = yAxis} + + fun withPatch (enemy, patch) = + let + val {id, health, x, y, xAxis, yAxis} = enemy + in + case patch of + W_HEALTH health => mkEnemy (id, health, x, y, xAxis, yAxis) + | W_X x => mkEnemy (id, health, x, y, xAxis, yAxis) + | W_X_AXIS xAxis => mkEnemy (id, health, x, y, xAxis, yAxis) + | W_Y y => mkEnemy (id, health, x, y, xAxis, yAxis) + | W_Y_AXIS yAxis => mkEnemy (id, health, x, y, xAxis, yAxis) + end + + fun withPatches (enemy, lst) = + case lst of + hd :: tl => + let val enemy = withPatch (enemy, hd) + in withPatches (enemy, tl) + end + | [] => enemy +end diff --git a/oms.mlb b/oms.mlb index 050a991..8f792f3 100644 --- a/oms.mlb +++ b/oms.mlb @@ -18,6 +18,7 @@ fcore/enemy.sml fcore/game-type.sml fcore/player-patch.sml +fcore/enemy-patch.sml fcore/physics.sml fcore/player.sml