emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/pacmacs cfa4437107 292/472: Implement eating terrified gho


From: ELPA Syncer
Subject: [nongnu] elpa/pacmacs cfa4437107 292/472: Implement eating terrified ghosts (#153)
Date: Thu, 6 Jan 2022 21:59:33 -0500 (EST)

branch: elpa/pacmacs
commit cfa44371072312167fc5a62167c3454b02d73cf8
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>

    Implement eating terrified ghosts (#153)
---
 pacmacs.el | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/pacmacs.el b/pacmacs.el
index 20483bceb2..ca0d16ae8f 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -253,6 +253,10 @@
   (pacmacs--object-type-at-p pacmacs--object-board
                              row column 'ghost))
 
+(defun pacmacs--terrified-ghost-at-p (row column)
+  (pacmacs--object-type-at-p pacmacs--object-board
+                             row column 'terrified-ghost))
+
 (defun pacmacs-quit ()
   (interactive)
   (when (get-buffer pacmacs-buffer-name)
@@ -455,6 +459,16 @@
       (when (equal (plist-get pill :type) 'big-pill)
         (pacmacs--terrify-all-ghosts)))))
 
+(defun pacmacs--detect-terrified-ghost-collision ()
+  (plist-bind ((row :row)
+               (column :column))
+      pacmacs--player-state
+    (-when-let (terrified-ghost (pacmacs--terrified-ghost-at-p row column))
+      (setq pacmacs-score (+ pacmacs-score 200))
+      (setq pacmacs--terrified-ghosts (-remove (-partial #'eql terrified-ghost)
+                                               pacmacs--terrified-ghosts))
+      (pacmacs--remove-object terrified-ghost))))
+
 (defun pacmacs--ghost-collision-p ()
   (plist-bind ((row :row)
                (column :column))
@@ -473,12 +487,14 @@
     (if pacmacs--pills
         (progn
           (pacmacs--step-object pacmacs--player-state)
+          (pacmacs--detect-terrified-ghost-collision)
           (if (pacmacs--ghost-collision-p)
               (progn (pacmacs--step-back-object pacmacs--player-state)
                      (pacmacs--switch-to-death-state))
             (pacmacs--detect-pill-collision)
             (pacmacs--step-ghosts)
             (pacmacs--step-terrified-ghosts)
+            (pacmacs--detect-terrified-ghost-collision)
             (pacmacs--decrease-terrified-timers)
             (when (pacmacs--ghost-collision-p)
               (dolist (ghost pacmacs--ghosts)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]