Add some console roguelikes

This commit is contained in:
Jeremy Dormitzer 2024-04-29 16:24:06 -04:00
parent 7fb37be85f
commit b63422050d
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,41 @@
;; -*- lexical-binding: t; -*-
(defun roguelike-evil-insert ()
(interactive)
(vterm-reset-cursor-point)
(call-interactively #'evil-insert))
(defun roguelike-buffer-setup ()
(setq-local cursor-type 'box
blink-cursor-mode nil
evil-insert-state-cursor 'box
evil-normal-state-cursor 'hollow
evil-motion-state-cursor 'hollow
left-fringe-width 0
right-fringe-width 0)
(evil-local-set-key 'normal (kbd "i") #'roguelike-evil-insert))
(defun play-roguelike (exe)
(unless (executable-find exe)
(user-error "%s is not installed" exe))
(let ((buffer (format "*%s*" exe)))
(when (get-buffer buffer)
(kill-buffer buffer))
(vterm buffer)
(with-current-buffer buffer
(roguelike-buffer-setup)
(vterm-send-string (format "%s; exit" exe))
(vterm-send-return))
(switch-to-buffer buffer)))
(defun nethack ()
(interactive)
(play-roguelike "nethack"))
(defvar crawl-executable (expand-file-name "~/crawl/crawl-ref/source/crawl"))
(defun crawl ()
(interactive)
(play-roguelike crawl-executable))
(provide 'init-games)

View File

@ -121,6 +121,7 @@
(require 'init-wallabag)
(require 'init-plantuml)
(require 'init-mermaid)
(require 'init-games)
(require 'handwriting)
(when (string-equal system-type "darwin")
(require 'init-mac))