changeset 17:82efafc87d54

fixed camera zoom
author zzzzrrr <mason.green@gmail.com>
date Tue, 24 Mar 2009 16:47:42 -0400
parents cc494b8f8710
children 7f74e064dad5
files build-dmd-win.bat example.d main.d melee.d openmelee.geany openmelee.zip render.d ship.d testScript.md
diffstat 9 files changed, 128 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/build-dmd-win.bat	Tue Mar 24 13:29:16 2009 -0400
+++ b/build-dmd-win.bat	Tue Mar 24 16:47:42 2009 -0400
@@ -1,4 +1,4 @@
-::jake -I.. -I../blaze -I../xf/ext zlib.lib -inline -release -O main.d
+jake -I.. -I../blaze -I../xf/ext zlib.lib -inline -release -O main.d
 ::rebuild -I.. -I../blaze -I../xf/ext zlib.lib -inline -release -O main.d
-xfBuild main.d -oMain.exe -- -I.. -I../blaze -I../xf/ext zlib.lib -inline -release -O 
+::xfBuild main.d -oMain.exe -- -I.. -I../blaze -I../xf/ext zlib.lib -inline -release -O 
 
--- a/example.d	Tue Mar 24 13:29:16 2009 -0400
+++ b/example.d	Tue Mar 24 16:47:42 2009 -0400
@@ -1,11 +1,80 @@
+// jake -I../minid -I.. -version=old example.d
 module example;
 
-import minid.api;
+import xf.xpose2.Expose;
+import xf.xpose2.MiniD;
+import tango.text.convert.Format;
+
+struct vec3 {
+	float x, y, z;
+	
+	char[] toString() {
+		return Format("x={} y={} z={}", x, y, z);
+	}
+	
+	mixin(xpose2(`
+		.*
+		toString
+		_ctor overload vec3 function(float, float, float)
+	`));
+	mixin xposeMiniD;
+}
+
+class Poop {
+	int x = 0;
+	
+	this() {
+		this.x = 123456;
+	}
+	
+	this(int x) {
+		this.x = x;
+	}
+	
+	this (char[] zomg) {
+		this.x = zomg.length;
+	}
+	
+	int max(int a, int b) {
+		return a > b ? a : b;
+	}
+	
+	int dmax(int a, int b) {
+		return max(max(a, b), x);
+	}
+	
+	int dmax(int a, int b, int c) {
+		return dmax(a, dmax(b, c));
+	}
+	
+	vec3 getVec3(int x, int y, int z) {
+		return vec3(x, y, z);
+	}
+    
+}
+
+mixin(xpose2(`Poop`,`
+	dmax
+	dmax overload int function(int, int, int) ; md { rename "dmax2" }
+	getVec3
+	.*
+	_ctor
+	_ctor overload Poop function(int)
+	_ctor overload Poop function(char[])
+`));
+
+mixin xposeMiniD!(`Poop`);
 
 void main(char[][] args)
 {
 	MDVM vm;
 	auto t = openVM(&vm);
 	loadStdlibs(t);
-	importModule(t, args[1]);
+    xposeMiniD_initAll(t);
+    superPush(t, new Poop(10));
+    newGlobal(t, "poop");
+    importModule(t, args[1]);
+    lookup(t, "poop");
+	auto poop = superGet!(Poop)(t, -1);
+	Stdout.formatln("poop.dmax(1, 2) == {}", poop.dmax(1, 2));
 }
--- a/main.d	Tue Mar 24 13:29:16 2009 -0400
+++ b/main.d	Tue Mar 24 16:47:42 2009 -0400
@@ -49,7 +49,7 @@
 import openmelee.render;
 import openmelee.ai;
 
