2048: add helper functions for swipe motions
This commit is contained in:
parent
aee5de5743
commit
66a471dc51
20
lisp/2048.el
20
lisp/2048.el
@ -337,6 +337,15 @@ individually."
|
||||
(defun 2048-shift-up () (interactive) (2048-shift "u"))
|
||||
(defun 2048-shift-down () (interactive) (2048-shift "d"))
|
||||
|
||||
(defun 2048--scroll-left (&optional arg set-minmum)
|
||||
(interactive) (2048-shift-left))
|
||||
(defun 2048--scroll-right (&optional arg set-minmum)
|
||||
(interactive) (2048-shift-right))
|
||||
(defun 2048--scroll-up (&optional arg set-minmum)
|
||||
(interactive) (2048-shift-up))
|
||||
(defun 2048--scroll-down (&optional arg set-minmum)
|
||||
(interactive) (2048-shift-down))
|
||||
|
||||
(defun 2048-startup ()
|
||||
"Starts up the game mode for 2048!"
|
||||
(interactive)
|
||||
@ -345,8 +354,7 @@ individually."
|
||||
(setq 2048-board-old (make-vector 2048--board-size 0))
|
||||
(dotimes (i 2048--board-size) (aset 2048-board-old i (make-vector 2048--board-size 0)) )
|
||||
(dotimes (i 2) (2048-spawn))
|
||||
(2048-draw-board)
|
||||
)
|
||||
(2048-draw-board))
|
||||
|
||||
(define-derived-mode 2048-mode fundamental-mode "2048"
|
||||
"Major mode for playing 2048 in Emacs."
|
||||
@ -362,10 +370,10 @@ individually."
|
||||
(local-set-key (kbd "j") '2048-shift-down)
|
||||
(local-set-key (kbd "k") '2048-shift-up)
|
||||
;; Swipe controls for termux
|
||||
(setq-local mwheel-scroll-left-function '2048-shift-left)
|
||||
(setq-local mwheel-scroll-right-function '2048-shift-right)
|
||||
(setq-local mwheel-scroll-down-function '2048-shift-down)
|
||||
(setq-local mwheel-scroll-up-function '2048-shift-up)
|
||||
(setq-local mwheel-scroll-left-function '2048-scroll-left)
|
||||
(setq-local mwheel-scroll-right-function '2048-scroll-right)
|
||||
(setq-local mwheel-scroll-down-function '2048-scroll-down)
|
||||
(setq-local mwheel-scroll-up-function '2048-scroll-up)
|
||||
|
||||
(2048-startup)
|
||||
(setq font-lock-defaults '(2048-highlights)))
|
||||
|
Loading…
Reference in New Issue
Block a user