Advertisement
Guest User

Untitled

a guest
May 26th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (use Double)
  2. (use IO)
  3. (load "Vector.carp")
  4. (use Vector2) ;; HERE
  5.  
  6. (defmodule AABB2
  7.  
  8.   (deftype Box
  9.       [center V2
  10.        hwidth Double
  11.        hheight Double])
  12.  
  13. ;;...
  14.  
  15.   (defn corners
  16.     [b]
  17.     (let [center (Box.center b)
  18.           hwidth @(Box.hwidth b)
  19.           hheight @(Box.hheight b)
  20.           tl (V2.init (- (get-x center) hwidth) (+ (get-y center) hheight)) :: HERE V2.init works fine
  21.           tr (V2.init (+ (get-x center) hwidth) (+ (get-y center) hheight))
  22.           bl (V2.init (- (get-x center) hwidth) (- (get-y center) hheight))
  23.           br (V2.init (+ (get-x center) hwidth) (- (get-y center) hheight))]
  24.       [tl tr bl br]))
  25.   )
  26.  
  27. (use AABB2)
  28.  
  29. (defmodule Collision
  30.  
  31. ;;...
  32.  
  33.   (defn mtv
  34.     [b1 b2]
  35.     (let [x-dist (if (< (get-x (Box.center b1)) (get-x (Box.center b2)))
  36.                    (* -1.0 (abs (- (x-max b1) (x-min b2))))
  37.                    (abs (- (x-max b2) (x-min b1))))
  38.           y-dist (if (< (get-y (Box.center b1)) (get-y (Box.center b2)))
  39.                    (* -1.0 (abs (- (y-max b1) (y-min b2))))
  40.                    (abs (- (y-max b2) (y-min b1))))]
  41.       (if (< x-dist y-dist)
  42.         (Vector2.V2.init x-dist 0.0) ;; PROBLEM HERE: Trying to refer to an undefined symbol 'V2.init' at line 106, column 10 in '/home/jallen/dev/carp/collision/collision.carp'. if just V2.init
  43.         (Vector2.V2.init 0.0 y-dist))))
  44.   )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement