Skip to content

Commit

Permalink
feat(docs): more documentation (#73)
Browse files Browse the repository at this point in the history
* feat(docs): more documentation

* fix: remove unwanted file
  • Loading branch information
Milerius authored Oct 2, 2019
1 parent 9d555dd commit 8054de9
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Welcome to antara-gaming-sdk documentation !
:name: index

source/api/api_index
source/tutorials/tutorials


Indices and tables
Expand Down
3 changes: 2 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
breathe
sphinx>=2.0
sphinx>=2.0
m2r
15 changes: 15 additions & 0 deletions docs/source/tutorials/quick_and_dirty.rst
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions docs/source/tutorials/tutorials.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Tutorials
============================================

.. toctree::
:caption: Antara Gaming SDK Tutorials
:name: tutorialtoc
:maxdepth: 2

quick_and_dirty
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory(quick_and_dirty)
if (USE_SFML_ANTARA_WRAPPER)
add_subdirectory(sfml)
endif ()
17 changes: 17 additions & 0 deletions examples/quick_and_dirty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
60 changes: 60 additions & 0 deletions examples/quick_and_dirty/quick_and_dirty.cpp
Original file line number Diff line number Diff line change
@@ -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 <iostream>
#include <antara/gaming/core/safe.refl.hpp>
#include <antara/gaming/world/world.app.hpp>

class example_system final : public antara::gaming::ecs::post_update_system<example_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<antara::gaming::event::quit_game>(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<example_system>(); //! Here we load our system to use it.
}
};

int main()
{
my_world_example world;
return world.run();
}
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 8054de9

Please sign in to comment.