]> code.delx.au - gnu-emacs/commitdiff
(bb-trace-ray): Avoid double tracing.
authorThien-Thi Nguyen <ttn@gnuvola.org>
Wed, 8 Sep 2004 10:07:38 +0000 (10:07 +0000)
committerThien-Thi Nguyen <ttn@gnuvola.org>
Wed, 8 Sep 2004 10:07:38 +0000 (10:07 +0000)
lisp/play/blackbox.el

index f3933e7ccd210c40f0aa7482528cd9402ccc5a50..4d6cbfbeaf8b7d740baba5451f59a943cdc1100f 100644 (file)
@@ -335,34 +335,35 @@ a reflection."
       (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