forked from oerkki/voxelands
setup for sound triggers
This commit is contained in:
parent
7191179d46
commit
e6854a1293
Binary file not shown.
|
@ -172,19 +172,35 @@ void Camera::step(f32 dtime)
|
|||
}
|
||||
else
|
||||
{
|
||||
float was = m_view_bobbing_anim;
|
||||
m_view_bobbing_anim = my_modf(m_view_bobbing_anim + offset);
|
||||
if (
|
||||
was == 0
|
||||
|| (was < 0.5f && m_view_bobbing_anim >= 0.5f)
|
||||
|| (was > 0.5f && m_view_bobbing_anim <= 0.5f)
|
||||
) {
|
||||
printf("step\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_digging_button != -1)
|
||||
{
|
||||
if (m_digging_button != -1) {
|
||||
f32 offset = dtime * 3.5;
|
||||
float m_digging_anim_was = m_digging_anim;
|
||||
m_digging_anim += offset;
|
||||
if (m_digging_anim >= 1)
|
||||
{
|
||||
m_digging_anim = 0;
|
||||
m_digging_button = -1;
|
||||
}
|
||||
float lim = 0.15;
|
||||
if (m_digging_anim_was < lim && m_digging_anim >= lim) {
|
||||
if (m_digging_button == 0) {
|
||||
printf("dig\n");
|
||||
}else if(m_digging_button == 1) {
|
||||
printf("place\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,7 +226,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
|
|||
f32 bobfrac = my_modf(m_view_bobbing_anim * 2);
|
||||
f32 bobdir = (m_view_bobbing_anim < 0.5) ? 1.0 : -1.0;
|
||||
|
||||
#if 1
|
||||
#if 1
|
||||
f32 bobknob = 1.2;
|
||||
f32 bobtmp = sin(pow(bobfrac, bobknob) * PI);
|
||||
//f32 bobtmp2 = cos(pow(bobfrac, bobknob) * PI);
|
||||
|
@ -232,7 +248,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
|
|||
//rel_cam_target.X -= 0.005 * bobvec.X * f;
|
||||
//rel_cam_target.Y -= 0.005 * bobvec.Y * f;
|
||||
rel_cam_up.rotateXYBy(-0.03 * bobdir * bobtmp * PI * f);
|
||||
#else
|
||||
#else
|
||||
f32 angle_deg = 1 * bobdir * sin(bobfrac * PI);
|
||||
f32 angle_rad = angle_deg * PI / 180;
|
||||
f32 r = 0.05;
|
||||
|
@ -243,7 +259,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
|
|||
rel_cam_pos += off;
|
||||
//rel_cam_target += off;
|
||||
rel_cam_up.rotateXYBy(angle_deg);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -185,7 +185,8 @@ Client::Client(
|
|||
IrrlichtDevice *device,
|
||||
const char *playername,
|
||||
std::string password,
|
||||
MapDrawControl &control):
|
||||
MapDrawControl &control,
|
||||
ISoundManager *sound):
|
||||
m_mesh_update_thread(),
|
||||
m_env(
|
||||
new ClientMap(this, control,
|
||||
|
@ -194,6 +195,7 @@ Client::Client(
|
|||
device->getSceneManager()
|
||||
),
|
||||
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this),
|
||||
m_sound(sound),
|
||||
m_device(device),
|
||||
m_server_ser_ver(SER_FMT_VER_INVALID),
|
||||
m_inventory_updated(false),
|
||||
|
@ -2244,6 +2246,8 @@ float Client::getRTT(void)
|
|||
|
||||
ISoundManager* Client::getSoundManager()
|
||||
{
|
||||
return &dummySoundManager;
|
||||
if (m_sound == NULL)
|
||||
return &dummySoundManager;
|
||||
return m_sound;
|
||||
}
|
||||
|
||||
|
|
12
src/client.h
12
src/client.h
|
@ -155,11 +155,12 @@ public:
|
|||
*/
|
||||
|
||||
Client(
|
||||
IrrlichtDevice *device,
|
||||
const char *playername,
|
||||
std::string password,
|
||||
MapDrawControl &control
|
||||
);
|
||||
IrrlichtDevice *device,
|
||||
const char *playername,
|
||||
std::string password,
|
||||
MapDrawControl &control,
|
||||
ISoundManager *sound
|
||||
);
|
||||
|
||||
~Client();
|
||||
/*
|
||||
|
@ -348,6 +349,7 @@ private:
|
|||
|
||||
con::Connection m_con;
|
||||
HTTPClient *m_httpclient;
|
||||
ISoundManager *m_sound;
|
||||
|
||||
IrrlichtDevice *m_device;
|
||||
|
||||
|
|
|
@ -728,7 +728,8 @@ void the_game(
|
|||
std::string address,
|
||||
u16 port,
|
||||
std::wstring &error_message,
|
||||
std::string configpath
|
||||
std::string configpath,
|
||||
ISoundManager *sound
|
||||
)
|
||||
{
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
|
@ -770,7 +771,7 @@ void the_game(
|
|||
draw_load_screen(L"Creating client...", driver, font);
|
||||
infostream<<"Creating client"<<std::endl;
|
||||
MapDrawControl draw_control;
|
||||
Client client(device, playername.c_str(), password, draw_control);
|
||||
Client client(device, playername.c_str(), password, draw_control, sound);
|
||||
|
||||
draw_load_screen(L"Resolving address...", driver, font);
|
||||
Address connect_address(0,0,0,0, port);
|
||||
|
|
|
@ -122,6 +122,8 @@ public:
|
|||
virtual void clear() {};
|
||||
};
|
||||
|
||||
class ISoundManager;
|
||||
|
||||
void the_game(
|
||||
bool &kill,
|
||||
bool random_input,
|
||||
|
@ -134,7 +136,8 @@ void the_game(
|
|||
std::string address,
|
||||
u16 port,
|
||||
std::wstring &error_message,
|
||||
std::string configpath
|
||||
std::string configpath,
|
||||
ISoundManager *sound
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -920,6 +920,8 @@ int main(int argc, char *argv[])
|
|||
// (for texture atlas making)
|
||||
init_mineral();
|
||||
|
||||
ISoundManager *sound = createSoundManager();
|
||||
|
||||
/*
|
||||
Run unit tests
|
||||
*/
|
||||
|
@ -1324,7 +1326,8 @@ int main(int argc, char *argv[])
|
|||
address,
|
||||
port,
|
||||
error_message,
|
||||
configpath
|
||||
configpath,
|
||||
sound
|
||||
);
|
||||
|
||||
} //try
|
||||
|
|
|
@ -22,3 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
// Global DummySoundManager singleton
|
||||
DummySoundManager dummySoundManager;
|
||||
|
||||
void init_sounds(ISoundManager *sound)
|
||||
{
|
||||
sound->loadSound("grass-walk","grass_footstep.1.ogg");
|
||||
}
|
||||
|
|
|
@ -90,6 +90,9 @@ public:
|
|||
void updateSoundPosition(int sound, v3f pos) {}
|
||||
};
|
||||
|
||||
ISoundManager *createSoundManager();
|
||||
void init_sounds(ISoundManager *sound);
|
||||
|
||||
// Global DummySoundManager singleton
|
||||
extern DummySoundManager dummySoundManager;
|
||||
|
||||
|
|
|
@ -463,7 +463,9 @@ public:
|
|||
|
||||
ISoundManager *createSoundManager()
|
||||
{
|
||||
return new OpenALSoundManager();
|
||||
ISoundManager *sound = new OpenALSoundManager();
|
||||
init_sounds(sound);
|
||||
return sound;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue