;; hackpact day 23 - lego ;; gabor papp http://mndl.hu/hackpact (require "unimotion.ss") (define type (detect-sms)) (clear) (collisions 1) (ground-plane #(0 1 0) 0) (set-max-physical 500) (define lego-colours (map (lambda (c) (list->vector (map (lambda (x) (/ x 255)) c))) (list (list 245 205 47) (list 196 40 27) (list 13 105 171) (list 40 127 70) (list 242 243 242) (list 161 165 162)))) (define lego-bricks (list "meshes/lego1x1.obj" "meshes/lego2x1.obj" "meshes/lego2x2.obj" "meshes/lego4x2.obj")) (define (lego) (let ([p (load-primitive (list-ref lego-bricks (random (length lego-bricks))))] [c (list-ref lego-colours (random (length lego-colours)))]) (with-primitive p (colour c) (translate #(0 40 0))) (active-box p) (kick p (crndvec)))) (gain .04) (every-frame (begin (when (> (gh 2) 1) (lego)) (let ([g (vmul (read-sms-real type) 2)]) (gravity (vector (- (vx g)) -9 (vy g))))))