-const ITERS_PER_SECOND = 60;
+const ITERS_PER_SECOND = 100;
 
 void main() {
 
@@ -77,13 +77,19 @@
     StopWatch timer;
 
     jobHub.addRepeatableJob( {
-        
-        // Update AI
-        ai.move(whut.ship1);
-        
         // Update physics
         whut.world.step(timeStep, settings.velocityIterations,
                         settings.positionIterations);
+    }, ITERS_PER_SECOND);
+
+    bool running = true;
+
+    jobHub.addPreFrameJob( {
+        // Update AI
+        ai.move(whut.ship1);
+    });
+
+    jobHub.addPostFrameJob( {
         
         // Limit velocity
         whut.ship1.limitVelocity();
@@ -91,15 +97,6 @@
         whut.ship1.updateState();
         whut.ship2.updateState();
         
-    }, ITERS_PER_SECOND);
-
-    bool running = true;
-
-    jobHub.addPreFrameJob( {
-    });
-
-    jobHub.addPostFrameJob( {
-        
         gui.begin(cfg);
         gui.push(`main`);
         if (gui().getProperty!(bool)("frame.closeClicked")) {
@@ -116,15 +113,6 @@
         gui.end;
         gui.render(renderer);
         
-        {
-            vec2 p1 = vec2.from(whut.ship1.rBody.position);
-            vec2 p2 = vec2.from(whut.ship2.rBody.position);
-            vec2 distance = p1 - p2;
-            float d = distance.length;
-            whut.zoom = bzClamp(1/d*1000, 2, 50);
-            whut.viewCenter = p1 - (distance * 0.5f);
-        }
-        
     });
 
     while (running && !whut.quit) {
--- a/melee.d	Tue Mar 24 13:29:16 2009 -0400
+++ b/melee.d	Tue Mar 24 16:47:42 2009 -0400
@@ -85,7 +85,7 @@
 // Melee settings. Some can be controlled in the GUI.
 struct Settings {
     float hz = 60;
-    int velocityIterations = 5;
+    int velocityIterations = 3;
     int positionIterations = 1;
     bool drawShapes = true;
     bool drawJoints = true;
--- a/openmelee.geany	Tue Mar 24 13:29:16 2009 -0400
+++ b/openmelee.geany	Tue Mar 24 16:47:42 2009 -0400
@@ -14,21 +14,17 @@
 run_cmd=
 
 [files]
-current_page=14
-FILE_NAME_0=3621;D;0;16;0;1;1;C:\\workspace\\openmelee\\main.d;0
-FILE_NAME_1=7216;D;0;16;0;1;1;C:\\workspace\\openmelee\\melee.d;0
-FILE_NAME_2=2248;D;0;16;0;1;1;C:\\workspace\\openmelee\\orz.d;0
+current_page=0
+FILE_NAME_0=3305;D;0;16;0;1;1;C:\\workspace\\openmelee\\main.d;0
+FILE_NAME_1=1783;D;0;16;0;1;1;C:\\workspace\\openmelee\\melee.d;0
+FILE_NAME_2=2250;D;0;16;0;1;1;C:\\workspace\\openmelee\\orz.d;0
 FILE_NAME_3=9747;D;0;16;0;1;1;C:\\workspace\\openmelee\\render.d;0
-FILE_NAME_4=2600;D;0;16;0;1;1;C:\\workspace\\openmelee\\ship.d;0
-FILE_NAME_5=5704;D;0;16;0;1;1;C:\\workspace\\openmelee\\steer.d;0
-FILE_NAME_6=2250;D;0;16;0;1;1;C:\\workspace\\openmelee\\urQuan.d;0
-FILE_NAME_7=147;None;0;16;0;1;1;C:\\workspace\\openmelee\\build-dmd-win.bat;0
+FILE_NAME_4=2659;D;0;16;0;1;1;C:\\workspace\\openmelee\\ship.d;0
+FILE_NAME_5=6206;D;0;16;0;1;1;C:\\workspace\\openmelee\\steer.d;0
+FILE_NAME_6=2252;D;0;16;0;1;1;C:\\workspace\\openmelee\\urQuan.d;0
+FILE_NAME_7=0;None;0;16;0;1;1;C:\\workspace\\openmelee\\build-dmd-win.bat;0
 FILE_NAME_8=304;Conf;0;16;0;1;0;C:\\workspace\\openmelee\\gui.cfg;0
 FILE_NAME_9=1648;D;0;16;0;1;0;C:\\workspace\\openmelee\\planet.d;0
-FILE_NAME_10=2031;D;0;16;0;1;1;C:\\workspace\\openmelee\\ai.d;0
-FILE_NAME_11=13893;D;0;16;0;1;1;C:\\Documents and Settings\\greenma3\\workspace\\blaze\\blaze\\dynamics\\bzIsland.d;0
-FILE_NAME_12=17007;D;0;16;0;1;1;C:\\Documents and Settings\\greenma3\\workspace\\blaze\\blaze\\dynamics\\bzBody.d;0
-FILE_NAME_13=29005;D;0;16;0;1;1;C:\\workspace\\blaze\\blaze\\bzWorld.d;0
-FILE_NAME_14=22084;D;0;16;0;1;1;C:\\workspace\\blaze\\blaze\\dynamics\\bzBody.d;0
-FILE_NAME_15=8520;D;0;16;0;1;1;C:\\workspace\\blaze\\blaze\\collision\\shapes\\bzShape.d;0
-FILE_NAME_16=12632;D;0;16;0;1;1;C:\\workspace\\blaze\\blaze\\collision\\shapes\\bzPolygon.d;0
+FILE_NAME_10=2827;D;0;16;0;1;1;C:\\workspace\\openmelee\\ai.d;0
+FILE_NAME_11=814;D;0;16;0;1;1;C:\\workspace\\openmelee\\example.d;0
+FILE_NAME_12=19;None;0;16;0;1;1;C:\\workspace\\openmelee\\testScript.md;0
Binary file openmelee.zip has changed
--- a/render.d	Tue Mar 24 13:29:16 2009 -0400
+++ b/render.d	Tue Mar 24 16:47:42 2009 -0400
@@ -315,6 +315,13 @@
 
 void draw(vec2i screenSize, GL gl)
 {
+   
+    vec2 point1 = vec2.from(ship1.rBody.position);
+    vec2 point2 = vec2.from(ship2.rBody.position);
+    vec2 range = point1 - point2;
+    zoom = bzClamp(1000/range.length, 2, 60);
+    viewCenter = point1 - (range * 0.5f);
+        
     this.screenSize = screenSize;
 
     gl.LoadIdentity();
--- a/ship.d	Tue Mar 24 13:29:16 2009 -0400
+++ b/ship.d	Tue Mar 24 16:47:42 2009 -0400
@@ -121,9 +121,7 @@
     	state.velocity = rBody.linearVelocity;
     	state.speed = state.velocity.length;
     	state.position = rBody.position;
-    	bzVec2 heading = engineForce.rotate(rBody.angle);
-    	heading.normalize();
-    	state.forward = heading;
+    	state.forward = engineForce.rotate(rBody.angle);
     }
     
 }
--- a/testScript.md	Tue Mar 24 13:29:16 2009 -0400
+++ b/testScript.md	Tue Mar 24 16:47:42 2009 -0400
@@ -1,2 +1,25 @@
 module testscript
-writeln("Hi, I'm a scripty!")
+
+local blah = vec3(1, 2, 30000)
+writeln("created a vec3: ", blah)
+
+writeln("Hello world")
+poop.x = 123
+writeln("poop.dmax2(1, 20, 150) == ", poop.dmax2(1, 20, 150))
+writeln("poop.dmax(1, 20) == ", poop.dmax(1, 20))
+
+writeln("getting a vec3...")
+local v3 = poop.getVec3(3, 6, 9)
+writeln("x = ", v3.x, " y = ", v3.y, " z = ", v3.z)
+
+class Zomg : Poop {
+    /+this() {
+        super(1, 2, 3)
+    }+/
+    
+    function dmax(a : int, b : int) {
+        return 1337
+    }
+}
+
+poop = Zomg()