mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-15 00:11:55 +07:00
dummy sample 09
This commit is contained in:
@@ -47,3 +47,4 @@ add_e2d_sample(05)
|
||||
add_e2d_sample(06)
|
||||
add_e2d_sample(07)
|
||||
add_e2d_sample(08)
|
||||
add_e2d_sample(09)
|
||||
|
||||
8
samples/bin/library/scenes/sample_09.json
Normal file
8
samples/bin/library/scenes/sample_09.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"prototype" : "../prefabs/scene_prefab.json",
|
||||
"children" : [{
|
||||
"prototype" : "../prefabs/background_prefab.json"
|
||||
},{
|
||||
"prototype" : "../prefabs/camera_prefab.json"
|
||||
}]
|
||||
}
|
||||
69
samples/sources/sample_09/sample_09.cpp
Normal file
69
samples/sources/sample_09/sample_09.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*******************************************************************************
|
||||
* 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<input>().keyboard();
|
||||
|
||||
if ( k.is_key_just_released(keyboard_key::f12) ) {
|
||||
the<dbgui>().toggle_visible(!the<dbgui>().visible());
|
||||
}
|
||||
|
||||
if ( k.is_key_just_released(keyboard_key::escape) ) {
|
||||
the<window>().set_should_close(true);
|
||||
}
|
||||
|
||||
if ( k.is_key_pressed(keyboard_key::lsuper) && k.is_key_just_released(keyboard_key::enter) ) {
|
||||
the<window>().toggle_fullscreen(!the<window>().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<library>().load_asset<prefab_asset>("scenes/sample_09.json");
|
||||
auto scene_go = scene_prefab_res
|
||||
? the<world>().instantiate(scene_prefab_res->content())
|
||||
: gobject();
|
||||
return scene_go.valid();
|
||||
}
|
||||
|
||||
bool create_systems() {
|
||||
ecs::registry_filler(the<world>().registry())
|
||||
.feature<struct game_feature>(ecs::feature()
|
||||
.add_system<game_system>());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int e2d_main(int argc, char *argv[]) {
|
||||
const auto starter_params = starter::parameters(
|
||||
engine::parameters("sample_09", "enduro2d")
|
||||
.window_params(engine::window_parameters()
|
||||
.size({1024, 512}))
|
||||
.timer_params(engine::timer_parameters()
|
||||
.maximal_framerate(100)));
|
||||
modules::initialize<starter>(argc, argv, starter_params).start<game>();
|
||||
modules::shutdown<starter>();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user