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

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

[nongnu] elpa/pacmacs 0546e964b1 222/472: Connected walls proof of conce


From: ELPA Syncer
Subject: [nongnu] elpa/pacmacs 0546e964b1 222/472: Connected walls proof of concept for #131
Date: Thu, 6 Jan 2022 21:59:26 -0500 (EST)

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

    Connected walls proof of concept for #131
---
 pacmacs-image.el | 39 +++++++++++++++++++++++++++++++++++++++
 pacmacs.el       | 19 ++++++++++++++-----
 2 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/pacmacs-image.el b/pacmacs-image.el
index 25c30034a3..cfcb568712 100644
--- a/pacmacs-image.el
+++ b/pacmacs-image.el
@@ -46,6 +46,45 @@
    :foreground color
    :background color))
 
+(defun pacmacs--create-wall-block (width height color bottom right top left)
+  (let ((wall-block (make-vector
+                     width nil)))
+
+    (dotimes (i width)
+      (aset wall-block i (make-bool-vector height nil)))
+    
+    (when left
+      (dotimes (i height)
+        (aset (aref wall-block i) 0 t)
+        (aset (aref wall-block i) 1 t)
+        (aset (aref wall-block i) 2 t)
+        ))
+
+    (when right
+      (dotimes (i height)
+        (aset (aref wall-block i) (1- width) t)
+        (aset (aref wall-block i) (- width 2) t)
+        (aset (aref wall-block i) (- width 3) t)
+        ))
+
+    (when top
+      (dotimes (i width)
+        (aset (aref wall-block 0) i t)
+        (aset (aref wall-block 1) i t)
+        (aset (aref wall-block 2) i t)
+        ))
+    
+    (when bottom
+      (dotimes (i width)
+        (aset (aref wall-block (1- height)) i t)
+        (aset (aref wall-block (- height 2)) i t)
+        (aset (aref wall-block (- height 3)) i t)
+        ))
+
+    (create-image wall-block 'xbm t :width width :height height
+                  :foreground color
+                  :background nil)))
+
 (defun pacmacs-create-transparent-block (width height)
   (create-image
    (make-vector
diff --git a/pacmacs.el b/pacmacs.el
index 9d6b3f4cb4..f7d90f386b 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -244,10 +244,10 @@
       (plist-put game-object :speed-counter (1- speed-counter)))))
 
 (defun pacmacs--possible-ways (row column)
-  (list (cons (1+ row) column)
-        (cons row (1+ column))
-        (cons (1- row) column)
-        (cons row (1- column))))
+  (list (cons (1+ row) column)          ;down
+        (cons row (1+ column))          ;right
+        (cons (1- row) column)          ;up
+        (cons row (1- column))))        ;left
 
 (defun pacmacs--filter-candidates (p)
   (let ((row (car p))
@@ -456,7 +456,16 @@
           (dotimes (column width)
             (let ((anim-object (car (pacmacs--cell-wrapped-get 
pacmacs--object-board
                                                                row column))))
-              (pacmacs--render-object anim-object)))
+              (plist-bind ((type :type))
+                  anim-object
+                (if (not (equal type 'wall))
+                    (pacmacs--render-object anim-object)
+                  (pacmacs-insert-image (apply #'pacmacs--create-wall-block
+                                               40 40 "blue"
+                                               (-map (-lambda ((row . column))
+                                                       (not 
(pacmacs--wall-at-p row column)))
+                                                     (pacmacs--possible-ways 
row column)))
+                                        '(0 0 40 40))))))
           (insert "\n")))
       (insert "\n")
       (dotimes (i pacmacs-lives)



reply via email to

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