# HG changeset patch # User Robert McIntyre # Date 1319395817 25200 # Node ID c32f3eb9fdeba7001e03273341605b0a725ebf1d # Parent 3aa1ee6c6308b1a623ec9c4efc68d658c486f682 modified fire-cannon-ball to place the ball on a specific node diff -r 3aa1ee6c6308 -r c32f3eb9fdeb org/cortex.org --- a/org/cortex.org Sun Oct 23 11:30:42 2011 -0700 +++ b/org/cortex.org Sun Oct 23 11:50:17 2011 -0700 @@ -637,14 +637,18 @@ :shape (Sphere. 32 32 (float r)))))) ([] (sphere 0.5))) -(defn add-element [game node] +(defn add-element + ([game element node] (.addAll (.getPhysicsSpace (.getState (.getStateManager game) BulletAppState)) - node) - (.attachChild (.getRootNode game) node)) + element) + (.attachChild node element)) + ([game element] + (add-element game element (.getRootNode game)))) + (defn set-gravity* [game gravity] @@ -833,23 +837,27 @@ (set-gravity* game new-value) (set-gravity* game gravity)))) -(defn fire-cannon-ball [] - (fn [game value] - (if (not value) - (let [camera (.getCamera game) - cannon-ball - (sphere 0.7 - :material "Common/MatDefs/Misc/Unshaded.j3md" - :texture "Textures/PokeCopper.jpg" - :position - (.add (.getLocation camera) - (.mult (.getDirection camera) (float 1))) - :mass 3)] ;200 0.05 - (.setShadowMode cannon-ball RenderQueue$ShadowMode/CastAndReceive) - (.setLinearVelocity - (.getControl cannon-ball RigidBodyControl) - (.mult (.getDirection camera) (float 50))) ;50 - (add-element game cannon-ball))))) +(defn fire-cannon-ball + ([node] + (fn [game value] + (if (not value) + (let [camera (.getCamera game) + cannon-ball + (sphere 0.7 + :material "Common/MatDefs/Misc/Unshaded.j3md" + :texture "Textures/PokeCopper.jpg" + :position + (.add (.getLocation camera) + (.mult (.getDirection camera) (float 1))) + :mass 3)] ;200 0.05 + (.setShadowMode cannon-ball RenderQueue$ShadowMode/CastAndReceive) + (.setLinearVelocity + (.getControl cannon-ball RigidBodyControl) + (.mult (.getDirection camera) (float 50))) ;50 + (add-element game cannon-ball node))))) + ([] + (fire-cannon-ball false))) + (defn floor* [] (doto (box 10 0.1 5 :name "floor" ;10 0.1 5 ; 240 0.1 240 diff -r 3aa1ee6c6308 -r c32f3eb9fdeb org/skin.org --- a/org/skin.org Sun Oct 23 11:30:42 2011 -0700 +++ b/org/skin.org Sun Oct 23 11:50:17 2011 -0700 @@ -248,7 +248,7 @@ (world root-node - {"key-return" (fire-cannon-ball)} + {"key-return" (fire-cannon-ball node)} ;;no-op (fn [world] ;; (Capture/SimpleCaptureVideo @@ -261,7 +261,7 @@ (fn [& _] (let [touch-data (touch-percieve 0.2 b node)] - (println-repl touch-data) + ;;(println-repl touch-data) (manage-ray-debug-node debug-node b touch-data 0.2)) (Thread/sleep 10) ;;(touch-print controls)