aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThien-Thi Nguyen2004-09-08 10:07:38 +0000
committerThien-Thi Nguyen2004-09-08 10:07:38 +0000
commit18a6a2078320c56710beefd3245969527e3fe1de (patch)
tree1a7130e448cf8677cebe93cb3b7e7081bdcd6b9e
parentc2fb92d89a089dce36f52163351834f1c815146b (diff)
downloademacs-18a6a2078320c56710beefd3245969527e3fe1de.tar.gz
emacs-18a6a2078320c56710beefd3245969527e3fe1de.zip
(bb-trace-ray): Avoid double tracing.
-rw-r--r--lisp/play/blackbox.el57
1 files changed, 29 insertions, 28 deletions
diff --git a/lisp/play/blackbox.el b/lisp/play/blackbox.el
index f3933e7ccd2..4d6cbfbeaf8 100644
--- a/lisp/play/blackbox.el
+++ b/lisp/play/blackbox.el
@@ -335,34 +335,35 @@ a reflection."
335 (bb-update-board (propertize "O" 'help-echo "Placed ball")))))) 335 (bb-update-board (propertize "O" 'help-echo "Placed ball"))))))
336 336
337(defun bb-trace-ray (x y) 337(defun bb-trace-ray (x y)
338 (let ((result (bb-trace-ray-2 338 (when (= (following-char) 32)
339 t 339 (let ((result (bb-trace-ray-2
340 x 340 t
341 (cond 341 x
342 ((= x -1) 1) 342 (cond
343 ((= x 8) -1) 343 ((= x -1) 1)
344 (t 0)) 344 ((= x 8) -1)
345 y 345 (t 0))
346 (cond 346 y
347 ((= y -1) 1) 347 (cond
348 ((= y 8) -1) 348 ((= y -1) 1)
349 (t 0))))) 349 ((= y 8) -1)
350 (cond 350 (t 0)))))
351 ((eq result 'hit) 351 (cond
352 (bb-update-board (propertize "H" 'help-echo "Hit")) 352 ((eq result 'hit)
353 (setq bb-score (1+ bb-score))) 353 (bb-update-board (propertize "H" 'help-echo "Hit"))
354 ((equal result (cons x y)) 354 (setq bb-score (1+ bb-score)))
355 (bb-update-board (propertize "R" 'help-echo "Reflection")) 355 ((equal result (cons x y))
356 (setq bb-score (1+ bb-score))) 356 (bb-update-board (propertize "R" 'help-echo "Reflection"))
357 (t 357 (setq bb-score (1+ bb-score)))
358 (setq bb-detour-count (1+ bb-detour-count)) 358 (t
359 (bb-update-board (propertize (format "%d" bb-detour-count) 359 (setq bb-detour-count (1+ bb-detour-count))
360 'help-echo "Detour")) 360 (bb-update-board (propertize (format "%d" bb-detour-count)
361 (save-excursion 361 'help-echo "Detour"))
362 (bb-goto result) 362 (save-excursion
363 (bb-update-board (propertize (format "%d" bb-detour-count) 363 (bb-goto result)
364 'help-echo "Detour"))) 364 (bb-update-board (propertize (format "%d" bb-detour-count)
365 (setq bb-score (+ bb-score 2)))))) 365 'help-echo "Detour")))
366 (setq bb-score (+ bb-score 2)))))))
366 367
367(defun bb-trace-ray-2 (first x dx y dy) 368(defun bb-trace-ray-2 (first x dx y dy)
368 (cond 369 (cond