Skip to content

Commit

Permalink
Quit Game Over state with q key (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
rexim committed Jan 16, 2016
1 parent 23d315e commit 447882d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pacmacs.el
Expand Up @@ -95,7 +95,7 @@
:type '(radio (const :tag "Default path")
(directory :tag "Custom path")))

(define-derived-mode pacmacs-mode special-mode "pacmacs-mode"
(define-derived-mode pacmacs-mode special-mode "Pacmacs"
(define-key pacmacs-mode-map (kbd "<up>") 'pacmacs-up)
(define-key pacmacs-mode-map (kbd "<down>") 'pacmacs-down)
(define-key pacmacs-mode-map (kbd "<left>") 'pacmacs-left)
Expand All @@ -106,6 +106,11 @@
(setq cursor-type nil)
(setq truncate-lines t))

(define-derived-mode pacmacs-game-over-mode special-mode "Pacmacs Game Over"
(define-key pacmacs-game-over-mode-map (kbd "q") 'pacmacs-quit)
(setq cursor-type nil)
(setq truncate-lines t))

;;;###autoload
(defun pacmacs-start ()
(interactive)
Expand Down Expand Up @@ -589,7 +594,8 @@
(let ((nickname (widget-value widget)))
(pacmacs--add-entry-to-score-table nickname score)
(widget-value-set widget (pacmacs--align-score-record-nickname nickname))
(widget-delete widget))))
(widget-delete widget)
(pacmacs-game-over-mode))))

(defun pacmacs--switch-to-game-over-state ()
(pacmacs--load-map-sign "game-over")
Expand Down Expand Up @@ -623,11 +629,12 @@
(plist-bind ((height :height))
pacmacs--object-board
(goto-char (point-min))
(forward-line (+ height pacmacs--score-table-render-offset new-score-position))))
(forward-line (+ height pacmacs--score-table-render-offset new-score-position)))
(use-local-map widget-keymap)
(widget-setup))
(pacmacs--render-score-table score-table)
(goto-char (point-min)))
(use-local-map widget-keymap)
(widget-setup))))
(goto-char (point-min))
(pacmacs-game-over-mode)))))

(defun pacmacs--switch-to-play-state ()
(setq pacmacs-game-state 'play)
Expand Down

0 comments on commit 447882d

Please sign in to comment.