// // 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 #include #include #include #include #include #include #include #include #include "Models/Vector2.hpp" #include "Component/Renderer/CameraComponent.hpp" #include "Component/Renderer/Drawable2DComponent.hpp" #include "Component/Renderer/Drawable3DComponent.hpp" #include "Runner.hpp" #include "Models/GameState.hpp" #include #include "Component/Animation/AnimationsComponent.hpp" #include "System/Animation/AnimationsSystem.hpp" #include "Map/Map.hpp" namespace RAY2D = RAY::Drawables::Drawables2D; namespace RAY3D = RAY::Drawables::Drawables3D; 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(wal) .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(wal, window); } std::shared_ptr loadGameScene() { auto scene = std::make_shared(); scene->addEntity("player") .addComponent() .addComponent("assets/player/player.iqm", std::make_pair(MAP_DIFFUSE, "assets/player/blue.png")) .addComponent() .addComponent() .addComponent(RAY::ModelAnimations("assets/player/player.iqm"), 1) .addComponent(2) .addComponent(); scene->addEntity("cube") .addComponent(-5, 0, -5) .addComponent(Vector3f(-5, 0, -5), Vector3f(3, 3, 3), RED) .addComponent() .addComponent() .addComponent([](WAL::Entity &, const WAL::Entity &){}, [](WAL::Entity &actual, const WAL::Entity &) { try { auto &mov = actual.getComponent(); mov.resetVelocity(); } catch (std::exception &e) { }; }, 3); scene->addEntity("camera") .addComponent(8, 20, 7) .addComponent(Vector3f(8, 0, 8)); std::srand(std::time(NULL)); MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16), scene); return scene; } int run() { WAL::Wal wal; addSystems(wal); enableRaylib(wal); wal.scene = loadGameScene(); try { wal.run(updateState); return 0; } catch (const std::exception &ex) { std::cerr << ex.what() << std::endl; return 1; } } }