[ create a new paste ] login | about

Link: http://codepad.org/BnlaMbxu    [ raw code | output | fork ]

hurracane - Scheme, pasted on Dec 15:
(define (touchingOtherObjects? obj listOfObjects)
  ;currently only works with circular objects
  (if (not (eq? (obj 'getType) 'circle))
      (println "can only check for touching objects when said object is a circle, in touchingOtherObjects?, vectors.rkt"))
  
  (define origin (obj 'getOrigin))
  (define (iter lst-remaining)
    (if (null? lst-remaining)
        #f
        (let ((otherObj (car lst-remaining)))
          (cond ((eq? otherObj obj)
                 (iter (cdr lst-remaining)))
                ((not (eq? (otherObj 'getType)
                           'circle))
                 (iter (cdr lst-remaining)))
                (else (let* ((otherOrig (otherObj 'getOrigin))
                             (dist-in-radius (+ (obj 'getRadius)
                                                (otherObj 'getRadius)))
                             (dist ((calcVec 'getDistance) origin otherOrig)))
                        (if (or (< dist dist-in-radius)
                                (eq? dist dist-in-radius))
                            #t
                            (iter (cdr lst-remaining)))))))))
  (iter listOfObjects))


Output:
1
Line 6:2: define: not allowed in an expression context in: (define origin (obj (quote getOrigin)))


Create a new paste based on this one


Comments: