comparison ships/orz.d @ 18:7f74e064dad5

refactored code
author zzzzrrr <mason.green@gmail.com>
date Wed, 25 Mar 2009 11:28:25 -0400
parents orz.d@af1e8620f027
children 4fce5596d1f6
comparison
equal deleted inserted replaced
17:82efafc87d54 18:7f74e064dad5
1 /*
2 * Copyright (c) 2009, Mason Green (zzzzrrr)
3 * http://www.dsource.org/projects/openmelee
4 *
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without modification,
8 * are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * * Neither the name of the polygonal nor the names of its contributors may be
16 * used to endorse or promote products derived from this software without specific
17 * prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 module openmelee.ships.orz;
32
33 import blaze.dynamics.bzBody : bzBody;
34 import blaze.bzWorld: bzWorld;
35 import blaze.dynamics.bzBodyDef;
36 import blaze.collision.shapes.bzPolygon : bzPolyDef;
37 import blaze.common.bzMath: bzVec2, PI;
38
39 import openmelee.ships.ship;
40
41 // UrQuan Dreadnought
42 class Orz : Ship
43 {
44
45 float scale = 0.025;
46
47 this(bzWorld world) {
48
49 super(world);
50 engineForce = bzVec2(500, 0);
51 turnForce = bzVec2(0, 5000);
52 rightTurnPoint = bzVec2(-0.5, 0);
53 leftTurnPoint = bzVec2(0.5, 0);
54
55 auto bodyDef = new bzBodyDef;
56 //bodyDef.isBullet = true;
57 bodyDef.position = bzVec2(20,15);
58 bodyDef.angle = PI/2;
59 bodyDef.allowFreeze = false;
60
61 rBody = world.createBody(bodyDef);
62 float density = 5.0f;
63
64 // Body
65 auto b = new bzPolyDef(density);
66 b.vertices.length = 4;
67 b.vertices[0] = bzVec2(42,14) * scale;
68 b.vertices[1] = bzVec2(-28,21) * scale;
69 b.vertices[2] = bzVec2(-28,-28) * scale;
70 b.vertices[3] = bzVec2(42,-21) * scale;
71 shapes.add(rBody.createShape(b));
72
73 // Top Wing
74 auto tWing = new bzPolyDef(density);
75 tWing.vertices.length = 5;
76 tWing.vertices[4] = bzVec2(-28,21) * scale;
77 tWing.vertices[3] = bzVec2(-70,63) * scale;
78 tWing.vertices[2] = bzVec2(-49,63) * scale;
79 tWing.vertices[1] = bzVec2(70,14) * scale;
80 tWing.vertices[0] = bzVec2(42,14) * scale;
81 shapes.add(rBody.createShape(tWing));
82
83 // Bottom Wing
84 auto bWing = new bzPolyDef(density);
85 bWing.vertices.length = 5;
86 bWing.vertices[0] = bzVec2(-28,-28) * scale;
87 bWing.vertices[1] = bzVec2(-70,-63) * scale;
88 bWing.vertices[2] = bzVec2(-49,-63) * scale;
89 bWing.vertices[3] = bzVec2(70,-21) * scale;
90 bWing.vertices[4] = bzVec2(42,-21) * scale;
91 shapes.add(rBody.createShape(bWing));
92
93 rBody.setMassFromShapes();
94 setPlanetGravity();
95 }
96 }