# HG changeset patch # User zzzzrrr # Date 1237668128 14400 # Node ID eb6059f7035ac0cd01e65c6f8923c1165fba5f33 # Parent 6f455ef24063ac1a31fabfb74662afb8a5492271 Added planet diff -r 6f455ef24063 -r eb6059f7035a gui.cfg --- a/gui.cfg Sat Mar 21 15:51:41 2009 -0400 +++ b/gui.cfg Sat Mar 21 16:42:08 2009 -0400 @@ -3,16 +3,8 @@ new FramedTopLevelWindow main { frame.text = "OpenMelee"; showCursor = false; - size = 900 610; - [hexpand hfill vexpand vfill] new HBox { - [vexpand vfill] new VBox controls { - size = 175 0; - layout = { - padding = 5 5; - } - } - [hexpand hfill vexpand vfill] new GLViewport glview; - } + size = 900 610; + [hexpand hfill vexpand vfill] new GLViewport glview; } @overlay { [hexpand vexpand hfill vfill] new Group .overlay { layout = Ghost; diff -r 6f455ef24063 -r eb6059f7035a melee.d --- a/melee.d Sat Mar 21 15:51:41 2009 -0400 +++ b/melee.d Sat Mar 21 16:42:08 2009 -0400 @@ -46,6 +46,7 @@ import openmelee.ship; import openmelee.urQuan; import openmelee.orz; +import openmelee.planet; // Cursor scale factor const CURSORSIZE = 0.05f; @@ -170,14 +171,15 @@ void init() { // Define world boundaries - worldAABB.lowerBound.set(-75.0f, -75.0f); - worldAABB.upperBound.set(75.0f, 75.0f); + worldAABB.lowerBound.set(-100.0f, -100.0f); + worldAABB.upperBound.set(100.0f, 100.0f); world = new bzWorld(worldAABB, gravity, allowSleep); world.boundaryListener = m_boundaryListener; world.contactListener = m_contactListener; viewCenter = vec2(10, 10); ship1 = new Orz(world); ship2 = new UrQuan(world); + auto planet = new Planet(world); } void drag() diff -r 6f455ef24063 -r eb6059f7035a orz.d --- a/orz.d Sat Mar 21 15:51:41 2009 -0400 +++ b/orz.d Sat Mar 21 16:42:08 2009 -0400 @@ -29,8 +29,6 @@ */ module openmelee.orz; -import tango.io.Stdout; - import blaze.dynamics.bzBody : bzBody; import blaze.bzWorld: bzWorld; import blaze.dynamics.bzBodyDef; @@ -43,12 +41,13 @@ class Orz : Ship { - float scale = 0.01; + float scale = 0.025; this(bzWorld world) { - - super.engineForce = bzVec2(5, 0); - super.turnForce = bzVec2(0, 300); + + super(world); + super.engineForce = bzVec2(300, 0); + super.turnForce = bzVec2(0, 10000); super.rightTurnPoint = bzVec2(-0.1, 0); super.leftTurnPoint = bzVec2(0.1, 0); @@ -57,8 +56,7 @@ bodyDef.angle = PI/2; bodyDef.allowFreeze = false; - auto rBody = world.createBody(bodyDef); - super(rBody); + rBody = world.createBody(bodyDef); float density = 2.0f; // Body @@ -91,6 +89,6 @@ shapes.add(rBody.createShape(bWing)); rBody.setMassFromShapes(); - - } + setGravity(); + } } diff -r 6f455ef24063 -r eb6059f7035a planet.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/planet.d Sat Mar 21 16:42:08 2009 -0400 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2009, Mason Green (zzzzrrr) + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the polygonal nor the names of its contributors may be + * used to endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +module openmelee.planet; + +import blaze.dynamics.bzBody : bzBody; +import blaze.bzWorld: bzWorld; +import blaze.dynamics.bzBodyDef; +import blaze.collision.shapes.bzCircle : bzCircleDef; +import blaze.common.bzMath: bzVec2; + +class Planet +{ + + bzWorld world; + + this(bzWorld world) { + this.world = world; + init(); + } + + void init() { + // Create planet + bzVec2 position = bzVec2.zeroVect; + float angle = 0.0f; + auto bd = new bzBodyDef(position, angle); + auto rBody = world.createBody(bd); + float radius = 7.0f; + float density = 7.5f; + auto sd = new bzCircleDef(density, radius); + float friction = 1.0f; + float restitution = 0.1f; + sd.friction = friction; + sd.restitution = restitution; + rBody.createShape(sd); + } +} diff -r 6f455ef24063 -r eb6059f7035a render.d --- a/render.d Sat Mar 21 15:51:41 2009 -0400 +++ b/render.d Sat Mar 21 16:42:08 2009 -0400 @@ -92,7 +92,7 @@ void drawSolidCircle(GL gl, vec2 center, float radius, vec2 axis, Color color) { - const k_segments = 16.0f; + const k_segments = 25.0f; const k_increment = 2.0f * PI / k_segments; float theta = 0.0f; gl.Enable(GL_BLEND); diff -r 6f455ef24063 -r eb6059f7035a ship.d --- 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); + } } diff -r 6f455ef24063 -r eb6059f7035a urQuan.d --- a/urQuan.d Sat Mar 21 15:51:41 2009 -0400 +++ b/urQuan.d Sat Mar 21 16:42:08 2009 -0400 @@ -41,15 +41,15 @@ class UrQuan : Ship { - float scale = 0.01; + float scale = 0.025; this(bzWorld world) { + super(world); auto bodyDef = new bzBodyDef; bodyDef.position = bzVec2(10,5); bodyDef.allowFreeze = false; - auto rBody = world.createBody(bodyDef); - super(rBody); + rBody = world.createBody(bodyDef); float density = 2.0f; // Head @@ -111,5 +111,6 @@ shapes.add(rBody.createShape(bWing)); rBody.setMassFromShapes(); + setGravity(); } }