comparison ships/urQuan.d @ 18:7f74e064dad5

refactored code
author zzzzrrr <mason.green@gmail.com>
date Wed, 25 Mar 2009 11:28:25 -0400
parents urQuan.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.urQuan;
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;
38
39 import openmelee.ships.ship;
40
41 // UrQuan Dreadnought
42 class UrQuan : 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, 9000);
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(30,5);
58 bodyDef.allowFreeze = false;
59 rBody = world.createBody(bodyDef);
60 float density = 5.0f;
61
62 // Head
63 auto head = new bzPolyDef;
64 head.vertices.length = 8;
65 head.vertices[0] = bzVec2(42,49) * scale;
66 head.vertices[7] = bzVec2(63,49) * scale;
67 head.vertices[6] = bzVec2(70,45.5) * scale;
68 head.vertices[5] = bzVec2(73.5,38.5) * scale;
69 head.vertices[4] = bzVec2(73.5,-42) * scale;
70 head.vertices[3] = bzVec2(70,-49) * scale;
71 head.vertices[2] = bzVec2(63,-56) * scale;
72 head.vertices[1] = bzVec2(42,-56) * scale;
73 shapes.add(rBody.createShape(head));
74
75 // Body
76 auto b = new bzPolyDef(density);
77 b.vertices.length = 4;
78 b.vertices[0] = bzVec2(-70,-28) * scale;
79 b.vertices[3] = bzVec2(-70,24.5) * scale;
80 b.vertices[2] = bzVec2(42,24.5) * scale;
81 b.vertices[1] = bzVec2(42,-31.5) * scale;
82 shapes.add(rBody.createShape(b));
83
84 // Top Strut
85 auto tStrut = new bzPolyDef(density);
86 tStrut.vertices.length = 4;
87 tStrut.vertices[0] = bzVec2(0,24.5) * scale;
88 tStrut.vertices[3] = bzVec2(-28,24.5) * scale;
89 tStrut.vertices[2] = bzVec2(-28,42) * scale;
90 tStrut.vertices[1] = bzVec2(0,42) * scale;
91 shapes.add(rBody.createShape(tStrut));
92
93 // Top Wing
94 auto tWing = new bzPolyDef(density);
95 tWing.vertices.length = 4;
96 tWing.vertices[0] = bzVec2(-70,42) * scale;
97 tWing.vertices[3] = bzVec2(-49,63) * scale;
98 tWing.vertices[2] = bzVec2(28,63) * scale;
99 tWing.vertices[1] = bzVec2(28,42) * scale;
100 shapes.add(rBody.createShape(tWing));
101
102 // Bottom Strut
103 auto bStrut = new bzPolyDef(density);
104 bStrut.vertices.length = 4;
105 bStrut.vertices[0] = bzVec2(0,-31.5) * scale;
106 bStrut.vertices[3] = bzVec2(0,-49) * scale;
107 bStrut.vertices[2] = bzVec2(-28,-49) * scale;
108 bStrut.vertices[1] = bzVec2(-28,-31.5) * scale;
109 shapes.add(rBody.createShape(bStrut));
110
111 // Bottom Wing
112 auto bWing = new bzPolyDef(density);
113 bWing.vertices.length = 4;
114 bWing.vertices[0] = bzVec2(-70,-49) * scale;
115 bWing.vertices[3] = bzVec2(28,-49) * scale;
116 bWing.vertices[2] = bzVec2(28,-70) * scale;
117 bWing.vertices[1] = bzVec2(-42,-70) * scale;
118 shapes.add(rBody.createShape(bWing));
119
120 rBody.setMassFromShapes();
121 setPlanetGravity();
122 }
123 }