Skip to content

Commit 8efa952

Browse files
committed
Now with configuration
1 parent 6ef751f commit 8efa952

File tree

12 files changed

+186
-56
lines changed

12 files changed

+186
-56
lines changed

CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ SET( PROJECT_SOURCES
3636
Modules/Dragon/Dragon.cpp
3737
Modules/Dragon/Tube.cpp
3838

39-
HUD/DragonHUD.cpp
39+
# HUD/DragonHUD.cpp
4040
)
4141

4242
# Include needed to use SDL under Mac OS X
@@ -63,15 +63,15 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME}
6363
OpenEngine_Geometry
6464
# Extension dependencies
6565
Extensions_GenericHandlers
66-
Extensions_HUD
66+
#Extensions_HUD
6767
Extensions_OBJResource
6868
Extensions_RAWResource
6969
Extensions_SDLImage
7070
Extensions_OpenGLRenderer
7171
Extensions_SDL
72-
Extensions_CairoResource
73-
Extensions_VorbisResource
74-
Extensions_OpenALSoundSystem
75-
Extensions_MusicPlayer
76-
Extensions_GLUT
72+
# Extensions_CairoResource
73+
# Extensions_VorbisResource
74+
# Extensions_OpenALSoundSystem
75+
#Extensions_MusicPlayer
76+
#Extensions_GLUT
7777
)

Config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//#define DRAGON_SOUND
2+
//#define DRAGON_HUD

KeyHandler.cpp

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// See the GNU General Public License for more details (see LICENSE).
88
//--------------------------------------------------------------------
99

10+
#include "Config.h"
11+
1012
#include "KeyHandler.h"
1113

1214
#include "Modules/Boid/BoidsSystem.h"
@@ -18,7 +20,9 @@
1820
#include <Logging/Logger.h>
1921
#include <Devices/IMouse.h>
2022
#include <Math/Vector.h>
23+
#ifdef DRAGON_SOUND
2124
#include <Sound/MusicPlayer.h>
25+
#endif
2226
#include <Scene/RenderStateNode.h>
2327

2428

