Mercurial > emacs
changeset 56989:7cbddcabb63e
(bb-trace-ray): Avoid double tracing.
author | Thien-Thi Nguyen <ttn@gnuvola.org> |
---|---|
date | Wed, 08 Sep 2004 10:07:38 +0000 |
parents | c3cd33490e14 |
children | 8785d3b0ec48 |
files | lisp/play/blackbox.el |
diffstat | 1 files changed, 29 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/play/blackbox.el Wed Sep 08 09:42:42 2004 +0000 +++ b/lisp/play/blackbox.el Wed Sep 08 10:07:38 2004 +0000 @@ -335,34 +335,35 @@ (bb-update-board (propertize "O" 'help-echo "Placed ball")))))) (defun bb-trace-ray (x y) - (let ((result (bb-trace-ray-2 - t - x - (cond - ((= x -1) 1) - ((= x 8) -1) - (t 0)) - y - (cond - ((= y -1) 1) - ((= y 8) -1) - (t 0))))) - (cond - ((eq result 'hit) - (bb-update-board (propertize "H" 'help-echo "Hit")) - (setq bb-score (1+ bb-score))) - ((equal result (cons x y)) - (bb-update-board (propertize "R" 'help-echo "Reflection")) - (setq bb-score (1+ bb-score))) - (t - (setq bb-detour-count (1+ bb-detour-count)) - (bb-update-board (propertize (format "%d" bb-detour-count) - 'help-echo "Detour")) - (save-excursion - (bb-goto result) - (bb-update-board (propertize (format "%d" bb-detour-count) - 'help-echo "Detour"))) - (setq bb-score (+ bb-score 2)))))) + (when (= (following-char) 32) + (let ((result (bb-trace-ray-2 + t + x + (cond + ((= x -1) 1) + ((= x 8) -1) + (t 0)) + y + (cond + ((= y -1) 1) + ((= y 8) -1) + (t 0))))) + (cond + ((eq result 'hit) + (bb-update-board (propertize "H" 'help-echo "Hit")) + (setq bb-score (1+ bb-score))) + ((equal result (cons x y)) + (bb-update-board (propertize "R" 'help-echo "Reflection")) + (setq bb-score (1+ bb-score))) + (t + (setq bb-detour-count (1+ bb-detour-count)) + (bb-update-board (propertize (format "%d" bb-detour-count) + 'help-echo "Detour")) + (save-excursion + (bb-goto result) + (bb-update-board (propertize (format "%d" bb-detour-count) + 'help-echo "Detour"))) + (setq bb-score (+ bb-score 2))))))) (defun bb-trace-ray-2 (first x dx y dy) (cond