diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-03-21 21:28:25 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-03-21 21:28:25 +0000 |
commit | 11d2ed7f15a86dd465bc3456e3478e9ff03bf5d2 (patch) | |
tree | f5e6df771eb4396df13fe3cdc2d98721917a2d68 /src/Game/Entities/Robot.hs | |
parent | 1c8a22d24b14d258a9103f7b83d627359eae0da8 (diff) | |
download | space-plat-hs-11d2ed7f15a86dd465bc3456e3478e9ff03bf5d2.tar.gz space-plat-hs-11d2ed7f15a86dd465bc3456e3478e9ff03bf5d2.zip |
Introduce a set property
Stopped abusing the direction property!
Diffstat (limited to 'src/Game/Entities/Robot.hs')
-rw-r--r-- | src/Game/Entities/Robot.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Game/Entities/Robot.hs b/src/Game/Entities/Robot.hs index dd3404a..44fc310 100644 --- a/src/Game/Entities/Robot.hs +++ b/src/Game/Entities/Robot.hs @@ -16,6 +16,7 @@ mkRobot sprites x y playerCollision isBlocked = do y = y, delay = frameDelay, frame = 0, + set = toSpriteSet DirRight, jumping = False, gravity = gravityOff, dir = DirRight, @@ -36,10 +37,10 @@ updateRobot touchedPlayer isBlocked e = do | testBit ent.delay 1 = ent | ent.dir == DirLeft && (isBlocked (ent.x - 1) (ent.y + 17) || isBlocked (ent.x - 1) (ent.y + 17) || not (isBlocked (ent.x - 1) (ent.y + 24))) = - ent {dir = DirRight} + ent {dir = DirRight, set = toSpriteSet DirRight} | ent.dir == DirLeft = ent {x = ent.x - 1} | ent.dir == DirRight && (isBlocked (ent.x + 16) (ent.y + 17) || isBlocked (ent.x + 16) (ent.y + 17) || not (isBlocked (ent.x + 16) (ent.y + 24))) = - ent {dir = DirLeft} + ent {dir = DirLeft, set = toSpriteSet DirLeft} | ent.dir == DirRight = ent {x = ent.x + 1} | otherwise = ent |