Skip to content

Instantly share code, notes, and snippets.

@mdsib
Created April 26, 2018 01:21
Show Gist options
  • Save mdsib/4e788728eb188b71a2669ba760fe82dd to your computer and use it in GitHub Desktop.
Save mdsib/4e788728eb188b71a2669ba760fe82dd to your computer and use it in GitHub Desktop.
URN (not clojure) drawing all love2d shapes associated with physics body
(defun draw-shapes (body)
;; get all fixture shapes as world points and the shape type
;; check type, draw according to things
(do [(shape (map (lambda (fixture) (self fixture :getShape)) (values (self body :getFixtures))))]
(love/graphics/set-color 1 0 0 0.1)
(case (self shape :getType)
["polygon" (love/graphics/polygon
"fill"
(self body :getWorldPoints (self shape :getPoints)))]
["circle" (love/graphics/circle
"fill"
(self body :getWorldPoint (self shape :getPoint))
(self shape :getRadius))]
[true (print! "no match, hmm...")])
(love/graphics/set-color 1 1 1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment