/******************************************************************************* * 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 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 { { ecs::registry_filler(the().registry()) .feature(ecs::feature() .add_system()); } { prefab scene_prefab; scene_prefab.prototype() .component(named() .name("scene")) .component(); prefab camera_prefab; camera_prefab.prototype() .component(named() .name("camera")) .component(camera() .background({1.f, 0.4f, 0.f, 1.f})) .component(); gobject scene_go = the().instantiate(scene_prefab); gobject camera_go = the().instantiate(camera_prefab); node_iptr scene_node = scene_go.component()->node(); node_iptr camera_node = camera_go.component()->node(); scene_node->add_child(camera_node); } return true; } }; } int e2d_main(int argc, char *argv[]) { const auto params = starter::parameters( engine::parameters("bootstrap", "enduro2d") .timer_params(engine::timer_parameters() .maximal_framerate(100))); modules::initialize(argc, argv, params).start(); modules::shutdown(); return 0; }