Skip to content

Commit

Permalink
water sfx and general fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kade-github committed May 18, 2024
1 parent 6285e02 commit d7304cc
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 5 deletions.
Binary file added Assets/Sfx/water_in.ogg
Binary file not shown.
Binary file added Assets/Sfx/water_out.ogg
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Game/Data/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Settings
bool vsync = true;
bool fullscreen = false;

bool useAmbientDiffuse = false;
bool useAmbientDiffuse = true;

void Load();
void Save();
Expand Down
6 changes: 5 additions & 1 deletion src/Game/Data/Structures/Ruins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,10 @@ void Data::Ruins::Create(int x, int z, int y, Data::Chunk& c, Data::Region* r)
return;
}


for (BlueprintBlock& block : b.blocks)
r->freePlace(_x + block.x, y - block.y, _z + block.z, block.type);
{
float realY = y - block.y;
r->freePlace(_x + block.x, realY, _z + block.z, block.type);
}
}
10 changes: 10 additions & 0 deletions src/Game/Data/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ void Data::Region::freePlace(int x, int y, int z, int type)
c->placeBlock(x - c->x, y, z - c->z, type);
}

bool Data::Region::doesBlockExist(int x, int y, int z)
{
Chunk* c = getChunkPtr(x, z);

if (c == nullptr)
return false;

return c->bChunk.blocks[x - c->x][z - c->z][y] > 0;
}

bool Data::Region::doesBlockExistInRange(int x, int y, int z, int type, int range)
{
std::lock_guard<std::mutex> lock(m);
Expand Down
5 changes: 3 additions & 2 deletions src/Game/Data/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ namespace Data
{
public:
bool isGenerated = false;
BlockChunk bChunk;
BlockChunk bChunk = {};
int32_t x, z;
DataChunk data;
DataChunk data = {};

void placeBlock(int x, int y, int z, uint8_t block)
{
Expand Down Expand Up @@ -262,6 +262,7 @@ namespace Data
void freePlace(int x, int y, int z, int type);

bool doesBlockExistInRange(int x, int y, int z, int type, int range);
bool doesBlockExist(int x, int y, int z);

Chunk generateChunk(int x, int z);

Expand Down
17 changes: 17 additions & 0 deletions src/Game/Objects/Base/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,23 @@ void Entity::Draw()
else
inWater = topWater;

if (inWater && !waterSoundEntrance)
{
waterSoundEntrance = true;

float pitch = 1.0f + ((rand() % 20) - 10) / 100.0f;

MusicManager::GetInstance()->PlaySFX("water_in", position, pitch, "enter");
}
else if (!inWater && waterSoundEntrance)
{
waterSoundEntrance = false;

float pitch = 1.0f + ((rand() % 20) - 10) / 100.0f;

MusicManager::GetInstance()->PlaySFX("water_out", position, pitch, "exit");
}

if (glfwGetTime() - lightUpdate > 0.1)
{
lightUpdate = glfwGetTime();
Expand Down
1 change: 1 addition & 0 deletions src/Game/Objects/Base/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
class Entity : public GameObject
{
int lightUpdate = 0;
bool waterSoundEntrance = false;
public:
Sprite3D* shadow;

Expand Down
2 changes: 1 addition & 1 deletion src/Game/Scenes/Gameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ void Gameplay::UpdateChunks()

float angle = camera->YawAngleTo(fakePosC);

if ((angle <= 260 || distance <= 32) && distance <= fog + 32)
if ((angle <= 300 || distance <= 64) && distance <= fog + 64)
{
if (!c->isRendered || c->pleaseRender)
{
Expand Down

0 comments on commit d7304cc

Please sign in to comment.