From 8054de9e2cd02d3fe44ddc25d55575a50d771aab Mon Sep 17 00:00:00 2001 From: Sztergbaum Roman Date: Wed, 2 Oct 2019 13:03:15 +0200 Subject: [PATCH] feat(docs): more documentation (#73) * feat(docs): more documentation * fix: remove unwanted file --- docs/CMakeLists.txt | 2 + docs/index.rst | 1 + docs/requirements.txt | 3 +- docs/source/tutorials/quick_and_dirty.rst | 15 +++++ docs/source/tutorials/tutorials.rst | 9 +++ examples/CMakeLists.txt | 1 + examples/quick_and_dirty/CMakeLists.txt | 17 ++++++ examples/quick_and_dirty/quick_and_dirty.cpp | 60 +++++++++++++++++++ .../assets/scripts/scenes/lua/game_scene.lua | 29 +++++++++ 9 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 docs/source/tutorials/quick_and_dirty.rst create mode 100644 docs/source/tutorials/tutorials.rst create mode 100644 examples/quick_and_dirty/CMakeLists.txt create mode 100644 examples/quick_and_dirty/quick_and_dirty.cpp create mode 100644 examples/sfml/flappy-bird-scripted/assets/scripts/scenes/lua/game_scene.lua diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 32f72566..305ab452 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -63,6 +63,8 @@ add_custom_command(OUTPUT ${SPHINX_INDEX_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/source/api/api_index.rst ${CMAKE_CURRENT_SOURCE_DIR}/source/api/core.rst ${CMAKE_CURRENT_SOURCE_DIR}/source/api/config.rst + ${CMAKE_CURRENT_SOURCE_DIR}/source/tutorials/tutorials.rst + ${CMAKE_CURRENT_SOURCE_DIR}/source/tutorials/quick_and_dirty.rst ${DOXYGEN_INDEX_FILE} MAIN_DEPENDENCY ${SPHINX_SOURCE}/conf.py COMMENT "Generating documentation with Sphinx") diff --git a/docs/index.rst b/docs/index.rst index 327b58af..f853d17b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -5,6 +5,7 @@ Welcome to antara-gaming-sdk documentation ! :name: index source/api/api_index + source/tutorials/tutorials Indices and tables diff --git a/docs/requirements.txt b/docs/requirements.txt index 7b67392a..6350ecb2 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,3 @@ breathe -sphinx>=2.0 \ No newline at end of file +sphinx>=2.0 +m2r \ No newline at end of file diff --git a/docs/source/tutorials/quick_and_dirty.rst b/docs/source/tutorials/quick_and_dirty.rst new file mode 100644 index 00000000..2f494c85 --- /dev/null +++ b/docs/source/tutorials/quick_and_dirty.rst @@ -0,0 +1,15 @@ +tutorial: Quick And Dirty +============================================ + +prerequisites +----------------------- + +You'll need to have a basic ``CMakeLists.txt`` to able to compile your code: + +.. literalinclude:: ../../../examples/quick_and_dirty/CMakeLists.txt + :language: cmake + +And below a cpp file with the primitives needed to launch your game: + +.. literalinclude:: ../../../examples/quick_and_dirty/quick_and_dirty.cpp + :language: cpp \ No newline at end of file diff --git a/docs/source/tutorials/tutorials.rst b/docs/source/tutorials/tutorials.rst new file mode 100644 index 00000000..715b623d --- /dev/null +++ b/docs/source/tutorials/tutorials.rst @@ -0,0 +1,9 @@ +Tutorials +============================================ + +.. toctree:: + :caption: Antara Gaming SDK Tutorials + :name: tutorialtoc + :maxdepth: 2 + + quick_and_dirty \ No newline at end of file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 6ab1857c..3fd28dde 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,3 +1,4 @@ +add_subdirectory(quick_and_dirty) if (USE_SFML_ANTARA_WRAPPER) add_subdirectory(sfml) endif () \ No newline at end of file diff --git a/examples/quick_and_dirty/CMakeLists.txt b/examples/quick_and_dirty/CMakeLists.txt new file mode 100644 index 00000000..f0f316ac --- /dev/null +++ b/examples/quick_and_dirty/CMakeLists.txt @@ -0,0 +1,17 @@ +##! Uncomment those lines if you use the gaming sdk as an external project +#if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") +# set(LINUX TRUE) +#endif () + +#include(FetchContent) + +#FetchContent_Declare( +# antara-gaming-sdk +# URL https://github.com/KomodoPlatform/antara-gaming-sdk/archive/master.zip +#) + +#FetchContent_MakeAvailable(antara-gaming-sdk) +#init_apple_env() + +add_executable(quick_and_dirty quick_and_dirty.cpp) +target_link_libraries(quick_and_dirty PUBLIC antara::world) \ No newline at end of file diff --git a/examples/quick_and_dirty/quick_and_dirty.cpp b/examples/quick_and_dirty/quick_and_dirty.cpp new file mode 100644 index 00000000..62524924 --- /dev/null +++ b/examples/quick_and_dirty/quick_and_dirty.cpp @@ -0,0 +1,60 @@ +/****************************************************************************** + * Copyright © 2013-2019 The Komodo Platform Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * Komodo Platform software, including this file may be copied, modified, * + * propagated or distributed except according to the terms contained in the * + * LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#include +#include +#include + +class example_system final : public antara::gaming::ecs::post_update_system +{ +public: + example_system(entt::registry& entity_registry, entt::dispatcher& dispatcher) noexcept : system(entity_registry, + dispatcher) + { + //! Here you can initialize your systems, adding entities etc + } + + void update() noexcept final + { + //! Your game logic here + nb_iteration += 1; + std::cout << "nb_iteration: " << nb_iteration << "\n"; + if (nb_iteration == 10ull) { + std::cout << "Maximum iteration reached, leaving game now\n"; + this->dispatcher_.trigger(0); + } + } + +private: + std::size_t nb_iteration{0ull}; +}; + +REFL_AUTO(type(example_system)); + +class my_world_example : public antara::gaming::world::app +{ +public: + my_world_example() + { + this->system_manager_.create_system(); //! Here we load our system to use it. + } +}; + +int main() +{ + my_world_example world; + return world.run(); +} \ No newline at end of file diff --git a/examples/sfml/flappy-bird-scripted/assets/scripts/scenes/lua/game_scene.lua b/examples/sfml/flappy-bird-scripted/assets/scripts/scenes/lua/game_scene.lua new file mode 100644 index 00000000..549af6d9 --- /dev/null +++ b/examples/sfml/flappy-bird-scripted/assets/scripts/scenes/lua/game_scene.lua @@ -0,0 +1,29 @@ +local function enter() + print("enter game scene") +end + +local function leave() + print("leave game scene") +end + +local function on_key_released(evt) + print("key released: " .. evt.key) +end + +local function on_key_pressed(evt) + print("key pressed: " .. evt.key) +end + +local function update() + print("game scene update") +end + +return { + enter = enter, + leave = leave, + update = update, + on_key_released = on_key_released, + on_key_pressed = on_key_pressed, + scene_active = true +} +