diff --git a/src/7.in_practice/3.2d_game/audio/bleep.mp3 b/resources/audio/bleep.mp3 similarity index 100% rename from src/7.in_practice/3.2d_game/audio/bleep.mp3 rename to resources/audio/bleep.mp3 diff --git a/src/7.in_practice/3.2d_game/audio/bleep.wav b/resources/audio/bleep.wav similarity index 100% rename from src/7.in_practice/3.2d_game/audio/bleep.wav rename to resources/audio/bleep.wav diff --git a/src/7.in_practice/3.2d_game/audio/breakout.mp3 b/resources/audio/breakout.mp3 similarity index 100% rename from src/7.in_practice/3.2d_game/audio/breakout.mp3 rename to resources/audio/breakout.mp3 diff --git a/src/7.in_practice/3.2d_game/audio/powerup.wav b/resources/audio/powerup.wav similarity index 100% rename from src/7.in_practice/3.2d_game/audio/powerup.wav rename to resources/audio/powerup.wav diff --git a/src/7.in_practice/3.2d_game/audio/solid.wav b/resources/audio/solid.wav similarity index 100% rename from src/7.in_practice/3.2d_game/audio/solid.wav rename to resources/audio/solid.wav diff --git a/src/7.in_practice/3.2d_game/fonts/OCRAEXT.TTF b/resources/fonts/OCRAEXT.TTF similarity index 100% rename from src/7.in_practice/3.2d_game/fonts/OCRAEXT.TTF rename to resources/fonts/OCRAEXT.TTF diff --git a/src/7.in_practice/3.2d_game/levels/four.lvl b/resources/levels/four.lvl similarity index 100% rename from src/7.in_practice/3.2d_game/levels/four.lvl rename to resources/levels/four.lvl diff --git a/src/7.in_practice/3.2d_game/levels/one.lvl b/resources/levels/one.lvl similarity index 100% rename from src/7.in_practice/3.2d_game/levels/one.lvl rename to resources/levels/one.lvl diff --git a/src/7.in_practice/3.2d_game/levels/three.lvl b/resources/levels/three.lvl similarity index 100% rename from src/7.in_practice/3.2d_game/levels/three.lvl rename to resources/levels/three.lvl diff --git a/src/7.in_practice/3.2d_game/levels/two.lvl b/resources/levels/two.lvl similarity index 100% rename from src/7.in_practice/3.2d_game/levels/two.lvl rename to resources/levels/two.lvl diff --git a/src/7.in_practice/3.2d_game/textures/background.jpg b/resources/textures/background.jpg similarity index 100% rename from src/7.in_practice/3.2d_game/textures/background.jpg rename to resources/textures/background.jpg diff --git a/src/7.in_practice/3.2d_game/textures/block.png b/resources/textures/block.png similarity index 100% rename from src/7.in_practice/3.2d_game/textures/block.png rename to resources/textures/block.png diff --git a/src/7.in_practice/3.2d_game/textures/block_solid.png b/resources/textures/block_solid.png similarity index 100% rename from src/7.in_practice/3.2d_game/textures/block_solid.png rename to resources/textures/block_solid.png diff --git a/src/7.in_practice/3.2d_game/textures/paddle.png b/resources/textures/paddle.png similarity index 100% rename from src/7.in_practice/3.2d_game/textures/paddle.png rename to resources/textures/paddle.png diff --git a/src/7.in_practice/3.2d_game/textures/particle.png b/resources/textures/particle.png similarity index 100% rename from src/7.in_practice/3.2d_game/textures/particle.png rename to resources/textures/particle.png diff --git a/src/7.in_practice/3.2d_game/textures/powerup_chaos.png b/resources/textures/powerup_chaos.png similarity index 100% rename from src/7.in_practice/3.2d_game/textures/powerup_chaos.png rename to resources/textures/powerup_chaos.png diff --git a/src/7.in_practice/3.2d_game/textures/powerup_confuse.png b/resources/textures/powerup_confuse.png similarity index 100% rename from src/7.in_practice/3.2d_game/textures/powerup_confuse.png rename to resources/textures/powerup_confuse.png diff --git a/src/7.in_practice/3.2d_game/textures/powerup_increase.png b/resources/textures/powerup_increase.png similarity index 100% rename from src/7.in_practice/3.2d_game/textures/powerup_increase.png rename to resources/textures/powerup_increase.png diff --git a/src/7.in_practice/3.2d_game/textures/powerup_passthrough.png b/resources/textures/powerup_passthrough.png similarity index 100% rename from src/7.in_practice/3.2d_game/textures/powerup_passthrough.png rename to resources/textures/powerup_passthrough.png diff --git a/src/7.in_practice/3.2d_game/textures/powerup_speed.png b/resources/textures/powerup_speed.png similarity index 100% rename from src/7.in_practice/3.2d_game/textures/powerup_speed.png rename to resources/textures/powerup_speed.png diff --git a/src/7.in_practice/3.2d_game/textures/powerup_sticky.png b/resources/textures/powerup_sticky.png similarity index 100% rename from src/7.in_practice/3.2d_game/textures/powerup_sticky.png rename to resources/textures/powerup_sticky.png diff --git a/src/7.in_practice/3.2d_game/game.cpp b/src/7.in_practice/3.2d_game/game.cpp index 8e5e385..8e281ab 100644 --- a/src/7.in_practice/3.2d_game/game.cpp +++ b/src/7.in_practice/3.2d_game/game.cpp @@ -8,6 +8,9 @@ ******************************************************************/ #include #include +#include + +#include #include using namespace irrklang; @@ -54,9 +57,9 @@ Game::~Game() void Game::Init() { // load shaders - ResourceManager::LoadShader("shaders/sprite.vs", "shaders/sprite.frag", nullptr, "sprite"); - ResourceManager::LoadShader("shaders/particle.vs", "shaders/particle.frag", nullptr, "particle"); - ResourceManager::LoadShader("shaders/post_processing.vs", "shaders/post_processing.frag", nullptr, "postprocessing"); + ResourceManager::LoadShader("sprite.vs", "sprite.fs", nullptr, "sprite"); + ResourceManager::LoadShader("particle.vs", "particle.fs", nullptr, "particle"); + ResourceManager::LoadShader("post_processing.vs", "post_processing.fs", nullptr, "postprocessing"); // configure shaders glm::mat4 projection = glm::ortho(0.0f, static_cast(this->Width), static_cast(this->Height), 0.0f, -1.0f, 1.0f); ResourceManager::GetShader("sprite").Use().SetInteger("sprite", 0); @@ -64,29 +67,29 @@ void Game::Init() ResourceManager::GetShader("particle").Use().SetInteger("sprite", 0); ResourceManager::GetShader("particle").SetMatrix4("projection", projection); // load textures - ResourceManager::LoadTexture("textures/background.jpg", false, "background"); - ResourceManager::LoadTexture("textures/awesomeface.png", true, "face"); - ResourceManager::LoadTexture("textures/block.png", false, "block"); - ResourceManager::LoadTexture("textures/block_solid.png", false, "block_solid"); - ResourceManager::LoadTexture("textures/paddle.png", true, "paddle"); - ResourceManager::LoadTexture("textures/particle.png", true, "particle"); - ResourceManager::LoadTexture("textures/powerup_speed.png", true, "powerup_speed"); - ResourceManager::LoadTexture("textures/powerup_sticky.png", true, "powerup_sticky"); - ResourceManager::LoadTexture("textures/powerup_increase.png", true, "powerup_increase"); - ResourceManager::LoadTexture("textures/powerup_confuse.png", true, "powerup_confuse"); - ResourceManager::LoadTexture("textures/powerup_chaos.png", true, "powerup_chaos"); - ResourceManager::LoadTexture("textures/powerup_passthrough.png", true, "powerup_passthrough"); + ResourceManager::LoadTexture(FileSystem::getPath("resources/textures/background.jpg").c_str(), false, "background"); + ResourceManager::LoadTexture(FileSystem::getPath("resources/textures/awesomeface.png").c_str(), true, "face"); + ResourceManager::LoadTexture(FileSystem::getPath("resources/textures/block.png").c_str(), false, "block"); + ResourceManager::LoadTexture(FileSystem::getPath("resources/textures/block_solid.png").c_str(), false, "block_solid"); + ResourceManager::LoadTexture(FileSystem::getPath("resources/textures/paddle.png").c_str(), true, "paddle"); + ResourceManager::LoadTexture(FileSystem::getPath("resources/textures/particle.png").c_str(), true, "particle"); + ResourceManager::LoadTexture(FileSystem::getPath("resources/textures/powerup_speed.png").c_str(), true, "powerup_speed"); + ResourceManager::LoadTexture(FileSystem::getPath("resources/textures/powerup_sticky.png").c_str(), true, "powerup_sticky"); + ResourceManager::LoadTexture(FileSystem::getPath("resources/textures/powerup_increase.png").c_str(), true, "powerup_increase"); + ResourceManager::LoadTexture(FileSystem::getPath("resources/textures/powerup_confuse.png").c_str(), true, "powerup_confuse"); + ResourceManager::LoadTexture(FileSystem::getPath("resources/textures/powerup_chaos.png").c_str(), true, "powerup_chaos"); + ResourceManager::LoadTexture(FileSystem::getPath("resources/textures/powerup_passthrough.png").c_str(), true, "powerup_passthrough"); // set render-specific controls Renderer = new SpriteRenderer(ResourceManager::GetShader("sprite")); Particles = new ParticleGenerator(ResourceManager::GetShader("particle"), ResourceManager::GetTexture("particle"), 500); Effects = new PostProcessor(ResourceManager::GetShader("postprocessing"), this->Width, this->Height); Text = new TextRenderer(this->Width, this->Height); - Text->Load("fonts/OCRAEXT.TTF", 24); + Text->Load(FileSystem::getPath("resources/fonts/OCRAEXT.TTF").c_str(), 24); // load levels - GameLevel one; one.Load("levels/one.lvl", this->Width, this->Height / 2); - GameLevel two; two.Load("levels/two.lvl", this->Width, this->Height /2 ); - GameLevel three; three.Load("levels/three.lvl", this->Width, this->Height / 2); - GameLevel four; four.Load("levels/four.lvl", this->Width, this->Height / 2); + GameLevel one; one.Load(FileSystem::getPath("resources/levels/one.lvl").c_str(), this->Width, this->Height / 2); + GameLevel two; two.Load(FileSystem::getPath("resources/levels/two.lvl").c_str(), this->Width, this->Height /2 ); + GameLevel three; three.Load(FileSystem::getPath("resources/levels/three.lvl").c_str(), this->Width, this->Height / 2); + GameLevel four; four.Load(FileSystem::getPath("resources/levels/four.lvl").c_str(), this->Width, this->Height / 2); this->Levels.push_back(one); this->Levels.push_back(two); this->Levels.push_back(three); @@ -98,7 +101,7 @@ void Game::Init() glm::vec2 ballPos = playerPos + glm::vec2(PLAYER_SIZE.x / 2.0f - BALL_RADIUS, -BALL_RADIUS * 2.0f); Ball = new BallObject(ballPos, BALL_RADIUS, INITIAL_BALL_VELOCITY, ResourceManager::GetTexture("face")); // audio - SoundEngine->play2D("audio/breakout.mp3", true); + SoundEngine->play2D(FileSystem::getPath("resources/audio/breakout.mp3").c_str(), true); } void Game::Update(float dt) @@ -413,13 +416,13 @@ void Game::DoCollisions() { box.Destroyed = true; this->SpawnPowerUps(box); - SoundEngine->play2D("audio/bleep.mp3", false); + SoundEngine->play2D(FileSystem::getPath("resources/audio/bleep.mp3").c_str(), false); } else { // if block is solid, enable shake effect ShakeTime = 0.05f; Effects->Shake = true; - SoundEngine->play2D("audio/solid.wav", false); + SoundEngine->play2D(FileSystem::getPath("resources/audio/bleep.mp3").c_str(), false); } // collision resolution Direction dir = std::get<1>(collision); @@ -465,7 +468,7 @@ void Game::DoCollisions() ActivatePowerUp(powerUp); powerUp.Destroyed = true; powerUp.Activated = true; - SoundEngine->play2D("audio/powerup.wav", false); + SoundEngine->play2D(FileSystem::getPath("resources/audio/powerup.wav").c_str(), false); } } } @@ -490,7 +493,7 @@ void Game::DoCollisions() // if Sticky powerup is activated, also stick ball to paddle once new velocity vectors were calculated Ball->Stuck = Ball->Sticky; - SoundEngine->play2D("audio/bleep.wav", false); + SoundEngine->play2D(FileSystem::getPath("resources/audio/bleep.wav").c_str(), false); } } diff --git a/src/7.in_practice/3.2d_game/shaders/particle.frag b/src/7.in_practice/3.2d_game/particle.fs similarity index 100% rename from src/7.in_practice/3.2d_game/shaders/particle.frag rename to src/7.in_practice/3.2d_game/particle.fs diff --git a/src/7.in_practice/3.2d_game/shaders/particle.vs b/src/7.in_practice/3.2d_game/particle.vs similarity index 100% rename from src/7.in_practice/3.2d_game/shaders/particle.vs rename to src/7.in_practice/3.2d_game/particle.vs diff --git a/src/7.in_practice/3.2d_game/shaders/post_processing.frag b/src/7.in_practice/3.2d_game/post_processing.fs similarity index 100% rename from src/7.in_practice/3.2d_game/shaders/post_processing.frag rename to src/7.in_practice/3.2d_game/post_processing.fs diff --git a/src/7.in_practice/3.2d_game/shaders/post_processing.vs b/src/7.in_practice/3.2d_game/post_processing.vs similarity index 100% rename from src/7.in_practice/3.2d_game/shaders/post_processing.vs rename to src/7.in_practice/3.2d_game/post_processing.vs diff --git a/src/7.in_practice/3.2d_game/shaders/sprite.frag b/src/7.in_practice/3.2d_game/sprite.fs similarity index 100% rename from src/7.in_practice/3.2d_game/shaders/sprite.frag rename to src/7.in_practice/3.2d_game/sprite.fs diff --git a/src/7.in_practice/3.2d_game/shaders/sprite.vs b/src/7.in_practice/3.2d_game/sprite.vs similarity index 100% rename from src/7.in_practice/3.2d_game/shaders/sprite.vs rename to src/7.in_practice/3.2d_game/sprite.vs diff --git a/src/7.in_practice/3.2d_game/shaders/text.frag b/src/7.in_practice/3.2d_game/text_2d.fs similarity index 100% rename from src/7.in_practice/3.2d_game/shaders/text.frag rename to src/7.in_practice/3.2d_game/text_2d.fs diff --git a/src/7.in_practice/3.2d_game/shaders/text.vs b/src/7.in_practice/3.2d_game/text_2d.vs similarity index 100% rename from src/7.in_practice/3.2d_game/shaders/text.vs rename to src/7.in_practice/3.2d_game/text_2d.vs diff --git a/src/7.in_practice/3.2d_game/text_renderer.cpp b/src/7.in_practice/3.2d_game/text_renderer.cpp index d9c2e0a..05748bf 100644 --- a/src/7.in_practice/3.2d_game/text_renderer.cpp +++ b/src/7.in_practice/3.2d_game/text_renderer.cpp @@ -19,7 +19,7 @@ TextRenderer::TextRenderer(unsigned int width, unsigned int height) { // load and configure shader - this->TextShader = ResourceManager::LoadShader("shaders/text.vs", "shaders/text.frag", nullptr, "text"); + this->TextShader = ResourceManager::LoadShader("text_2d.vs", "text_2d.fs", nullptr, "text"); this->TextShader.SetMatrix4("projection", glm::ortho(0.0f, static_cast(width), static_cast(height), 0.0f), true); this->TextShader.SetInteger("text", 0); // configure VAO/VBO for texture quads diff --git a/src/7.in_practice/3.2d_game/textures/awesomeface.png b/src/7.in_practice/3.2d_game/textures/awesomeface.png deleted file mode 100644 index 9840caf..0000000 Binary files a/src/7.in_practice/3.2d_game/textures/awesomeface.png and /dev/null differ