forked from oerkki/voxelands
walk sounds
This commit is contained in:
parent
e6854a1293
commit
c255099ec1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -33,7 +33,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
|
||||
#define CAMERA_OFFSET_STEP 200
|
||||
|
||||
Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control):
|
||||
Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control, Client *client):
|
||||
m_client(client),
|
||||
m_smgr(smgr),
|
||||
m_playernode(NULL),
|
||||
m_headnode(NULL),
|
||||
|
@ -129,25 +130,9 @@ inline f32 my_modf(f32 x)
|
|||
|
||||
void Camera::step(f32 dtime)
|
||||
{
|
||||
if (m_view_bobbing_state != 0)
|
||||
{
|
||||
//f32 offset = dtime * m_view_bobbing_speed * 0.035;
|
||||
if (m_view_bobbing_state != 0) {
|
||||
f32 offset = dtime * m_view_bobbing_speed * 0.030;
|
||||
if (m_view_bobbing_state == 2)
|
||||
{
|
||||
#if 0
|
||||
// Animation is getting turned off
|
||||
if (m_view_bobbing_anim < 0.5)
|
||||
m_view_bobbing_anim -= offset;
|
||||
else
|
||||
m_view_bobbing_anim += offset;
|
||||
if (m_view_bobbing_anim <= 0 || m_view_bobbing_anim >= 1)
|
||||
{
|
||||
m_view_bobbing_anim = 0;
|
||||
m_view_bobbing_state = 0;
|
||||
}
|
||||
#endif
|
||||
#if 1
|
||||
if (m_view_bobbing_state == 2) {
|
||||
// Animation is getting turned off
|
||||
if(m_view_bobbing_anim < 0.25){
|
||||
m_view_bobbing_anim -= offset;
|
||||
|
@ -168,10 +153,7 @@ void Camera::step(f32 dtime)
|
|||
m_view_bobbing_anim = 0;
|
||||
m_view_bobbing_state = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
}else{
|
||||
float was = m_view_bobbing_anim;
|
||||
m_view_bobbing_anim = my_modf(m_view_bobbing_anim + offset);
|
||||
if (
|
||||
|
@ -179,7 +161,7 @@ void Camera::step(f32 dtime)
|
|||
|| (was < 0.5f && m_view_bobbing_anim >= 0.5f)
|
||||
|| (was > 0.5f && m_view_bobbing_anim <= 0.5f)
|
||||
) {
|
||||
printf("step\n");
|
||||
m_client->playStepSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,17 +170,16 @@ void Camera::step(f32 dtime)
|
|||
f32 offset = dtime * 3.5;
|
||||
float m_digging_anim_was = m_digging_anim;
|
||||
m_digging_anim += offset;
|
||||
if (m_digging_anim >= 1)
|
||||
{
|
||||
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");
|
||||
m_client->playDigSound();
|
||||
}else if(m_digging_button == 1) {
|
||||
printf("place\n");
|
||||
m_client->playPlaceSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
class LocalPlayer;
|
||||
class MapDrawControl;
|
||||
class ExtrudedSpriteSceneNode;
|
||||
class Client;
|
||||
|
||||
/*
|
||||
Client camera class, manages the player and camera scene nodes, the viewing distance
|
||||
|
@ -40,7 +41,7 @@ class ExtrudedSpriteSceneNode;
|
|||
class Camera
|
||||
{
|
||||
public:
|
||||
Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control);
|
||||
Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control, Client *client);
|
||||
~Camera();
|
||||
|
||||
// Get player scene node.
|
||||
|
@ -130,6 +131,7 @@ public:
|
|||
void drawWieldedTool();
|
||||
|
||||
private:
|
||||
Client *m_client;
|
||||
// Scene manager and nodes
|
||||
scene::ISceneManager* m_smgr;
|
||||
scene::ISceneNode* m_playernode;
|
||||
|
|
|
@ -2251,3 +2251,49 @@ ISoundManager* Client::getSoundManager()
|
|||
return m_sound;
|
||||
}
|
||||
|
||||
void Client::playStepSound()
|
||||
{
|
||||
if (!m_sound)
|
||||
return;
|
||||
|
||||
v3f pf = m_env.getLocalPlayer()->getPosition();
|
||||
v3s16 pp = floatToInt(pf + v3f(0, BS*0.1, 0), BS);
|
||||
MapNode n = m_env.getMap().getNodeNoEx(pp);
|
||||
if (content_features(n).type == CMT_AIR) {
|
||||
pp.Y--;
|
||||
n = m_env.getMap().getNodeNoEx(pp);
|
||||
}
|
||||
switch (content_features(n).type) {
|
||||
case CMT_PLANT:
|
||||
m_sound->playSound("plant-walk",false,1.0);
|
||||
break;
|
||||
case CMT_DIRT:
|
||||
m_sound->playSound("dirt-walk",false,1.0);
|
||||
break;
|
||||
case CMT_STONE:
|
||||
m_sound->playSound("stone-walk",false,1.0);
|
||||
break;
|
||||
case CMT_LIQUID:
|
||||
m_sound->playSound("liquid-walk",false,1.0);
|
||||
break;
|
||||
case CMT_WOOD:
|
||||
m_sound->playSound("wood-walk",false,1.0);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
||||
void Client::playDigSound()
|
||||
{
|
||||
if (!m_sound)
|
||||
return;
|
||||
printf("dig\n");
|
||||
}
|
||||
|
||||
void Client::playPlaceSound()
|
||||
{
|
||||
if (!m_sound)
|
||||
return;
|
||||
printf("place\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -321,6 +321,10 @@ public:
|
|||
float getRTT(void);
|
||||
virtual ISoundManager* getSoundManager();
|
||||
|
||||
void playStepSound();
|
||||
void playDigSound();
|
||||
void playPlaceSound();
|
||||
|
||||
private:
|
||||
|
||||
// Virtual methods from con::PeerHandler
|
||||
|
|
|
@ -867,7 +867,7 @@ void the_game(
|
|||
/*
|
||||
Create the camera node
|
||||
*/
|
||||
Camera camera(smgr, draw_control);
|
||||
Camera camera(smgr, draw_control, &client);
|
||||
if (!camera.successfullyCreated(error_message))
|
||||
return;
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ std::string getPath(const char* tp, const std::string &filename, bool must_exist
|
|||
std::string data_path = g_settings->get("data_path");
|
||||
if (data_path != "") {
|
||||
std::string testpath = data_path + DIR_DELIM + rel_path;
|
||||
if (type == "model" || type == "html") {
|
||||
if (type == "model" || type == "html" || type == "sound") {
|
||||
if (fs::PathExists(testpath))
|
||||
fullpath = std::string(testpath);
|
||||
}else{
|
||||
|
@ -150,7 +150,7 @@ std::string getPath(const char* tp, const std::string &filename, bool must_exist
|
|||
/* check from user data directory */
|
||||
if (fullpath == "") {
|
||||
std::string testpath = porting::path_userdata + DIR_DELIM + rel_path;
|
||||
if (type == "model" || type == "html") {
|
||||
if (type == "model" || type == "html" || type == "sound") {
|
||||
if (fs::PathExists(testpath))
|
||||
fullpath = std::string(testpath);
|
||||
}else{
|
||||
|
@ -161,7 +161,7 @@ std::string getPath(const char* tp, const std::string &filename, bool must_exist
|
|||
/* check from default data directory */
|
||||
if (fullpath == "") {
|
||||
std::string testpath = porting::path_data + DIR_DELIM + rel_path;
|
||||
if (type == "model" || type == "html") {
|
||||
if (type == "model" || type == "html" || type == "sound") {
|
||||
if (fs::PathExists(testpath))
|
||||
fullpath = std::string(testpath);
|
||||
}else{
|
||||
|
|
|
@ -24,5 +24,44 @@ DummySoundManager dummySoundManager;
|
|||
|
||||
void init_sounds(ISoundManager *sound)
|
||||
{
|
||||
sound->loadSound("grass-walk","grass_footstep.1.ogg");
|
||||
// walking
|
||||
// CMT_DIRT
|
||||
sound->loadSound("dirt-walk","dirt_footstep.1.ogg");
|
||||
sound->loadSound("dirt-walk","dirt_footstep.2.ogg");
|
||||
sound->loadSound("dirt-walk","dirt_footstep.3.ogg");
|
||||
sound->loadSound("dirt-walk","dirt_footstep.4.ogg");
|
||||
// CMT_STONE
|
||||
sound->loadSound("stone-walk","stone_footstep.1.ogg");
|
||||
sound->loadSound("stone-walk","stone_footstep.2.ogg");
|
||||
sound->loadSound("stone-walk","stone_footstep.3.ogg");
|
||||
sound->loadSound("stone-walk","stone_footstep.4.ogg");
|
||||
// CMT_PLANT
|
||||
sound->loadSound("plant-walk","plant_footstep.1.ogg");
|
||||
sound->loadSound("plant-walk","plant_footstep.2.ogg");
|
||||
sound->loadSound("plant-walk","plant_footstep.3.ogg");
|
||||
sound->loadSound("plant-walk","plant_footstep.4.ogg");
|
||||
// CMT_LIQUID
|
||||
sound->loadSound("liquid-walk","liquid_footstep.1.ogg");
|
||||
sound->loadSound("liquid-walk","liquid_footstep.2.ogg");
|
||||
sound->loadSound("liquid-walk","liquid_footstep.3.ogg");
|
||||
sound->loadSound("liquid-walk","liquid_footstep.4.ogg");
|
||||
// CMT_WOOD
|
||||
sound->loadSound("wood-walk","wood_footstep.1.ogg");
|
||||
sound->loadSound("wood-walk","wood_footstep.2.ogg");
|
||||
sound->loadSound("wood-walk","wood_footstep.3.ogg");
|
||||
sound->loadSound("wood-walk","wood_footstep.4.ogg");
|
||||
|
||||
// digging
|
||||
// CMT_DIRT
|
||||
// CMT_STONE
|
||||
// CMT_PLANT
|
||||
// CMT_LIQUID
|
||||
// CMT_WOOD
|
||||
|
||||
// placing
|
||||
// CMT_DIRT
|
||||
// CMT_STONE
|
||||
// CMT_PLANT
|
||||
// CMT_LIQUID
|
||||
// CMT_WOOD
|
||||
}
|
||||
|
|
|
@ -262,6 +262,7 @@ public:
|
|||
}
|
||||
std::vector<SoundBuffer*> bufs;
|
||||
bufs.push_back(buf);
|
||||
m_buffers[name] = bufs;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue