/******************************************************************************* * This file is part of the "Enduro2D" * For conditions of distribution and use, see copyright notice in LICENSE.md * Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com) ******************************************************************************/ #include "../common.hpp" using namespace e2d; namespace { class game_system final : public systems::update_system { public: void process( ecs::registry& owner, const systems::update_event& event) override { E2D_UNUSED(owner, event); const keyboard& k = the().keyboard(); if ( k.is_key_just_released(keyboard_key::f1) ) { the().toggle_visible(!the().visible()); } if ( k.is_key_just_released(keyboard_key::escape) ) { the().set_should_close(true); } if ( k.is_key_pressed(keyboard_key::lsuper) && k.is_key_just_released(keyboard_key::enter) ) { the().toggle_fullscreen(!the().fullscreen()); } } }; class game final : public starter::application { public: bool initialize() final { return create_scene() && create_systems(); } private: bool create_scene() { auto scene_prefab_res = the().load_asset("scenes/sample_07.json"); auto scene_go = scene_prefab_res ? the().instantiate(scene_prefab_res->content()) : gobject(); return scene_go.valid(); } bool create_systems() { ecs::registry_filler(the().registry()) .feature(ecs::feature() .add_system()); return true; } }; } int e2d_main(int argc, char *argv[]) { const auto starter_params = starter::parameters( engine::parameters("sample_07", "enduro2d") .window_params(engine::window_parameters() .size({1024, 512}) .resizable(true)) .timer_params(engine::timer_parameters() .maximal_framerate(100))); modules::initialize(argc, argv, starter_params).start(); modules::shutdown(); return 0; }