// // 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 "Component/Renderer/CameraComponent.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 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() .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(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(1) .addComponent(); scene->addEntity("camera") .addComponent(8, 20, 7) .addComponent(Vector3f(8, 0, 8)); 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.scene = loadGameScene(); try { wal.run(updateState); return 0; } catch (const std::exception &ex) { std::cerr << ex.what() << std::endl; return 1; } } }