Mercurial > cortex
comparison org/cortex.org @ 15:c32f3eb9fdeb
modified fire-cannon-ball to place the ball on a specific node
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 23 Oct 2011 11:50:17 -0700 |
parents | e3c6d1c1cb00 |
children | 01e1427126af |
comparison
equal
deleted
inserted
replaced
14:3aa1ee6c6308 | 15:c32f3eb9fdeb |
---|---|
635 (let [options (merge base-shape options)] | 635 (let [options (merge base-shape options)] |
636 (make-shape (assoc options | 636 (make-shape (assoc options |
637 :shape (Sphere. 32 32 (float r)))))) | 637 :shape (Sphere. 32 32 (float r)))))) |
638 ([] (sphere 0.5))) | 638 ([] (sphere 0.5))) |
639 | 639 |
640 (defn add-element [game node] | 640 (defn add-element |
641 ([game element node] | |
641 (.addAll | 642 (.addAll |
642 (.getPhysicsSpace | 643 (.getPhysicsSpace |
643 (.getState | 644 (.getState |
644 (.getStateManager game) | 645 (.getStateManager game) |
645 BulletAppState)) | 646 BulletAppState)) |
646 node) | 647 element) |
647 (.attachChild (.getRootNode game) node)) | 648 (.attachChild node element)) |
649 ([game element] | |
650 (add-element game element (.getRootNode game)))) | |
651 | |
648 | 652 |
649 (defn set-gravity* | 653 (defn set-gravity* |
650 [game gravity] | 654 [game gravity] |
651 (traverse | 655 (traverse |
652 (fn [geom] | 656 (fn [geom] |
831 (println-repl "set gravity to " new-value) | 835 (println-repl "set gravity to " new-value) |
832 (if value | 836 (if value |
833 (set-gravity* game new-value) | 837 (set-gravity* game new-value) |
834 (set-gravity* game gravity)))) | 838 (set-gravity* game gravity)))) |
835 | 839 |
836 (defn fire-cannon-ball [] | 840 (defn fire-cannon-ball |
837 (fn [game value] | 841 ([node] |
838 (if (not value) | 842 (fn [game value] |
839 (let [camera (.getCamera game) | 843 (if (not value) |
840 cannon-ball | 844 (let [camera (.getCamera game) |
841 (sphere 0.7 | 845 cannon-ball |
842 :material "Common/MatDefs/Misc/Unshaded.j3md" | 846 (sphere 0.7 |
843 :texture "Textures/PokeCopper.jpg" | 847 :material "Common/MatDefs/Misc/Unshaded.j3md" |
844 :position | 848 :texture "Textures/PokeCopper.jpg" |
845 (.add (.getLocation camera) | 849 :position |
846 (.mult (.getDirection camera) (float 1))) | 850 (.add (.getLocation camera) |
847 :mass 3)] ;200 0.05 | 851 (.mult (.getDirection camera) (float 1))) |
848 (.setShadowMode cannon-ball RenderQueue$ShadowMode/CastAndReceive) | 852 :mass 3)] ;200 0.05 |
849 (.setLinearVelocity | 853 (.setShadowMode cannon-ball RenderQueue$ShadowMode/CastAndReceive) |
850 (.getControl cannon-ball RigidBodyControl) | 854 (.setLinearVelocity |
851 (.mult (.getDirection camera) (float 50))) ;50 | 855 (.getControl cannon-ball RigidBodyControl) |
852 (add-element game cannon-ball))))) | 856 (.mult (.getDirection camera) (float 50))) ;50 |
857 (add-element game cannon-ball node))))) | |
858 ([] | |
859 (fire-cannon-ball false))) | |
860 | |
853 | 861 |
854 (defn floor* [] | 862 (defn floor* [] |
855 (doto (box 10 0.1 5 :name "floor" ;10 0.1 5 ; 240 0.1 240 | 863 (doto (box 10 0.1 5 :name "floor" ;10 0.1 5 ; 240 0.1 240 |
856 :material "Common/MatDefs/Misc/Unshaded.j3md" | 864 :material "Common/MatDefs/Misc/Unshaded.j3md" |
857 :texture "Textures/Terrain/Pond/Pond.png" | 865 :texture "Textures/Terrain/Pond/Pond.png" |