begin adding variant for STRAIGHT_BAT enemy

This commit is contained in:
2025-02-11 18:05:44 +00:00
parent 534852c8bf
commit 3202c67f47
4 changed files with 96 additions and 57 deletions

View File

@@ -528,7 +528,7 @@ struct
, enemyList , enemyList
, fallingList , fallingList
) )
| FOLLOW_SIME => | FOLLOW_SLIME =>
updateFollowState updateFollowState
( player ( player
, enemy , enemy

View File

@@ -25,7 +25,8 @@ struct
| W_PLAT_ID of int | W_PLAT_ID of int
| W_NEXT_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 { id = id
, health = health , health = health
, x = x , x = x
@@ -35,27 +36,106 @@ struct
, variant = variant , variant = variant
, platID = platID , platID = platID
, nextPlatID = nextPlatID , nextPlatID = nextPlatID
, batRest = batRest
} }
fun withPatch (enemy, patch) = fun withPatch (enemy, patch) =
let 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 in
case patch of case patch of
W_HEALTH health => 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 => | 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 => | 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 => | 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 => | 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 => | 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 => | 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 end
fun withPatches (enemy, lst) = fun withPatches (enemy, lst) =

View File

@@ -1,7 +1,7 @@
signature ENEMY_VARIANTS = signature ENEMY_VARIANTS =
sig sig
datatype t = PATROL_SLIME | FOLLOW_SLIME datatype t = PATROL_SLIME | FOLLOW_SLIME | STRAIGHT_BAT
end end
structure EnemyVariants: ENEMY_VARIANTS = structure EnemyVariants: ENEMY_VARIANTS =
struct datatype t = PATROL_SLIME | FOLLOW_SLIME end struct datatype t = PATROL_SLIME | FOLLOW_SLIME | STRAIGHT_BAT end

View File

@@ -56,6 +56,7 @@ sig
, variant: EnemyVariants.t , variant: EnemyVariants.t
, platID: int , platID: int
, nextPlatID: int , nextPlatID: int
, batRest: int
} }
type falling_enemy = {x: int, y: int, variant: EnemyVariants.t} type falling_enemy = {x: int, y: int, variant: EnemyVariants.t}
@@ -133,6 +134,7 @@ struct
, variant: EnemyVariants.t , variant: EnemyVariants.t
, platID: int , platID: int
, nextPlatID: int , nextPlatID: int
, batRest: int
} }
type falling_enemy = {x: int, y: int, variant: EnemyVariants.t} type falling_enemy = {x: int, y: int, variant: EnemyVariants.t}
@@ -220,52 +222,9 @@ struct
, variant = EnemyVariants.FOLLOW_SLIME , variant = EnemyVariants.FOLLOW_SLIME
, platID = ~1 , platID = ~1
, nextPlatID = ~1 , nextPlatID = ~1
, batRest = 0
} }
val enemy2 = val enemies = Vector.fromList [enemy1]
{ 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 graph = Graph.fromPlatforms (platforms, platformTree) val graph = Graph.fromPlatforms (platforms, platformTree)
in in
{ player = player { player = player