(define-key map [right] 'tetris-move-right)
(define-key map [up] 'tetris-rotate-prev)
(define-key map [down] 'tetris-move-down)
- map))
+ map)
+ "Keymap for Tetris games.")
(defvar tetris-null-map
(let ((map (make-sparse-keymap 'tetris-null-map)))
(define-key map "n" 'tetris-start-game)
(define-key map "q" 'quit-window)
- map))
+ map)
+ "Keymap for finished Tetris games.")
+
+(defconst tetris--menu-def
+ '("Tetris"
+ ["Start new game" tetris-start-game
+ :help "Start a new Tetris game"]
+ ["End game" tetris-end-game
+ :active (tetris-active-p)
+ :help "End the current Tetris game"]
+ ["Pause" tetris-pause-game
+ :active (and (tetris-active-p) (not tetris-paused))
+ :help "Pause running Tetris game"]
+ ["Resume" tetris-pause-game
+ :active (and (tetris-active-p) tetris-paused)
+ :help "Resume paused Tetris game"])
+ "Menu for `tetris'. Used to initialize menus.")
+
+(easy-menu-define
+ tetris-mode-menu tetris-mode-map
+ "Menu for running Tetris games."
+ tetris--menu-def)
+
+(easy-menu-define
+ tetris-null-menu tetris-null-map
+ "Menu for finished Tetris games."
+ tetris--menu-def)
;; ;;;;;;;;;;;;;;;; game functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-local-map tetris-null-map)
- (unless (featurep 'emacs)
- (setq mode-popup-menu
- '("Tetris Commands"
- ["Start new game" tetris-start-game]
- ["End game" tetris-end-game
- (tetris-active-p)]
- ["Pause" tetris-pause-game
- (and (tetris-active-p) (not tetris-paused))]
- ["Resume" tetris-pause-game
- (and (tetris-active-p) tetris-paused)])))
-
(setq show-trailing-whitespace nil)
(setq gamegrid-use-glyphs tetris-use-glyphs)