// // Created by Zoe Roux on 5/24/21. // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "Models/Vector2.hpp" #include "Component/Renderer/CameraComponent.hpp" #include "Runner.hpp" #include "Models/GameState.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(); } 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.addSystem(window) .addSystem>(); wal.addSystem(window); } std::shared_ptr loadGameScene() { auto scene = std::make_shared(); scene->addEntity("cube") .addComponent() .addComponent>(Vector2f(), Vector2f(10, 10), RED) .addComponent() .addComponent() .addComponent();; scene->addEntity("player") .addComponent() .addComponent>("assets/player/player.iqm", std::make_pair(MAP_DIFFUSE, "assets/player/blue.png")) .addComponent() .addComponent() .addComponent(); scene->addEntity("camera") .addComponent(0, 20, -5) .addComponent(); 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; } } }