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

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

[nongnu] elpa/pacmacs be91d566cb 139/472: Implement Game Over state. Clo


From: ELPA Syncer
Subject: [nongnu] elpa/pacmacs be91d566cb 139/472: Implement Game Over state. Close #94
Date: Thu, 6 Jan 2022 21:59:19 -0500 (EST)

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

    Implement Game Over state. Close #94
---
 maps/game-over.txt | 13 +++++++++++++
 pacmacs.el         | 23 ++++++++++++++++-------
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/maps/game-over.txt b/maps/game-over.txt
new file mode 100644
index 0000000000..7d005bd7d1
--- /dev/null
+++ b/maps/game-over.txt
@@ -0,0 +1,13 @@
+####             
+#  # ### ##### ##
+#    # # # # # # 
+# ## ### # # # ##
+#  # # # # # # # 
+#### # # # # # ##
+                 
+####             
+#  # #  # ## ### 
+#  # #  # #  # # 
+#  # # ## ## ####
+#  # # #  #  #  #
+#### ###  ## #  #
diff --git a/pacmacs.el b/pacmacs.el
index 3b40f3e844..0bf81b8ce2 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -83,11 +83,12 @@
   (define-key pacmacs-mode-map (kbd "<right>") 'pacmacs-right)
   (define-key pacmacs-mode-map (kbd "q") 'pacmacs-quit)
   (add-hook 'kill-buffer-hook 'pacmacs-destroy nil t)
-  (setq cursor-type nil))
+  (setq cursor-type nil)
+  (setq truncate-lines t))
 
 (defun pacmacs-start ()
   (interactive)
-  (switch-to-buffer-other-window pacmacs-buffer-name)
+  (switch-to-buffer pacmacs-buffer-name)
   (pacmacs-mode)
 
   (setq pacmacs-lives 3)
@@ -354,7 +355,9 @@
               (plist-get pacmacs-player-state
                          :current-animation)
               :current-frame))
-    (pacmacs--switch-to-play-state)))
+    (if (<= pacmacs-lives 0)
+        (pacmacs--switch-to-game-over-state)
+      (pacmacs--switch-to-play-state))))
 
 (defun pacmacs-waiting-logic (switcher)
   (if (<= pacmacs-waiting-counter 0)
@@ -372,10 +375,11 @@
     (pacmacs-render-anim anim)))
 
 (defun pacmacs--put-object (anim-object)
-  (plist-bind ((row :row)
-               (column :column))
-      anim-object
-    (pacmacs--cell-set pacmacs-board row column anim-object)))
+  (when anim-object
+    (plist-bind ((row :row)
+                 (column :column))
+        anim-object
+      (pacmacs--cell-set pacmacs-board row column anim-object))))
 
 (defun pacmacs--switch-to-death-state ()
   (setq pacmacs-game-state 'death)
@@ -383,6 +387,10 @@
   (plist-put pacmacs-player-state :current-animation
              (pacmacs-load-anim "Pacman-Death")))
 
+(defun pacmacs--switch-to-game-over-state ()
+  (setq pacmacs-game-state 'game-over)
+  (pacmacs-load-map "game-over"))
+
 (defun pacmacs--switch-to-play-state ()
   (setq pacmacs-game-state 'play)
   (pacmacs--reset-object-position pacmacs-player-state)
@@ -489,6 +497,7 @@
     (setq pacmacs-wall-cells nil)
     (setq pacmacs-pills nil)
     (setq pacmacs-ghosts nil)
+    (setq pacmacs-player-state nil)
 
     (loop
      for line being the element of lines using (index row)



reply via email to

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