Mercurial > projects > openmelee
annotate orz.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.orz; |
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, PI; | |
37 | |
2 | 38 import openmelee.ship; |
0 | 39 |
40 // UrQuan Dreadnought | |
41 class Orz : Ship | |
42 { | |
43 | |
6 | 44 float scale = 0.025; |
0 | 45 |
46 this(bzWorld world) { | |
6 | 47 |
48 super(world); | |
7
2217fd1fe384
added angular and linear velocity limit
zzzzrrr <mason.green@gmail.com>
parents:
6
diff
changeset
|
49 engineForce = bzVec2(500, 0); |
2217fd1fe384
added angular and linear velocity limit
zzzzrrr <mason.green@gmail.com>
parents:
6
diff
changeset
|
50 turnForce = bzVec2(0, 5000); |
2217fd1fe384
added angular and linear velocity limit
zzzzrrr <mason.green@gmail.com>
parents:
6
diff
changeset
|
51 rightTurnPoint = bzVec2(-0.5, 0); |
2217fd1fe384
added angular and linear velocity limit
zzzzrrr <mason.green@gmail.com>
parents:
6
diff
changeset
|
52 leftTurnPoint = bzVec2(0.5, 0); |
0 | 53 |
54 auto bodyDef = new bzBodyDef; | |
7
2217fd1fe384
added angular and linear velocity limit
zzzzrrr <mason.green@gmail.com>
parents:
6
diff
changeset
|
55 //bodyDef.isBullet = true; |
0 | 56 bodyDef.position = bzVec2(10,10); |
57 bodyDef.angle = PI/2; | |
5 | 58 bodyDef.allowFreeze = false; |
0 | 59 |
6 | 60 rBody = world.createBody(bodyDef); |
7
2217fd1fe384
added angular and linear velocity limit
zzzzrrr <mason.green@gmail.com>
parents:
6
diff
changeset
|
61 float density = 5.0f; |
0 | 62 |
63 // Body | |
64 auto b = new bzPolyDef(density); | |
65 b.vertices.length = 4; | |
66 b.vertices[0] = bzVec2(42,14) * scale; | |
67 b.vertices[1] = bzVec2(-28,21) * scale; | |
68 b.vertices[2] = bzVec2(-28,-28) * scale; | |
69 b.vertices[3] = bzVec2(42,-21) * scale; | |
5 | 70 shapes.add(rBody.createShape(b)); |
0 | 71 |
72 // Top Wing | |
73 auto tWing = new bzPolyDef(density); | |
74 tWing.vertices.length = 5; | |
75 tWing.vertices[4] = bzVec2(-28,21) * scale; | |
76 tWing.vertices[3] = bzVec2(-70,63) * scale; | |
77 tWing.vertices[2] = bzVec2(-49,63) * scale; | |
78 tWing.vertices[1] = bzVec2(70,14) * scale; | |
79 tWing.vertices[0] = bzVec2(42,14) * scale; | |
5 | 80 shapes.add(rBody.createShape(tWing)); |
0 | 81 |
82 // Bottom Wing | |
83 auto bWing = new bzPolyDef(density); | |
84 bWing.vertices.length = 5; | |
85 bWing.vertices[0] = bzVec2(-28,-28) * scale; | |
86 bWing.vertices[1] = bzVec2(-70,-63) * scale; | |
87 bWing.vertices[2] = bzVec2(-49,-63) * scale; | |
88 bWing.vertices[3] = bzVec2(70,-21) * scale; | |
89 bWing.vertices[4] = bzVec2(42,-21) * scale; | |
5 | 90 shapes.add(rBody.createShape(bWing)); |
0 | 91 |
5 | 92 rBody.setMassFromShapes(); |
6 | 93 setGravity(); |
94 } | |
0 | 95 } |