Mercurial > projects > openmelee
diff melee/melee.d @ 31:55eb66672c03
added ldc build file
author | zzzzrrr@zzzzrrr-desktop |
---|---|
date | Mon, 30 Mar 2009 17:44:54 -0400 |
parents | 1cc6b8c0acd2 |
children |
line wrap: on
line diff
--- a/melee/melee.d Mon Mar 30 16:16:58 2009 -0400 +++ b/melee/melee.d Mon Mar 30 17:44:54 2009 -0400 @@ -1,7 +1,7 @@ /* * Copyright (c) 2009, Mason Green (zzzzrrr) * http://www.dsource.org/projects/openmelee - * + * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -41,12 +41,17 @@ import blaze.common.bzMath : bzVec2; import blaze.bzWorld : bzWorld; import blaze.collision.bzCollision : bzAABB; +import blaze.collision.shapes.bzShape : bzShape; +import blaze.dynamics.bzBody : bzBody; +import blaze.dynamics.contact.bzContact : bzContactPoint; +import blaze.collision.bzCollision : bzContactID; -import openmelee.melee.boundaryListener; -import openmelee.melee.contactListener; +import openmelee.melee.boundaryListener : BoundaryListener; +import openmelee.melee.contactListener : ContactListener; import openmelee.render.render; import openmelee.ai.ai : AI; import openmelee.ai.human : Human; +import openmelee.ships.ship : Ship; import openmelee.ships.urQuan : UrQuan; import openmelee.ships.orz : Orz; import openmelee.ships.planet : Planet; @@ -91,76 +96,76 @@ } class Melee { - + ObjectList objectList; Settings settings; float timeStep; const bzVec2 gravity = bzVec2(0.0f, 0.0f); bool allowSleep; Render render; - + AI ai; Human human; - + Ship ship1; Ship ship2; Ship planet; - + bool running; - + StopWatch timer; bzAABB worldAABB; bzWorld world; - bzBoundaryListener m_boundaryListener; - bzContactListener m_contactListener; + BoundaryListener m_boundaryListener; + ContactListener m_contactListener; ContactPoint[k_maxContactPoints] points; int pointCount; - + this() { timeStep = settings.hz > 0.0f ? 1.0f / settings.hz : 0.0f; objectList = new ObjectList; m_boundaryListener = new BoundaryListener(this); - - + + initWorld(); running = true; - + human = new Human(ship1, this); ai = new AI(ship2, objectList); - + render = new Render(world, ship1, ship2, human, settings); - + objectList.add(planet); objectList.add(ship1); objectList.add(ship2); } - + void run() { // Main game loop while (running && !human.quit && render.running) { - + float delta = timer.stop; timer.start; - + // Update AI ai.move(ship1); // Update Physics world.step(timeStep, settings.velocityIterations, settings.positionIterations); // Update screen render.update(); - + // Limit velocities foreach(o; objectList) { o.limitVelocity(); o.updateState(); } - + // Apply thrust if(human.thrust && ship1) { ship1.thrust(); } } - + delete render; } @@ -179,11 +184,11 @@ objectList.add(asteroid); } } - + void boundaryViolated(bzBody rBody) { float x,y; - + if(rBody.position.x > worldAABB.upperBound.x) { x = worldAABB.lowerBound.x + 5; rBody.position = bzVec2(x, rBody.position.y); @@ -196,6 +201,6 @@ } else if(rBody.position.y < worldAABB.lowerBound.y) { y = worldAABB.upperBound.y - 5; rBody.position = bzVec2(rBody.position.x, y); - } + } } }