From 9b56a9b4a57f47c57e0b7f956548aef16865d602 Mon Sep 17 00:00:00 2001 From: MarcEricMartel <74071476+MarcEricMartel@users.noreply.github.com> Date: Wed, 8 Dec 2021 16:29:36 -0500 Subject: [PATCH] Done! --- SQCSim2021/audio.cpp | 2 +- SQCSim2021/audio.h | 6 +++--- SQCSim2021/engine.cpp | 2 +- SQCSim2021/engine.h | 2 -- SQCSim2021/player.cpp | 5 +++-- SQCSim2021/world.cpp | 6 ++---- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/SQCSim2021/audio.cpp b/SQCSim2021/audio.cpp index fcea86b..afde709 100644 --- a/SQCSim2021/audio.cpp +++ b/SQCSim2021/audio.cpp @@ -28,7 +28,7 @@ void Audio::Update3DAudio(Vector3f pos, Vector3f dir, Vector3f vel) { irrklang::vec3df(vel.x, vel.y, vel.z)); } -void Audio::Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f& pos, Vector3f& vel, float volume = 1) { +void Audio::Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, float volume = 1) { sound = m_engine->play3D(name, irrklang::vec3df(pos.x, pos.y, pos.z), false, false, true, irrklang::ESM_NO_STREAMING, true); sound->setVelocity(irrklang::vec3df(vel.x, vel.y, vel.z)); sound->setVolume(volume); diff --git a/SQCSim2021/audio.h b/SQCSim2021/audio.h index cd0e6a9..923b7d9 100644 --- a/SQCSim2021/audio.h +++ b/SQCSim2021/audio.h @@ -1,8 +1,8 @@ #ifndef AUDIO_H__ #define AUDIO_H__ -#include "external/irrKlang-1.6.0/include/irrklang.h" -#include "external/irrKlang-1.6.0/include/ik_ISoundSource.h" +#include +#include #include "define.h" #include "vector3.h" @@ -18,7 +18,7 @@ public: void Update3DAudio(Vector3f pos, Vector3f dir, Vector3f speed); - void Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f& pos, Vector3f& vel, float volume); + void Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, float volume); void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume); diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 9389499..3058c86 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -259,7 +259,7 @@ void Engine::Render(float elapsedTime) { if (m_wireframe) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - static bool fell = false; + static bool fell = false; if (m_player.GetPosition().y < 1.7f && !fell) { m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), 1.f); fell = true; diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 6b0d622..f00924e 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -41,7 +41,6 @@ private: bool m_isSkybox = true; int m_renderCount = 0; - int m_badHitCount = 0; Shader m_shader01; BlockInfo* m_blockinfo[BTYPE_LAST]; @@ -58,7 +57,6 @@ private: Audio m_audio = Audio(AUDIO_PATH "music01.wav"); irrklang::ISound* m_powpow; - irrklang::ISound* m_step; irrklang::ISound* m_scream; Player m_player = Player(Vector3f(0, CHUNK_SIZE_Y + 1.8f, 0)); diff --git a/SQCSim2021/player.cpp b/SQCSim2021/player.cpp index 13b080a..37717a4 100644 --- a/SQCSim2021/player.cpp +++ b/SQCSim2021/player.cpp @@ -156,10 +156,11 @@ void Player::ApplyPhysics(Vector3f input, World world, float elapsedTime, Audio* if ((sin(bobbingtime) - 0.5f) * (abs(m_velocity.x) + abs(m_velocity.z)) < -.2f && !m_airborne) { Vector3f vstep; if (leftright) - vstep = Vector3f(GetPosition().x - GetDirection().x, GetPosition().y, GetPosition().z + GetDirection().z); - else vstep = Vector3f(GetPosition().x + GetDirection().x, GetPosition().y, GetPosition().z - GetDirection().z); + vstep = Vector3f(GetPosition().x + GetDirection().z, GetPosition().y - 1.7f, GetPosition().z + GetDirection().x); + else vstep = Vector3f(GetPosition().x - GetDirection().z, GetPosition().y - 1.7f, GetPosition().z - GetDirection().x); if (!isStep) { audio->Create3DAudioObj(step, AUDIO_PATH "step.wav", vstep, GetVelocity(), .8f); + leftright = !leftright; } isStep = true; } diff --git a/SQCSim2021/world.cpp b/SQCSim2021/world.cpp index 272ea8f..49a3cfb 100644 --- a/SQCSim2021/world.cpp +++ b/SQCSim2021/world.cpp @@ -39,8 +39,7 @@ BlockType World::BlockAt(const Vector3f& pos, BlockType defaultBlockType) const } void World::TransposeWorld(Player& player, Bullet* bullets[MAX_BULLETS]) { - int x = 0; - int y = 0; + int x = 0, y = 0; if (player.GetPosition().x > (WORLD_SIZE_X * CHUNK_SIZE_X) * .66f) ++x; else if (player.GetPosition().x < (WORLD_SIZE_X * CHUNK_SIZE_X) * .33f) --x; @@ -211,12 +210,12 @@ bool World::GenerateChunk(int chx, int chy, Perlin& perlin) { } void World::UpdateChunk(int& generates, int& updates, int chx, int chy, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]) { - if (generates == 0 && GenerateChunk(chx, chy, perlin)) generates = FRAMES_RENDER_CHUNKS; if (updates == 0 && ChunkAt(chx, 1, chy) && ChunkAt(chx, 1, chy)->IsDirty()) { ChunkAt(chx, 1, chy)->Update(blockinfo, this); updates = FRAMES_UPDATE_CHUNKS; } + if (generates == 0 && GenerateChunk(chx, chy, perlin)) generates = FRAMES_RENDER_CHUNKS; } void World::ChangeBlockAtCursor(BlockType blockType, Player& player, bool& block) { @@ -276,7 +275,6 @@ void World::ChangeBlockAtCursor(BlockType blockType, Player& player, bool& block } } - void World::ChangeBlockAtPosition(BlockType blockType, Vector3f pos) { int bx = (int)pos.x % CHUNK_SIZE_X; int by = (int)pos.y % CHUNK_SIZE_Y;