Created
April 26, 2018 01:21
-
-
Save mdsib/4e788728eb188b71a2669ba760fe82dd to your computer and use it in GitHub Desktop.
URN (not clojure) drawing all love2d shapes associated with physics body
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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