diff ship.d @ 6:eb6059f7035a

Added planet
author zzzzrrr <mason.green@gmail.com>
date Sat, 21 Mar 2009 16:42:08 -0400
parents 6f455ef24063
children 2217fd1fe384
line wrap: on
line diff
--- a/ship.d	Sat Mar 21 15:51:41 2009 -0400
+++ b/ship.d	Sat Mar 21 16:42:08 2009 -0400
@@ -35,12 +35,14 @@
 import blaze.dynamics.bzBody : bzBody;
 import blaze.collision.shapes.bzShape : bzShape;
 import blaze.common.bzMath: bzVec2, bzCross;
+import blaze.bzWorld : bzWorld;
+import blaze.dynamics.forces.bzAttractor: bzAttractor;
 
 alias LinkedList!(bzShape) ShapeList;
 
 abstract class Ship
 {
-
+    bzWorld world;
     bzBody rBody;
     ShapeList shapes;
     bzVec2 engineForce;
@@ -48,8 +50,8 @@
     bzVec2 leftTurnPoint;
     bzVec2 rightTurnPoint;
 
-    this(bzBody rBody) {
-        this.rBody = rBody;
+    this(bzWorld world) {
+        this.world = world;
         shapes = new ShapeList;
     }
 
@@ -66,4 +68,14 @@
         rBody.torque += bzCross(rightTurnPoint.rotate(rBody.angle), 
                                 turnForce.rotate(rBody.angle));
     }
+    
+    void setGravity() {
+        
+        float minRadius = 1;
+        float maxRadius = 30;
+        float strength = 4;
+        bzVec2 center = bzVec2(0,0);
+        auto attractor = new bzAttractor(rBody, center, strength, minRadius, maxRadius);
+        world.addForce(attractor);
+    }
 }