From 7a8af18d0e1003c26eb595b5faa71e51da6286a6 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Mon, 17 Apr 2023 23:41:35 +0100 Subject: Added new shooter enemy --- src/Game/Entities.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/Game/Entities.hs') diff --git a/src/Game/Entities.hs b/src/Game/Entities.hs index 6506a60..25a7184 100644 --- a/src/Game/Entities.hs +++ b/src/Game/Entities.hs @@ -16,6 +16,7 @@ import Data.Foldable (find, traverse_) import Data.IORef import Data.List (sort) import qualified Game.Controller as C +import Game.Entities.Blast import Game.Entities.Common import Game.Entities.Const import Game.Entities.Effect @@ -24,6 +25,7 @@ import Game.Entities.Exit import Game.Entities.Pickup import Game.Entities.Player import Game.Entities.Robot +import Game.Entities.Shooter import Game.Entities.Slime import Game.Entities.Types import qualified Game.Map as M @@ -46,6 +48,7 @@ mkEntities sprites m controls = do toEntity :: IORef Entity -> M.Object -> IO Entity toEntity playerRef (M.SlimeEntity x y d) = mkSlime sprites x y d (collision playerRef 16) (M.isBlocked m) toEntity playerRef (M.RobotEntity x y d) = mkRobot sprites x y d (collision playerRef 24) (M.isBlocked m) + toEntity playerRef (M.ShooterEntity x y d) = mkShooter sprites x y d (collision playerRef 24) (inLine playerRef 24) (M.isBlocked m) (collision playerRef 8) toEntity playerRef (M.BatteryEntity x y) = mkBattery sprites x y (collision playerRef 16) toEntity _ (M.PlayerEntity _ _) = error "Player already processed" @@ -110,6 +113,9 @@ updateAll es state = do t ActionEntryDone -> processActions s {GS.levelCompleted = GS.ExitOff} ents t ActionExitDone -> processActions s {GS.levelCompleted = GS.ExitDone} ents t + ActionAddBlast x y d playerCollision isBlocked -> do + blast <- mkBlast es.sprites x y d playerCollision isBlocked + processActions s (ents ++ [blast]) t processActions s ents [] = pure (s, ents) -- Update entities skipping enemies if the player was hit -- cgit v1.2.3