From 3202c67f4736dfed797d42f0c2c9c72172a04e1a Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Tue, 11 Feb 2025 18:05:44 +0000 Subject: [PATCH] begin adding variant for STRAIGHT_BAT enemy --- fcore/enemy/enemy-behaviour.sml | 2 +- fcore/enemy/enemy-patch.sml | 98 ++++++++++++++++++++++++++++++--- fcore/enemy/enemy-variants.sml | 4 +- fcore/game-type.sml | 49 ++--------------- 4 files changed, 96 insertions(+), 57 deletions(-) diff --git a/fcore/enemy/enemy-behaviour.sml b/fcore/enemy/enemy-behaviour.sml index 62f376b..b250360 100644 --- a/fcore/enemy/enemy-behaviour.sml +++ b/fcore/enemy/enemy-behaviour.sml @@ -528,7 +528,7 @@ struct , enemyList , fallingList ) - | FOLLOW_SIME => + | FOLLOW_SLIME => updateFollowState ( player , enemy diff --git a/fcore/enemy/enemy-patch.sml b/fcore/enemy/enemy-patch.sml index ccc2b41..5ed6b58 100644 --- a/fcore/enemy/enemy-patch.sml +++ b/fcore/enemy/enemy-patch.sml @@ -25,7 +25,8 @@ struct | W_PLAT_ID of int | W_NEXT_PLAT_ID of int - fun mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID, nextPlatID) = + fun mkEnemy + (id, health, x, y, xAxis, yAxis, variant, platID, nextPlatID, batRest) = { id = id , health = health , x = x @@ -35,27 +36,106 @@ struct , variant = variant , platID = platID , nextPlatID = nextPlatID + , batRest = batRest } fun withPatch (enemy, patch) = let - val {id, health, x, y, xAxis, yAxis, variant, platID, nextPlatID} = enemy + val {id, health, x, y, xAxis, yAxis, variant, platID, nextPlatID, batRest} = + enemy in case patch of W_HEALTH health => - mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID, nextPlatID) + mkEnemy + ( id + , health + , x + , y + , xAxis + , yAxis + , variant + , platID + , nextPlatID + , batRest + ) | W_X x => - mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID, nextPlatID) + mkEnemy + ( id + , health + , x + , y + , xAxis + , yAxis + , variant + , platID + , nextPlatID + , batRest + ) | W_X_AXIS xAxis => - mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID, nextPlatID) + mkEnemy + ( id + , health + , x + , y + , xAxis + , yAxis + , variant + , platID + , nextPlatID + , batRest + ) | W_Y y => - mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID, nextPlatID) + mkEnemy + ( id + , health + , x + , y + , xAxis + , yAxis + , variant + , platID + , nextPlatID + , batRest + ) | W_Y_AXIS yAxis => - mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID, nextPlatID) + mkEnemy + ( id + , health + , x + , y + , xAxis + , yAxis + , variant + , platID + , nextPlatID + , batRest + ) | W_PLAT_ID platID => - mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID, nextPlatID) + mkEnemy + ( id + , health + , x + , y + , xAxis + , yAxis + , variant + , platID + , nextPlatID + , batRest + ) | W_NEXT_PLAT_ID nextPlatID => - mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID, nextPlatID) + mkEnemy + ( id + , health + , x + , y + , xAxis + , yAxis + , variant + , platID + , nextPlatID + , batRest + ) end fun withPatches (enemy, lst) = diff --git a/fcore/enemy/enemy-variants.sml b/fcore/enemy/enemy-variants.sml index 2f21201..11e02d1 100644 --- a/fcore/enemy/enemy-variants.sml +++ b/fcore/enemy/enemy-variants.sml @@ -1,7 +1,7 @@ signature ENEMY_VARIANTS = sig - datatype t = PATROL_SLIME | FOLLOW_SLIME + datatype t = PATROL_SLIME | FOLLOW_SLIME | STRAIGHT_BAT end structure EnemyVariants: ENEMY_VARIANTS = -struct datatype t = PATROL_SLIME | FOLLOW_SLIME end +struct datatype t = PATROL_SLIME | FOLLOW_SLIME | STRAIGHT_BAT end diff --git a/fcore/game-type.sml b/fcore/game-type.sml index 8e264a7..7a4a0db 100644 --- a/fcore/game-type.sml +++ b/fcore/game-type.sml @@ -56,6 +56,7 @@ sig , variant: EnemyVariants.t , platID: int , nextPlatID: int + , batRest: int } type falling_enemy = {x: int, y: int, variant: EnemyVariants.t} @@ -133,6 +134,7 @@ struct , variant: EnemyVariants.t , platID: int , nextPlatID: int + , batRest: int } type falling_enemy = {x: int, y: int, variant: EnemyVariants.t} @@ -220,52 +222,9 @@ struct , variant = EnemyVariants.FOLLOW_SLIME , platID = ~1 , nextPlatID = ~1 + , batRest = 0 } - val enemy2 = - { id = 2 - , x = 777 - , y = 333 - , health = 1 - , xAxis = MOVE_LEFT - , yAxis = FALLING - , variant = EnemyVariants.FOLLOW_SLIME - , platID = ~1 - , nextPlatID = ~1 - } - val enemy3 = - { id = 3 - , x = 555 - , y = 135 - , health = 1 - , xAxis = MOVE_RIGHT - , yAxis = FALLING - , variant = EnemyVariants.FOLLOW_SLIME - , platID = ~1 - , nextPlatID = ~1 - } - val enemy4 = - { id = 4 - , x = 555 - , y = 555 - , health = 1 - , xAxis = MOVE_RIGHT - , yAxis = FALLING - , variant = EnemyVariants.FOLLOW_SLIME - , platID = ~1 - , nextPlatID = ~1 - } - val enemy5 = - { id = 5 - , x = 199 - , y = 333 - , health = 1 - , xAxis = MOVE_RIGHT - , yAxis = FALLING - , variant = EnemyVariants.FOLLOW_SLIME - , platID = ~1 - , nextPlatID = ~1 - } - val enemies = Vector.fromList [enemy1, enemy2, enemy3, enemy4, enemy5] + val enemies = Vector.fromList [enemy1] val graph = Graph.fromPlatforms (platforms, platformTree) in { player = player