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