// // Created by Zoe Roux on 5/24/21. // #include #include #include "System/Movable/MovableSystem.hpp" #include "System/Renderer/RenderSystem.hpp" #include #include #include #include #include "System/Keyboard/KeyboardSystem.hpp" #include "System/Controllable/ControllableSystem.hpp" #include "Component/Movable/MovableComponent.hpp" #include "Component/Controllable/ControllableComponent.hpp" #include "Component/Keyboard/KeyboardComponent.hpp" #include "System/Gamepad/GamepadSystem.hpp" #include #include #include "Component/Renderer/CameraComponent.hpp" #include "Component/Renderer/Drawable3DComponent.hpp" #include "Runner.hpp" #include "Models/GameState.hpp" #include #include #include #include #include #include #include #include #include #include "Component/Animation/AnimationsComponent.hpp" #include "System/Animation/AnimationsSystem.hpp" #include "Component/Shaders/ShaderComponent.hpp" #include "Map/Map.hpp" #include "Component/Music/MusicComponent.hpp" #include "Component/Sound/SoundComponent.hpp" #include "System/Sound/PlayerSoundManagerSystem.hpp" #include "System/Music/MusicSystem.hpp" #include "Component/Gravity/GravityComponent.hpp" #include "System/Gravity/GravitySystem.hpp" #include "Component/BumperTimer/BumperTimerComponent.hpp" #include "System/BumperTimer/BumperTimerSystem.hpp" namespace RAY3D = RAY::Drawables::Drawables3D; namespace RAY2D = RAY::Drawables::Drawables2D; namespace BBM { void updateState(WAL::Wal &engine, GameState &state) { // You can change the scene here or update the game state based on entities values. // If you want to keep a scene loaded but not running, store it in the state.loadedScenes. // If you don't need the scene anymore, remember to remove it from the loadedScene array. if (RAY::Window::getInstance().shouldClose()) engine.shouldClose = true; } void addSystems(WAL::Wal &wal) { wal.addSystem() .addSystem() .addSystem() .addSystem() .addSystem() .addSystem() .addSystem() .addSystem() .addSystem() .addSystem() .addSystem() .addSystem() .addSystem(); } void enableRaylib(WAL::Wal &wal) { RAY::TraceLog::setLevel(LOG_WARNING); RAY::Window &window = RAY::Window::getInstance(600, 400, "Bomberman", FLAG_WINDOW_RESIZABLE); wal.addSystem() .addSystem() .addSystem(window); } std::shared_ptr loadGameScene() { auto scene = std::make_shared(); std::map soundPath ={ {SoundComponent::JUMP, "assets/sounds/jump.wav"}, {SoundComponent::MOVE, "assets/sounds/move.ogg"}, {SoundComponent::BOMB, "assets/sounds/bomb_drop.ogg"}, //{SoundComponent::DEATH, "assets/sounds/death.ogg"} }; scene->addEntity("player") .addComponent(0, 1.01, 0) .addComponent("assets/player/player.iqm", std::make_pair(MAP_DIFFUSE, "assets/player/blue.png")) .addComponent() .addComponent() .addComponent() .addComponent("assets/shaders/glsl330/predator.fs") .addComponent>() //.addComponent(0) .addComponent(RAY::ModelAnimations("assets/player/player.iqm"), 3) .addComponent(BBM::Vector3f{0.25, 0, 0.25}, BBM::Vector3f{.75, 2, .75}) .addComponent() .addComponent(soundPath) .addComponent() .addComponent() .addComponent() .addComponent(1, [](WAL::Entity &entity) { auto &animation = entity.getComponent(); animation.setAnimIndex(5); }); scene->addEntity("camera") .addComponent(8, 20, 7) .addComponent(Vector3f(8, 0, 8)); /*scene->addEntity("cube") .addComponent(5, 0, 5) .addComponent("assets/shaders/glsl330/grayscale.fs") //.addComponent(Vector3f(-5, 0, -5), Vector3f(3, 3, 3), RED) .addComponent(BBM::Vector2f{200,200}, BBM::Vector2f{200, 200}, RED) .addComponent() .addComponent() .addComponent(WAL::Callback(), &MapGenerator::wallCollide, 3); */ std::srand(std::time(nullptr)); MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16), scene); return scene; } int run() { WAL::Wal wal; addSystems(wal); enableRaylib(wal); wal.changeScene(loadGameScene()); try { wal.run(updateState); return 0; } catch (const std::exception &ex) { std::cerr << ex.what() << std::endl; return 1; } } }