Mercurial > projects > openmelee
annotate main.d @ 17:82efafc87d54
fixed camera zoom
author | zzzzrrr <mason.green@gmail.com> |
---|---|
date | Tue, 24 Mar 2009 16:47:42 -0400 |
parents | 8e6a9e390cba |
children |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright (c) 2009, Mason Green (zzzzrrr) | |
8 | 3 * http://www.dsource.org/projects/openmelee |
0 | 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 */ | |
2 | 31 module openmelee.main; |
0 | 32 |
12 | 33 import tango.io.Stdout : Stdout; |
34 | |
0 | 35 version(distrib) import tango.io.vfs.ZipFolder; |
36 import tango.time.StopWatch; | |
37 import fc = tango.text.convert.Float : toString; | |
38 import tango.util.log.Trace; | |
39 import tango.math.Math; | |
40 | |
41 import xf.core.JobHub; | |
42 import xf.hybrid.Hybrid; | |
43 import xf.hybrid.backend.GL; | |
44 import xf.omg.core.LinearAlgebra; | |
45 | |
7
2217fd1fe384
added angular and linear velocity limit
zzzzrrr <mason.green@gmail.com>
parents:
5
diff
changeset
|
46 import blaze.common.bzMath: bzVec2; |
2217fd1fe384
added angular and linear velocity limit
zzzzrrr <mason.green@gmail.com>
parents:
5
diff
changeset
|
47 |
2 | 48 import openmelee.melee; |
49 import openmelee.render; | |
11
d998bf1b0654
Added utilities and AI; fixed steer
Mason Green <mason.green@gmail.com>
parents:
9
diff
changeset
|
50 import openmelee.ai; |
0 | 51 |
17 | 52 const ITERS_PER_SECOND = 100; |
0 | 53 |
54 void main() { | |
55 | |
56 Settings settings; | |
57 float timeStep = settings.hz > 0.0f ? 1.0f / settings.hz : 0.0f; | |
58 version(distrib) gui.vfs.mount(new ZipFolder("./gui.zip")); | |
59 scope cfg = loadHybridConfig("./gui.cfg"); | |
60 scope renderer = new Renderer; | |
61 auto whut = new Render(&settings); | |
11
d998bf1b0654
Added utilities and AI; fixed steer
Mason Green <mason.green@gmail.com>
parents:
9
diff
changeset
|
62 auto ai = new AI(whut.ship2); |
d998bf1b0654
Added utilities and AI; fixed steer
Mason Green <mason.green@gmail.com>
parents:
9
diff
changeset
|
63 |
0 | 64 gui.begin(cfg).retained; |
65 gui.push(`main`); | |
66 GLViewport(`glview`).renderingHandler(&whut.draw) | |
67 .addHandler(&whut.onClick) | |
68 .addHandler(&whut.onMove) | |
69 .addHandler(&whut.onKey) | |
70 .addHandler(&whut.onDT) | |
71 .addHandler(&whut.onMouseEnter) | |
72 .addHandler(&whut.onMouseLeave) | |
73 .grabKeyboardFocus; | |
74 gui.pop(); | |
75 gui.immediate.end; | |
76 | |
77 StopWatch timer; | |
78 | |
79 jobHub.addRepeatableJob( { | |
9 | 80 // Update physics |
81 whut.world.step(timeStep, settings.velocityIterations, | |
82 settings.positionIterations); | |
17 | 83 }, ITERS_PER_SECOND); |
84 | |
85 bool running = true; | |
86 | |
87 jobHub.addPreFrameJob( { | |
88 // Update AI | |
89 ai.move(whut.ship1); | |
90 }); | |
91 | |
92 jobHub.addPostFrameJob( { | |
15 | 93 |
94 // Limit velocity | |
95 whut.ship1.limitVelocity(); | |
96 whut.ship2.limitVelocity(); | |
97 whut.ship1.updateState(); | |
98 whut.ship2.updateState(); | |
99 | |
0 | 100 gui.begin(cfg); |
101 gui.push(`main`); | |
102 if (gui().getProperty!(bool)("frame.closeClicked")) { | |
103 running = false; | |
104 } | |
2 | 105 |
0 | 106 |
107 if(whut.thrust) { | |
108 whut.ship1.thrust(); | |
109 } | |
110 | |
111 gui().setProperty!(bool)("showCursor", true); | |
112 gui.pop(); | |
113 gui.end; | |
114 gui.render(renderer); | |
115 | |
116 }); | |
117 | |
118 while (running && !whut.quit) { | |
119 float delta = timer.stop; | |
120 timer.start; | |
121 jobHub.update(delta); | |
122 } | |
123 } |