@@ -35,7 +39,9 @@ KeyHandler::KeyHandler(FollowCamera& camera,
3539
BoidsSystem* boidssystem,
3640
TimeModifier& timeModifier,
3741
GameState& gamestate,
42+
#ifdef DRAGON_SOUND
3843
MusicPlayer& musicplayer,
44+
#endif
3945
IFrame& frame,
4046
RenderStateNode* rn)
4147
: camera(camera)
@@ -62,8 +68,8 @@ KeyHandler::KeyHandler(FollowCamera& camera,
6268
done = pause = false;
6369
rotChunkMouse = 0.05;
6470
moveChunkMouse = 0.0015;
65-
rotChunkKeyboard = 0.2; //rotChunkMouse*200;
66-
moveChunkKeyboard = 2; //moveChunkMouse*400;
71+
rotChunkKeyboard = 0.05; //rotChunkMouse*200;
72+
moveChunkKeyboard = 1; //moveChunkMouse*400;
6773
warping = false;
6874

6975
ResetCamera();
@@ -127,7 +133,7 @@ void KeyHandler::Handle(ProcessEventArg arg) {
127133

128134
// handle joystick.
129135

130-
float move_factor = 2.5;
136+
float move_factor = 1.0;
131137

132138
if (up)
133139
MoveForward(up*move_factor);
@@ -185,21 +191,27 @@ void KeyHandler::HandleDown(Key key) {
185191
case KEY_9:
186192
boidssystem->IncNumberOfShownBoids();
187193
break;
188-
case KEY_a:
194+
case KEY_LEFT:
189195
MoveLeft(moveChunkKeyboard);
190196
break;
191-
case KEY_d:
197+
case KEY_RIGHT:
192198
MoveRight(moveChunkKeyboard);
193199
break;
194-
case KEY_w:
200+
case KEY_UP:
195201
MoveForward(moveChunkKeyboard);
196202
break;
197-
case KEY_s:
203+
case KEY_DOWN:
198204
MoveBack(moveChunkKeyboard);
199205
break;
200-
case KEY_z:
201-
rn->ToggleOption(RenderStateNode::LIGHTING);
202-
rn->ToggleOption(RenderStateNode::WIREFRAME);
206+
case KEY_z:
207+
rn->EnableOption(RenderStateNode::WIREFRAME);
208+
break;
209+
case KEY_x:
210+
rn->DisableOption(RenderStateNode::WIREFRAME);
211+
break;
212+
213+
case KEY_j:
214+
rn->EnableOption(RenderStateNode::HARD_NORMAL);
203215
break;
204216
/*
205217
case KEY_z:
@@ -239,12 +251,14 @@ void KeyHandler::HandleDown(Key key) {
239251
case KEY_q:
240252
dragon->ChargeFireball();
241253
break;
254+
#ifdef DRAGON_SOUND
242255
case KEY_COMMA:
243256
musicplayer.SetGain(musicplayer.GetGain()-gainStep);
244257
break;
245258
case KEY_PERIOD:
246259
musicplayer.SetGain(musicplayer.GetGain()+gainStep);
247260
break;
261+
#endif
248262

249263
// case KEY_F1:
250264
// //inputgrabber->rotateViewAbsolute( 30, 5, 50, 1.0 );
@@ -274,14 +288,14 @@ void KeyHandler::HandleDown(Key key) {
274288
// break;
275289
case KEY_n: //KEY_F11
276290
if (done) return;
277-
timeFactor -= 0.1;
291+
timeFactor -= 0.01;
278292
if (timeFactor < 0.0) timeFactor = 0.0;
279293
timeModifier.SetFactor(timeFactor);
280294
logger.info << "time factor: " << timeFactor << logger.end;
281295
break;
282296
case KEY_m: //KEY_F12
283297
if (done) return;
284-
timeFactor += 0.1;
298+
timeFactor += 0.01;
285299
if (timeFactor > 100.0) timeFactor = 100.0;
286300
timeModifier.SetFactor(timeFactor);
287301
logger.info << "time factor: " << timeFactor << logger.end;
@@ -298,16 +312,16 @@ void KeyHandler::HandleDown(Key key) {
298312
case KEY_END:
299313
//inputgrabber->decMultiplier();
300314
break;
301-
case KEY_UP:
315+
case KEY_w:
302316
RotateUp(moveChunkKeyboard);
303317
break;
304-
case KEY_DOWN:
318+
case KEY_s:
305319
RotateDown(moveChunkKeyboard);
306320
break;
307-
case KEY_LEFT:
321+
case KEY_a:
308322
RotateLeft(rotChunkKeyboard);
309323
break;
310-
case KEY_RIGHT:
324+
case KEY_d:
311325
RotateRight(rotChunkKeyboard);
312326
break;
313327
default:

KeyHandler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ class KeyHandler : public IListener<ProcessEventArg>,
104104
BoidsSystem* boidssystem,
105105
TimeModifier& timeModifer,
106106
GameState& gamestate,
107+
#ifdef DRAGON_SOUND
107108
MusicPlayer& musicplayer,
109+
#endif
108110
IFrame& frame,
109111
RenderStateNode* rn);
110112
~KeyHandler();

Modules/Boid/Boid.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
// extensions
2626
#include <ParticleSystem/ParticleSystem.h>
2727
#include <Renderers/TextureLoader.h>
28+
#ifdef DRAGON_SOUND
2829
#include <Sound/IMonoSound.h>
30+
#endif
2931

3032
using OpenEngine::Math::PI;
3133
using OpenEngine::Scene::TransformationNode;
@@ -34,14 +36,20 @@ using std::max;
3436

3537
Boid::Boid(HeightMap* heightMap, OscSurface* oscsurface, BoidsSystem* boidssystem,
3638
Vector<3,float> position, Vector<3,float> forward,
37-
Vector<3,float> velocity, Vector<3,float> color, IMonoSound& voice,
39+
Vector<3,float> velocity, Vector<3,float> color,
40+
#ifdef DRAGON_SOUND
41+
IMonoSound& voice,
42+
#endif
3843
OpenEngine::ParticleSystem::ParticleSystem& oeparticlesystem,
3944
OpenEngine::Renderers::TextureLoader& texloader,
4045
ISceneNode* particleRoot):
4146

42-
particleRoot(particleRoot),
43-
oeparticlesystem(oeparticlesystem),
44-
voice(voice) {
47+
particleRoot(particleRoot),
48+
oeparticlesystem(oeparticlesystem)
49+
#ifdef DRAGON_SOUND
50+
, voice(voice)
51+
#endif
52+
{
4553

4654
this->heightMap = heightMap;
4755
this->oscsurface = oscsurface;
@@ -79,7 +87,8 @@ Boid::Boid(HeightMap* heightMap, OscSurface* oscsurface, BoidsSystem* boidssyste
7987

8088
Boid::~Boid(){
8189
// @todo how to handle deallocation of the particle renderer?
82-
particleRoot->RemoveNode(boidfire->GetSceneNode());
90+
if (particleRoot != NULL)
91+
particleRoot->RemoveNode(boidfire->GetSceneNode());
8392
delete boidfire->GetSceneNode();
8493
delete boidfire;
8594
delete fireTrans;
@@ -226,8 +235,9 @@ void Boid::updatePhysics( double timeDelta ) {
226235
void Boid::updateLocomotion( double timeDelta ) {
227236
TransformationNode* tn = boidfire->GetTransformationNode();
228237
if (tn) tn->SetPosition(position);
238+
#ifdef DRAGON_SOUND
229239
voice.SetPosition(position);
230-
240+
#endif
231241
Vector<3,float> normal = heightMap->NormalAt(position);
232242
if (airborn && drowning) normal = Vector<3,float>(0,1,0);
233243

@@ -281,7 +291,9 @@ void Boid::updateLocomotion( double timeDelta ) {
281291
}
282292
if (hot>1 && life>0) {
283293
if (!burning) {
294+
#ifdef DRAGON_SOUND
284295
voice.Play();
296+
#endif
285297
boidfire->SetActive(true);
286298
}
287299
burning = true;
@@ -326,6 +338,9 @@ void Boid::HandleFire(Vector<3,float> firePosition, float fireStrength) {
326338

327339
// Get burned
328340
float fireDist = (firePosition-position).GetLength();
341+
342+
343+
329344
if (fireDist<4.0) {
330345
burned += (4.0/fireDist)*fireStrength;
331346
}

Modules/Boid/Boid.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef _BOID_H_
22
#define _BOID_H_
33

4+
#include "../../Config.h"
5+
46
//include templated classes only
57
#include <Math/Vector.h>
68

@@ -27,19 +29,24 @@ namespace OpenEngine {
2729
using OpenEngine::Scene::ISceneNode;
2830
using OpenEngine::Scene::TransformationNode;
2931

32+
#ifdef DRAGON_SOUND
3033
namespace OpenEngine {
3134
namespace Sound {
3235
class IMonoSound;
3336
}
3437
}
3538

3639
using namespace OpenEngine::Sound;
40+
#endif
3741

3842
class Boid {
3943
public:
4044
Boid(HeightMap* heightMap, OscSurface* oscsurface, BoidsSystem* boidssystem,
4145
Vector<3,float> position, Vector<3,float> forward,
42-
Vector<3,float> velocity, Vector<3,float> color, IMonoSound& voice,
46+
Vector<3,float> velocity, Vector<3,float> color,
47+
#ifdef DRAGON_SOUND
48+
IMonoSound& voice,
49+
#endif
4350
OpenEngine::ParticleSystem::ParticleSystem& oeparticlesystem,
4451
OpenEngine::Renderers::TextureLoader& texloader,
4552
ISceneNode* particleRoot);
@@ -70,9 +77,9 @@ class Boid {
7077

7178
Vector<3,float> color;
7279
bool airborn;
73-
80+
#ifdef DRAGON_SOUND
7481
IMonoSound& voice;
75-
82+
#endif
7683
void draw2( bool shadow );
7784

7885
// accumulated variables. to accumulate force for all boids before applying it
@@ -84,7 +91,7 @@ class Boid {
8491

8592
// Vehicle model:
8693
void updatePhysics( double timeDelta );
87-
double mass, max_force, max_speed;
94+
float mass, max_force, max_speed;
8895
Vector<3,float> position, velocity, forward, up, left;
8996

9097
// Additional physics:

0 commit comments

Comments
 (0)