comparison lisp/play/blackbox.el @ 47562:56e5df2ccc8d

(bb-right): Respect prefix argument. (bb-left, bb-up, bb-down): Likewise.
author Richard M. Stallman <rms@gnu.org>
date Fri, 20 Sep 2002 18:33:35 +0000
parents 6f3215f24a28
children 0d8b17d428b5
comparison
equal deleted inserted replaced
47561:5bb8339ffc9e 47562:56e5df2ccc8d
1 ;;; blackbox.el --- blackbox game in Emacs Lisp 1 ;;; blackbox.el --- blackbox game in Emacs Lisp
2 2
3 ;; Copyright (C) 1985, 1986, 1987, 1992, 2001 Free Software Foundation, Inc. 3 ;; Copyright (C) 1985, 1986, 1987, 1992, 2001, 2002 Free Software Foundation, Inc.
4 4
5 ;; Author: F. Thomas May <uw-nsr!uw-warp!tom@beaver.cs.washington.edu> 5 ;; Author: F. Thomas May <uw-nsr!uw-warp!tom@beaver.cs.washington.edu>
6 ;; Adapted-By: ESR 6 ;; Adapted-By: ESR
7 ;; Keywords: games 7 ;; Keywords: games
8 8
273 (insert " - - - - - - - - \n")) 273 (insert " - - - - - - - - \n"))
274 (insert " \n") 274 (insert " \n")
275 (insert (format "\nThere are %d balls in the box" (length bb-board))) 275 (insert (format "\nThere are %d balls in the box" (length bb-board)))
276 )) 276 ))
277 277
278 (defun bb-right () 278 (defun bb-right (count)
279 (interactive) 279 (interactive "p")
280 (if (= bb-x 8) 280 (while (and (> count 0) (< bb-x 8))
281 ()
282 (forward-char 2) 281 (forward-char 2)
283 (setq bb-x (1+ bb-x)))) 282 (setq bb-x (1+ bb-x))
284 283 (setq count (1- count))))
285 (defun bb-left () 284
286 (interactive) 285 (defun bb-left (count)
287 (if (= bb-x -1) 286 (interactive "p")
288 () 287 (while (and (> count 0) (> bb-x -1))
289 (backward-char 2) 288 (backward-char 2)
290 (setq bb-x (1- bb-x)))) 289 (setq bb-x (1- bb-x))
291 290 (setq count (1- count))))
292 (defun bb-up () 291
293 (interactive) 292 (defun bb-up (count)
294 (if (= bb-y -1) 293 (interactive "p")
295 () 294 (while (and (> count 0) (> bb-y -1))
296 (previous-line 1) 295 (previous-line 1)
297 (setq bb-y (1- bb-y)))) 296 (setq bb-y (1- bb-y))
298 297 (setq count (1- count))))
299 (defun bb-down () 298
300 (interactive) 299 (defun bb-down (count)
301 (if (= bb-y 8) 300 (interactive "p")
302 () 301 (while (and (> count 0) (< bb-y 8))
303 (next-line 1) 302 (next-line 1)
304 (setq bb-y (1+ bb-y)))) 303 (setq bb-y (1+ bb-y))
304 (setq count (1- count))))
305 305
306 (defun bb-eol () 306 (defun bb-eol ()
307 (interactive) 307 (interactive)
308 (setq bb-x 8) 308 (setq bb-x 8)
309 (bb-goto (cons bb-x bb-y))) 309 (bb-goto (cons bb-x bb-y)))