begin adding shield slime enemy variant

This commit is contained in:
2025-02-15 12:34:10 +00:00
parent 190f11d7ef
commit 66c60a490d
6 changed files with 61 additions and 3 deletions

View File

@@ -517,6 +517,9 @@ struct
EnemyPatch.withPatches (enemy, patches)
end
fun updateShieldSlime
(player, enemy, walls, wallTree, platforms, platformTree) = enemy
fun updateEnemyState
(enemy, walls, wallTree, platforms, platformTree, player, graph) =
case #variant enemy of
@@ -527,4 +530,7 @@ struct
updateFollowState
(player, enemy, walls, wallTree, platforms, platformTree, graph)
| STRAIGHT_BAT => updateStraightBat (player, enemy, walls, wallTree)
| SHIELD_SLIME =>
updateShieldSlime
(player, enemy, walls, wallTree, platforms, platformTree)
end

View File

@@ -13,6 +13,7 @@ sig
| W_BAT_MIN_Y of int
| W_BAT_DIR_Y of EnemyType.bat_dir_y
| W_FACING of EntityType.facing
| W_SHIELD_ON of bool
val withPatch: EnemyType.enemy * enemy_patch -> EnemyType.enemy
@@ -34,6 +35,7 @@ struct
| W_BAT_MIN_Y of int
| W_BAT_DIR_Y of EnemyType.bat_dir_y
| W_FACING of EntityType.facing
| W_SHIELD_ON of bool
fun mkEnemy
( id
@@ -50,6 +52,7 @@ struct
, batMaxY
, batMinY
, facing
, shieldOn
) =
{ id = id
, health = health
@@ -65,6 +68,7 @@ struct
, batMaxY = batMaxY
, batMinY = batMinY
, facing = facing
, shieldOn = shieldOn
}
fun withPatch (enemy, patch) =
@@ -84,6 +88,7 @@ struct
, batMaxY
, batMinY
, facing
, shieldOn
} = enemy
in
case patch of
@@ -103,6 +108,7 @@ struct
, batMaxY
, batMinY
, facing
, shieldOn
)
| W_X x =>
mkEnemy
@@ -120,6 +126,7 @@ struct
, batMaxY
, batMinY
, facing
, shieldOn
)
| W_X_AXIS xAxis =>
mkEnemy
@@ -137,6 +144,7 @@ struct
, batMaxY
, batMinY
, facing
, shieldOn
)
| W_Y y =>
mkEnemy
@@ -154,6 +162,7 @@ struct
, batMaxY
, batMinY
, facing
, shieldOn
)
| W_Y_AXIS yAxis =>
mkEnemy
@@ -171,6 +180,7 @@ struct
, batMaxY
, batMinY
, facing
, shieldOn
)
| W_PLAT_ID platID =>
mkEnemy
@@ -188,6 +198,7 @@ struct
, batMaxY
, batMinY
, facing
, shieldOn
)
| W_NEXT_PLAT_ID nextPlatID =>
mkEnemy
@@ -205,6 +216,7 @@ struct
, batMaxY
, batMinY
, facing
, shieldOn
)
| W_BAT_REST batRest =>
mkEnemy
@@ -222,6 +234,7 @@ struct
, batMaxY
, batMinY
, facing
, shieldOn
)
| W_BAT_MAX_Y batMaxY =>
mkEnemy
@@ -239,6 +252,7 @@ struct
, batMaxY
, batMinY
, facing
, shieldOn
)
| W_BAT_MIN_Y batMinY =>
mkEnemy
@@ -256,6 +270,7 @@ struct
, batMaxY
, batMinY
, facing
, shieldOn
)
| W_BAT_DIR_Y batDirY =>
mkEnemy
@@ -273,6 +288,7 @@ struct
, batMaxY
, batMinY
, facing
, shieldOn
)
| W_FACING facing =>
mkEnemy
@@ -290,6 +306,25 @@ struct
, batMaxY
, batMinY
, facing
, shieldOn
)
| W_SHIELD_ON shieldOn =>
mkEnemy
( id
, health
, x
, y
, xAxis
, yAxis
, variant
, platID
, nextPlatID
, batRest
, batDirY
, batMaxY
, batMinY
, facing
, shieldOn
)
end

View File

@@ -1,6 +1,6 @@
signature ENEMY_TYPE =
sig
datatype variant = PATROL_SLIME | FOLLOW_SLIME | STRAIGHT_BAT
datatype variant = PATROL_SLIME | FOLLOW_SLIME | STRAIGHT_BAT | SHIELD_SLIME
datatype bat_dir_y = UP | DOWN
@@ -19,6 +19,7 @@ sig
, batMaxY: int
, batMinY: int
, facing: EntityType.facing
, shieldOn: bool
}
type falling_enemy = {x: int, y: int, variant: variant}
@@ -29,7 +30,7 @@ end
structure EnemyType: ENEMY_TYPE =
struct
datatype variant = PATROL_SLIME | FOLLOW_SLIME | STRAIGHT_BAT
datatype variant = PATROL_SLIME | FOLLOW_SLIME | STRAIGHT_BAT | SHIELD_SLIME
datatype bat_dir_y = UP | DOWN
@@ -48,6 +49,7 @@ struct
, batMaxY: int
, batMinY: int
, facing: EntityType.facing
, shieldOn: bool
}
type falling_enemy = {x: int, y: int, variant: variant}

View File

@@ -86,6 +86,7 @@ struct
PATROL_SLIME => (0.5, 0.5, 1.0)
| FOLLOW_SLIME => (1.0, 0.5, 0.5)
| STRAIGHT_BAT => (0.55, 0.55, 0.55)
| SHIELD_SLIME => (0.33, 0.33, 0.11)
in
if wratio < hratio then
let