[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pacmacs 8fd7660240 290/472: Terrify ghosts by eating big p
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pacmacs 8fd7660240 290/472: Terrify ghosts by eating big pill (#153) |
Date: |
Thu, 6 Jan 2022 21:59:32 -0500 (EST) |
branch: elpa/pacmacs
commit 8fd766024088e24d6b83ed9867edc1ddf8e2ad70
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>
Terrify ghosts by eating big pill (#153)
---
pacmacs.el | 60 +++++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 47 insertions(+), 13 deletions(-)
diff --git a/pacmacs.el b/pacmacs.el
index 3b444f6696..ef4b9a6a91 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -131,18 +131,18 @@
:column column
:type 'wall))
-(defun pacmacs--make-pill (row column anim-name points)
+(defun pacmacs--make-pill (row column anim-name points type)
(list :current-animation (pacmacs-load-anim anim-name)
:row row
:column column
- :type 'pill
+ :type type
:points points))
(defun pacmacs--make-regular-pill (row column)
- (pacmacs--make-pill row column "Pill" 10))
+ (pacmacs--make-pill row column "Pill" 10 'pill))
(defun pacmacs--make-big-pill (row column)
- (pacmacs--make-pill row column "Big-Pill" 50))
+ (pacmacs--make-pill row column "Big-Pill" 50 'big-pill))
(defun pacmacs--switch-direction-animation-callback (animation-prefix)
(let ((direction-animations (-mapcat
@@ -236,8 +236,11 @@
row column 'wall))
(defun pacmacs--pill-at-p (row column)
- (pacmacs--object-type-at-p pacmacs--object-board
- row column 'pill))
+ (-if-let (pill (pacmacs--object-type-at-p pacmacs--object-board
+ row column 'pill))
+ pill
+ (pacmacs--object-type-at-p pacmacs--object-board
+ row column 'big-pill)))
(defun pacmacs--ghost-at-p (row column)
(pacmacs--object-type-at-p pacmacs--object-board
@@ -380,14 +383,42 @@
(defun pacmacs--step-terrified-ghosts ()
(dolist (terrified-ghost pacmacs--terrified-ghosts)
+ (-when-let (direction (pacmacs--run-away-direction
+ terrified-ghost
+ pacmacs--player-state))
+ (pacmacs--switch-direction terrified-ghost direction))
+ (pacmacs--step-object terrified-ghost)))
+
+(defun pacmacs--create-game-object (row column list-name constructor)
+ (let ((game-object (funcall constructor row column)))
+ (add-to-list list-name game-object)
+ (pacmacs--put-object game-object)))
+
+(defun pacmacs--create-terrified-ghost (row column)
+ (pacmacs--create-game-object row column 'pacmacs--terrified-ghosts
+ #'pacmacs--make-terrified-ghost))
+
+(defun pacmacs--create-ghost (row column)
+ (pacmacs--create-game-object row column 'pacmacs--ghosts
+ #'pacmacs--make-ghost))
+
+
+(defun pacmacs--replace-game-objects (list-name replacing-constructor)
+ (dolist (game-object (symbol-value list-name))
(plist-bind ((row :row)
(column :column))
- terrified-ghost
- (-when-let (direction (pacmacs--run-away-direction
- terrified-ghost
- pacmacs--player-state))
- (pacmacs--switch-direction terrified-ghost direction))
- (pacmacs--step-object terrified-ghost))))
+ game-object
+ (funcall replacing-constructor row column))
+ (pacmacs--remove-object game-object))
+ (set list-name nil))
+
+(defun pacmacs--terrify-all-ghosts ()
+ (pacmacs--replace-game-objects 'pacmacs--ghosts
+ #'pacmacs--create-terrified-ghost))
+
+(defun pacmacs--unterrify-all-ghosts ()
+ (pacmacs--replace-game-objects 'pacmacs--terrified-ghosts
+ #'pacmacs--create-ghost))
(defun pacmacs--detect-pill-collision ()
(plist-bind ((row :row)
@@ -396,7 +427,10 @@
(-when-let (pill (pacmacs--pill-at-p row column))
(setq pacmacs-score (+ pacmacs-score (plist-get pill :points)))
(setq pacmacs--pills (-remove (-partial #'eql pill) pacmacs--pills))
- (pacmacs--remove-object pill))))
+ (pacmacs--remove-object pill)
+
+ (when (equal (plist-get pill :type) 'big-pill)
+ (pacmacs--terrify-all-ghosts)))))
(defun pacmacs--ghost-collision-p ()
(plist-bind ((row :row)
- [nongnu] elpa/pacmacs 1ab8264214 198/472: Remove dead vars for board size (#126), (continued)
- [nongnu] elpa/pacmacs 1ab8264214 198/472: Remove dead vars for board size (#126), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 144a973d83 203/472: Merge branch 'slow-object-look-up-126'. Close #126, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 6a4bf8c87f 214/472: Merge branch 'integration-test-recorder-115'. Close #115, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs b73dd8215c 220/472: Merge branch 'integration-test-replayer-122'. Close #122, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1eadfb94fd 225/472: Refactor out pacmacs--wall-cells list (#81), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 843d428744 226/472: Refactor out pacmacs--big-pills list (#81), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 7eafd1bf11 017/472: Merge branch 'split-merged-modules-19'. Close #19, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs f88ea61b10 035/472: Merge branch 'ut-coverage-27'. Close #27, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 9acb9eefa4 286/472: Introduce a constructor for terrified ghosts (#153), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 25193bcdbf 289/472: Better running away algorithm (#153), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 8fd7660240 290/472: Terrify ghosts by eating big pill (#153),
ELPA Syncer <=
- [nongnu] elpa/pacmacs e4e4053c26 306/472: Ghost terrified time as constant (#159), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1978363e9d 310/472: Fix handle-ghost-blinking-threshold (#159), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs a896a83366 312/472: Merge pull request #164 from codingteam/blink-almost-timed-out-159, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs d3c94de6da 320/472: Remove UT for pacmacs--track-point (#159), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 8b40dc51cf 330/472: Add 1st big pill level (#162), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 49292e34d3 342/472: UT for terrified-ghost-timed-out-p function (#171), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 40a3d00209 367/472: Implement glowing walls (#138), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 5c45e17c40 399/472: Add docs for destroy function (#134), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs f79355209d 060/472: Refactor out functions for creating images (#51), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 080aae5f08 070/472: Use plist-bind for pacman-anim-next-frame function (#54), ELPA Syncer, 2022/01/06