comparison lisp/play/animate.el @ 88155:d7ddb3e565de

sync with trunk
author Henrik Enberg <henrik.enberg@telia.com>
date Mon, 16 Jan 2006 00:03:54 +0000
parents 0d8b17d428b5
children
comparison
equal deleted inserted replaced
88154:8ce476d3ba36 88155:d7ddb3e565de
1 ;;; animate.el --- make text dance 1 ;;; animate.el --- make text dance
2 2
3 ;; Copyright (C) 2001 Free Software Foundation, Inc. 3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 4
5 ;; Maintainer: Richard Stallman <rms@gnu.org> 5 ;; Maintainer: Richard Stallman <rms@gnu.org>
6 ;; Keywords: games 6 ;; Keywords: games
7 7
8 ;; This file is part of GNU Emacs. 8 ;; This file is part of GNU Emacs.
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details. 18 ;; GNU General Public License for more details.
19 19
20 ;; You should have received a copy of the GNU General Public License 20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02111-1307, USA. 23 ;; Boston, MA 02110-1301, USA.
24 24
25 ;;; Commentary: 25 ;;; Commentary:
26 26
27 ;; (animate-string STRING VPOS &optional HPOS) 27 ;; (animate-string STRING VPOS &optional HPOS)
28 ;; makes the string STRING appear starting at VPOS, HPOS 28 ;; makes the string STRING appear starting at VPOS, HPOS
78 (animate-place-char (car item) vpos hpos))))) 78 (animate-place-char (car item) vpos hpos)))))
79 79
80 ;;; Place the character CHAR at position VPOS, HPOS in the current buffer. 80 ;;; Place the character CHAR at position VPOS, HPOS in the current buffer.
81 (defun animate-place-char (char vpos hpos) 81 (defun animate-place-char (char vpos hpos)
82 (goto-char (window-start)) 82 (goto-char (window-start))
83 (let ((next-line-add-newlines t)) 83 (let (abbrev-mode)
84 (dotimes (i vpos) 84 (dotimes (i vpos)
85 (next-line 1))) 85 (end-of-line)
86 (if (= (forward-line 1) 1)
87 (insert "\n"))))
86 (beginning-of-line) 88 (beginning-of-line)
87 (move-to-column (floor hpos) t) 89 (move-to-column (floor hpos) t)
88 (unless (eolp) (delete-char 1)) 90 (unless (eolp) (delete-char 1))
89 (insert-char char 1)) 91 (insert-char char 1))
90 92
149 (animate-string (car list-of-strings) vpos) 151 (animate-string (car list-of-strings) vpos)
150 (setq vpos (+ vpos space 1)) 152 (setq vpos (+ vpos space 1))
151 (setq list-of-strings (cdr list-of-strings))))) 153 (setq list-of-strings (cdr list-of-strings)))))
152 154
153 ;;;###autoload 155 ;;;###autoload
154 (defun animate-birthday-present () 156 (defun animate-birthday-present (&optional name)
155 "Display Sarah's birthday present in a new buffer." 157 "Display one's birthday present in a new buffer.
156 (interactive) 158 You can specify the one's name by NAME; the default value is \"Sarah\"."
159 (interactive (list (read-string "Name (default Sarah): "
160 nil nil "Sarah")))
157 ;; Make a suitable buffer to display the birthday present in. 161 ;; Make a suitable buffer to display the birthday present in.
158 (switch-to-buffer (get-buffer-create "*Sarah*")) 162 (switch-to-buffer (get-buffer-create (format "*%s*" name)))
159 (erase-buffer) 163 (erase-buffer)
160 ;; Display the empty buffer. 164 ;; Display the empty buffer.
161 (sit-for 0) 165 (sit-for 0)
162 ;; Make sure indentation does not use tabs. 166 ;; Make sure indentation does not use tabs.
163 ;; They would confuse things. 167 ;; They would confuse things.
164 (setq indent-tabs-mode nil) 168 (setq indent-tabs-mode nil)
165 169
166 (animate-string "Happy Birthday," 6) 170 (animate-string "Happy Birthday," 6)
167 (animate-string "Sarah" 7) 171 (animate-string (format "%s" name) 7)
168 172
169 (sit-for 1) 173 (sit-for 1)
170 174
171 (animate-string "You are my sunshine," 10 30) 175 (animate-string "You are my sunshine," 10 30)
172 (sit-for .5) 176 (sit-for .5)
182 (sit-for .5) 186 (sit-for .5)
183 (animate-string "Please bring back" 17 30) 187 (animate-string "Please bring back" 17 30)
184 (animate-string "my sunshine" 18 34) 188 (animate-string "my sunshine" 18 34)
185 (animate-string "to stay!" 19 34)) 189 (animate-string "to stay!" 19 34))
186 190
191 ;;; arch-tag: 275289a3-6ac4-41da-b527-a1147045392f
187 ;;; animate.el ends here 192 ;;; animate.el ends here