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

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

[nongnu] elpa/pacmacs 4341b23d87 094/472: Implement wraparound. Close #6


From: ELPA Syncer
Subject: [nongnu] elpa/pacmacs 4341b23d87 094/472: Implement wraparound. Close #67
Date: Thu, 6 Jan 2022 21:59:15 -0500 (EST)

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

    Implement wraparound. Close #67
---
 maps/map02.txt | 12 ++++++++++++
 pacmacs.el     | 11 ++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/maps/map02.txt b/maps/map02.txt
new file mode 100644
index 0000000000..dd7db15c48
--- /dev/null
+++ b/maps/map02.txt
@@ -0,0 +1,12 @@
+#### ####
+#       #
+# ## ## #
+#       #
+# ## ## #
+#       #
+# ## ## #
+    o    
+# ## ## #
+#       #
+#g      #
+#### ####
diff --git a/pacmacs.el b/pacmacs.el
index 90ec5badb1..ad805c2575 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -89,7 +89,7 @@
   (interactive)
   (switch-to-buffer-other-window pacmacs-buffer-name)
   (pacmacs-mode)
-  (pacmacs-load-map "map01")
+  (pacmacs-load-map "map02")
   (unless pacmacs-timer
     (setq pacmacs-timer (run-at-time nil (* pacmacs-tick-duration-ms 0.001) 
'pacmacs-tick))))
 
@@ -197,11 +197,12 @@
       game-object
     (if (zerop speed-counter)
         (let* ((velocity (plist-get pacmacs-direction-table direction))
-               (new-row (+ row (cdr velocity)))
-               (new-column (+ column (car velocity))))
+               (new-row (mod (+ row (cdr velocity))
+                             pacmacs-board-height))
+               (new-column (mod (+ column (car velocity))
+                                pacmacs-board-width)))
           (plist-put game-object :speed-counter speed)
-          (when (and (pacmacs--within-of-map-p new-row new-column)
-                     (not (pacmacs--wall-at-p new-row new-column)))
+          (when (not (pacmacs--wall-at-p new-row new-column))
             (plist-put game-object :row new-row)
             (plist-put game-object :column new-column)))
       (plist-put game-object :speed-counter (1- speed-counter)))))



reply via email to

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