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

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

[nongnu] elpa/pacmacs 9cb186f10a 137/472: Refactor pacmacs-inversed-dire


From: ELPA Syncer
Subject: [nongnu] elpa/pacmacs 9cb186f10a 137/472: Refactor pacmacs-inversed-direction-table out. Close #103
Date: Thu, 6 Jan 2022 21:59:19 -0500 (EST)

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

    Refactor pacmacs-inversed-direction-table out. Close #103
---
 pacmacs-utils.el |  8 ++++++++
 pacmacs.el       | 11 +----------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/pacmacs-utils.el b/pacmacs-utils.el
index 9d649bcb5a..f8301b5b62 100644
--- a/pacmacs-utils.el
+++ b/pacmacs-utils.el
@@ -57,6 +57,14 @@ side-effects."
                                'down  (cons  1  0))))
     (plist-get direction-table direction)))
 
+(defun pacmacs--direction-name (direction-vector)
+  (let ((direction-table '((( 0 . -1) . left)
+                           (( 0 .  1) . right)
+                           ((-1 .  0) . up)
+                           (( 1 .  0) . down))))
+    (cdr (assoc direction-vector
+                direction-table))))
+
 (provide 'pacmacs-utils)
 
 ;;; pacmacs.el ends here
diff --git a/pacmacs.el b/pacmacs.el
index 278f92a241..41de38e4ef 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -53,13 +53,6 @@
 (defvar pacmacs-board-height 10)
 (defvar pacmacs-score 0)
 
-(defvar pacmacs-inversed-direction-table nil)
-(setq pacmacs-inversed-direction-table
-      (list (cons (cons -1 0) 'left)
-            (cons (cons 1 0) 'right)
-            (cons (cons 0 -1) 'up)
-            (cons (cons 0 1) 'down)))
-
 (defvar pacmacs-player-state nil)
 
 (defvar pacmacs-ghosts nil)
@@ -260,9 +253,7 @@
     
     (pacmacs--cell-set pacmacs-track-board
                        start-row start-column
-                       (cdr
-                        (assoc (cons d-column d-row)
-                               pacmacs-inversed-direction-table)))))
+                       (pacmacs--direction-name (cons d-row d-column)))))
 
 (defun pacmacs--recalc-track-board ()
   (pacmacs--fill-board pacmacs-track-board nil)



reply via email to

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