[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pacmacs 16b0d6583a 153/472: Get rid of the hardcoded level
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pacmacs 16b0d6583a 153/472: Get rid of the hardcoded level list. Close #109 |
Date: |
Thu, 6 Jan 2022 21:59:20 -0500 (EST) |
branch: elpa/pacmacs
commit 16b0d6583a1d56de6f92d1b6138ba6ec7d0696ce
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>
Get rid of the hardcoded level list. Close #109
---
pacmacs-utils.el | 4 ++++
pacmacs.el | 13 ++++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/pacmacs-utils.el b/pacmacs-utils.el
index 798e7b4d31..ad5b31aa2a 100644
--- a/pacmacs-utils.el
+++ b/pacmacs-utils.el
@@ -70,6 +70,10 @@ side-effects."
(insert-file-contents filename)
(buffer-string)))
+(defun pacmacs--levelname-from-filename (filename)
+ (string-match "\\(map[0-9]+\\)\\.txt" filename)
+ (match-string 1 filename))
+
(provide 'pacmacs-utils)
;;; pacmacs.el ends here
diff --git a/pacmacs.el b/pacmacs.el
index 07c0546e80..114e2fa2bc 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -68,9 +68,7 @@
(defvar pacmacs-lives 3)
-
-(defvar pacmacs-levels ["map01" "map02" "map03"
- "map04" "map05" "map06"])
+(defvar pacmacs-levels nil)
(defvar pacmacs-current-level 0)
(defvar pacmacs-waiting-counter 0)
@@ -92,7 +90,9 @@
(setq pacmacs-lives 3)
(setq pacmacs-score 0)
+ (setq pacmacs-levels (pacmacs--get-list-of-levels))
(setq pacmacs-current-level 0)
+
(pacmacs--load-current-level)
(pacmacs--switch-to-play-state)
@@ -455,6 +455,13 @@
(when (equal pacmacs-game-state 'play)
(pacmacs--switch-direction pacmacs-player-state 'right)))
+(defun pacmacs--get-list-of-levels ()
+ (->> (directory-files "./maps/")
+ (-map #'pacmacs--levelname-from-filename)
+ (-remove #'null)
+ (-sort #'string-lessp)
+ (apply #'vector)))
+
(defun pacmacs-load-map (map-name)
(let* ((lines (split-string (pacmacs--file-content (format "maps/%s.txt"
map-name)) "\n" t))
(board-width (apply 'max (mapcar #'length lines)))
- [nongnu] elpa/pacmacs 85069784fb 147/472: Add a couple of new maps., (continued)
- [nongnu] elpa/pacmacs 85069784fb 147/472: Add a couple of new maps., ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 39fc09baf3 161/472: Load cl-lib.el for using its macros and functions, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 9ddaedae20 174/472: UT for pacmacs--file-content-test, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs b6141dc8e3 175/472: UT for pacmacs--anim-object-list-next-frame, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1186dcdaa1 197/472: Double dash pacmacs-render-state function (#126), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 57b0e8566b 204/472: Get pacmacs-quit back, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 531386d7f1 208/472: Merge pull request #128 from rexim/readme-fix, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 775a2d3ec5 211/472: Convert recorder module to a tool (#115), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs a0d9c1bbbc 212/472: Reverse test case before saving (#115), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs d5bdd0b20a 025/472: Slightly refactored pacman-anim:, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 16b0d6583a 153/472: Get rid of the hardcoded level list. Close #109,
ELPA Syncer <=
- [nongnu] elpa/pacmacs 68f6dc9a93 167/472: Update MELPA repo link, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs fe837b20fa 184/472: Implement victory animation for ghosts. Close #89, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 09ad044887 232/472: Better color for walls (#131), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 9c69162781 247/472: Rough implementation of XPM wall generation (#141), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 4a94a72dd4 250/472: Remove generate-wall-tiles script tool (#141), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs eab5b98b05 254/472: Add average-tick-time function, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 4bd94d2058 255/472: Merge branch 'master' into big-pills-81, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs b97248f316 258/472: Put regular and big pills to same list (#81), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 2473e65744 268/472: Remove dead left overs of #141, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 22355a4954 276/472: Add Terrified Ghost animation. Close #83, ELPA Syncer, 2022/01/06