comparison lisp/play/blackbox.el @ 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 695cf19ef79e
children eaa9acd9122c cce1c0ee76ee
comparison
equal deleted inserted replaced
56988:c3cd33490e14 56989:7cbddcabb63e
333 (t 333 (t
334 (setq bb-balls-placed (cons coord bb-balls-placed)) 334 (setq bb-balls-placed (cons coord bb-balls-placed))
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
369 ((and (not first) 370 ((and (not first)
370 (bb-outside-box x y)) 371 (bb-outside-box x y))