(define-key map "\C-f" 'snake-move-right)
(define-key map "\C-p" 'snake-move-up)
(define-key map "\C-n" 'snake-move-down)
- map))
+ map)
+ "Keymap for Snake games.")
(defvar snake-null-map
(let ((map (make-sparse-keymap 'snake-null-map)))
(define-key map "n" 'snake-start-game)
- map))
+ map)
+ "Keymap for finished Snake games.")
+
+(defconst snake--menu-def
+ '("Snake"
+ ["Start new game" snake-start-game
+ :help "Start a new Snake game"]
+ ["End game" snake-end-game
+ :active (snake-active-p)
+ :help "End the current Snake game"]
+ ["Pause" snake-pause-game
+ :active (and (snake-active-p) (not snake-paused))
+ :help "Pause running Snake game"]
+ ["Resume" snake-pause-game
+ :active (and (snake-active-p) snake-paused)
+ :help "Resume paused Snake game"])
+ "Menu for `snake'. Used to initialize menus.")
+
+(easy-menu-define
+ snake-mode-menu snake-mode-map
+ "Menu for running Snake games."
+ snake--menu-def)
+
+(easy-menu-define
+ snake-null-menu snake-null-map
+ "Menu for finished Snake games."
+ snake--menu-def)
;; ;;;;;;;;;;;;;;;; game functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-local-map snake-null-map)
- (unless (featurep 'emacs)
- (setq mode-popup-menu
- '("Snake Commands"
- ["Start new game" snake-start-game]
- ["End game" snake-end-game
- (snake-active-p)]
- ["Pause" snake-pause-game
- (and (snake-active-p) (not snake-paused))]
- ["Resume" snake-pause-game
- (and (snake-active-p) snake-paused)])))
-
(setq gamegrid-use-glyphs snake-use-glyphs-flag)
(setq gamegrid-use-color snake-use-color-flag)