123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- ;; If the game is paused, then move the snake left.
- ;; If the game is already paused, move the snake one square.
- (defun my/snake-move-up ()
- (interactive)
- (if snake-paused
- (progn
- (snake-pause-game)
- (snake-move-up)
- (snake-update-game "*Snake*")
- (snake-pause-game))
- (progn
- (snake-move-up)
- (snake-update-game "*Snake*")
- (snake-pause-game))))
- (defun my/snake-move-down ()
- (interactive)
- (if snake-paused
- (progn
- (snake-pause-game)
- (snake-move-down)
- (snake-update-game "*Snake*")
- (snake-pause-game))
- (progn
- (snake-move-down)
- (snake-update-game "*Snake*")
- (snake-pause-game))))
- (defun my/snake-move-left ()
- (interactive)
- (if snake-paused
- (progn
- (snake-pause-game)
- (snake-move-left)
- (snake-update-game "*Snake*")
- (snake-pause-game))
- (progn
- (snake-move-left)
- (snake-update-game "*Snake*")
- (snake-pause-game))))
- (defun my/snake-move-right ()
- (interactive)
- (if snake-paused
- (progn
- (snake-pause-game)
- (snake-move-right)
- (snake-update-game "*Snake*")
- (snake-pause-game))
- (progn
- (snake-move-right)
- (snake-update-game "*Snake*")
- (snake-pause-game))))
- ;; call a new snake game and in some new keybindings
- (defun my/snake ()
- (interactive)
- (define-key snake-mode-map (kbd "t") 'my/snake-move-down)
- (define-key snake-mode-map (kbd "c") 'my/snake-move-up)
- (define-key snake-mode-map (kbd "h") 'my/snake-move-left)
- (define-key snake-mode-map (kbd "n") 'my/snake-move-right)
- (snake))
|