Rearrangements; Audio support

This commit is contained in:
2025-08-30 21:06:56 +03:00
parent 503db60c60
commit 657107b4ae
30 changed files with 95935 additions and 57 deletions

View File

@@ -13,6 +13,8 @@
#include "src/terrain/terrain.h"
#include "water/water.h"
#include "src/characters/controller.h"
#include "GameData.h"
#include "sound.h"
class App;
class SkyRenderer : public Ogre::SceneManager::Listener {
protected:
@@ -268,7 +270,6 @@ class App : public OgreBites::ApplicationContext {
App *mApp;
public:
Ogre::Vector3 motion;
bool gui_active;
Ogre::Timer fps_timer;
bool fast;
@@ -282,6 +283,7 @@ class App : public OgreBites::ApplicationContext {
}
bool keyPressed(const OgreBites::KeyboardEvent &evt) override
{
bool updated = false;
if (gui_active)
return false;
if (evt.keysym.sym == OgreBites::SDLK_ESCAPE) {
@@ -292,38 +294,12 @@ class App : public OgreBites::ApplicationContext {
return true;
}
return false;
if (evt.keysym.sym == OgreBites::SDLK_SPACE) {
mApp->dump_water();
}
if (evt.keysym.sym == 'w')
motion.z = -1.0f;
if (evt.keysym.sym == 's')
motion.z = 1.0f;
if (evt.keysym.sym == 'a')
motion.x = -1.0f;
if (evt.keysym.sym == 'd')
motion.x = 1.0f;
if (evt.keysym.sym == OgreBites::SDLK_LSHIFT)
fast = true;
// std::cout << "motion: " << motion << "\n";
return true;
}
bool keyReleased(const OgreBites::KeyboardEvent &evt) override
{
if (gui_active)
return false;
return false;
if (evt.keysym.sym == 'w' && motion.z < 0.0f)
motion.z = 0.0f;
if (evt.keysym.sym == 's' && motion.z > 0.0f)
motion.z = 0.0f;
if (evt.keysym.sym == 'a' && motion.x < 0.0f)
motion.x = 0.0f;
if (evt.keysym.sym == 'd' && motion.x > 0.0f)
motion.x = 0.0f;
if (evt.keysym.sym == OgreBites::SDLK_LSHIFT)
fast = false;
return true;
}
bool mouseMoved(const OgreBites::MouseMotionEvent &evt)
{
@@ -367,8 +343,10 @@ class App : public OgreBites::ApplicationContext {
update(evt.timeSinceLastFrame);
if (mApp->getCharacterController() && gui_active)
mApp->getCharacterController()->disableUpdates();
else if (mApp->getCharacterController() && !gui_active && mApp->isTerrainReady()) {
OgreAssert(mApp->isTerrainReady(), "terrain is not ready");
else if (mApp->getCharacterController() &&
!gui_active && mApp->isTerrainReady()) {
OgreAssert(mApp->isTerrainReady(),
"terrain is not ready");
mApp->getCharacterController()->enableUpdates();
}
if (!gui_active) {
@@ -408,6 +386,9 @@ public:
// getRenderWindow());
mDbgDraw.reset(new Ogre::Bullet::DebugDrawer(
mScnMgr->getRootSceneNode(), mDynWorld->getBtWorld()));
ECS::setup();
Sound::setup();
Sound::ding();
}
void locateResources() override
{
@@ -555,7 +536,8 @@ public:
void updateTerrain(float delta)
{
Ogre::Vector3 pos = mCharacterController->getPosition();
if (!mTerrainReady && m_terrain.isLoadedAt(pos) && mCharacterController->checkGround()) {
if (!mTerrainReady && m_terrain.isLoadedAt(pos) &&
mCharacterController->checkGround()) {
std::cout << "terrain ready\n";
mTerrainReady = true;
}
@@ -575,6 +557,7 @@ public:
void updateWorld(float delta)
{
mDynWorld->getBtWorld()->stepSimulation(delta, 4);
ECS::update(delta);
}
void updateWater(float delta)
{