[plt-scheme] thanks, but help again

From: Connor Ferguson (psfreak at linkline.com)
Date: Wed Mar 24 20:39:29 EST 2004

Hey everybody-

Thanks especially to Matthias and Bruce and mathematica for your help. My
science project of the UFO game (from HTDP) has been chosen to compete in
the Los Angeles County Science Fair on April 13.

While I¹m very happy about this, I am still having some problems. Whenever I
successfully modify hit-shot? to register the UFO as hit when it passes
through, it also classifies as hit when the shot has already passed and
missed and the UFO moves back to the line that the shot traveled. Below is
my function for hit-shot? If anyone could take a look at it and please tell
me where I may be going wrong, that would be great.

;; hit-shot? : shot/f ufo -> boolean
(define (hit-shot? shot/f ufo)
   [ (boolean? shot/f) false]
   [ else     
      [ (and (>= (+ (posn-x (ufo-nw ufo)) 22)
                (posn-x (shot-posn shot/f)))
            (<= (posn-x (ufo-nw ufo))
                (+ (posn-x (shot-posn shot/f)) 2))
            (>= (posn-y (ufo-nw ufo))
                (posn-y (shot-posn shot/f)))
            (>= (posn-y (ufo-nw ufo))
                (+ (posn-y (shot-posn shot/f)) 5))) true]
      [ else false])]))

Thanks again

Posted on the users mailing list.