diff melee/melee.d @ 27:d63faa81a5e4

removed Dog, added derelict and glfw
author zzzzrrr <mason.green@gmail.com>
date Mon, 30 Mar 2009 12:41:29 -0400
parents 88cca12cc8b9
children 1cc6b8c0acd2
line wrap: on
line diff
--- a/melee/melee.d	Fri Mar 27 19:26:01 2009 -0400
+++ b/melee/melee.d	Mon Mar 30 12:41:29 2009 -0400
@@ -38,10 +38,6 @@
 import fc = tango.text.convert.Float : toString;
 import tango.util.log.Trace;
 
-import xf.core.JobHub;
-import xf.hybrid.Hybrid;
-import xf.hybrid.backend.GL;
-
 import blaze.common.bzMath : bzVec2;
 import blaze.bzWorld : bzWorld;
 import blaze.collision.bzCollision : bzAABB;
@@ -101,7 +97,7 @@
     float timeStep;
     const bzVec2 gravity = bzVec2(0.0f, 0.0f);
     bool allowSleep;
-    Render draw;
+    Render render;
     
     AI ai;
     Human human;
@@ -121,83 +117,52 @@
     int pointCount;
     
     this() {
-        
+        timeStep = settings.hz > 0.0f ? 1.0f / settings.hz : 0.0f;
         objectList = new ObjectList;
-    }
-    
-    void init() {
-
-        timeStep = settings.hz > 0.0f ? 1.0f / settings.hz : 0.0f;
-        version(distrib) gui.vfs.mount(new ZipFolder("./gui.zip"));
-        scope cfg = loadHybridConfig("./gui.cfg");
-        scope renderer = new Renderer;
-    
 		m_boundaryListener = new BoundaryListener(this);
+        
+        
         initWorld();
         running = true;
         
-        draw = new Render(world, ship1, ship2, settings);
         human = new Human(ship1, this);
+        ai = new AI(ship2, objectList);
+        
+        render = new Render(world, ship1, ship2, human, settings);
+        render.keys();
         
         objectList.add(planet);
         objectList.add(ship1);
         objectList.add(ship2);
-        
-        ai = new AI(ship2, objectList);
-        
-        gui.begin(cfg).retained;
-        gui.push(`main`);
-        GLViewport(`glview`).renderingHandler(&draw.draw)
-        .addHandler(&human.onClick)
-        .addHandler(&human.onMove)
-        .addHandler(&human.onKey)
-        .addHandler(&human.onDT)
-        .addHandler(&human.onMouseEnter)
-        .addHandler(&human.onMouseLeave)
-        .grabKeyboardFocus;
-        gui.pop();
-        gui.immediate.end;
+    }
     
-        jobHub.addRepeatableJob( {
-            // Update physics
-            world.step(timeStep, settings.velocityIterations, settings.positionIterations);
-        }, ITERS_PER_SECOND);
-
-        jobHub.addPreFrameJob( {
+    void run() {
+        // Main game loop
+        while (running && !human.quit) {
+            
+            float delta = timer.stop;
+            timer.start;
+            
             // Update AI
             ai.move(ship1);
-        });
-
-        jobHub.addPostFrameJob( {
+            // Update Physics
+            world.step(timeStep, settings.velocityIterations, settings.positionIterations);
+            // Update screen
+            render.update();
             
-            // Limit velocity
+            // Limit velocities
             foreach(o; objectList) {
                 o.limitVelocity();
                 o.updateState();
             }
             
-            gui.begin(cfg);
-            gui.push(`main`);
-            if (gui().getProperty!(bool)("frame.closeClicked")) {
-                running = false;
+            // Apply thrust
+            if(human.thrust && ship1) {
+                ship1.thrust();
             }
-
-            if(human.thrust && ship1) {
-                ship1.thrust();
-            }
-
-            gui().setProperty!(bool)("showCursor", true);
-            gui.pop();
-            gui.end;
-            gui.render(renderer);
-            
-        });
+        }
         
-        while (running && !human.quit) {
-            float delta = timer.stop;
-            timer.start;
-            jobHub.update(delta);
-        }
+        delete render;
     }
 
     void initWorld() {