Skip to content
Closed

Dev #223

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 90 additions & 43 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
include(cmake/vcpkg.cmake)
endif()

project(RType VERSION 1.0.0 LANGUAGES CXX)
project(RTypeEngine VERSION 2.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -24,58 +24,106 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

# Copy assets to build directory
add_custom_target(copy_assets ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/assets
${CMAKE_BINARY_DIR}/assets
)

# =============================================================================
# Dependencies
# =============================================================================
find_package(asio CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(Threads REQUIRED)

add_subdirectory(libs/engine)
# =============================================================================
# Engine Libraries (generic, reusable by any game)
# =============================================================================
add_subdirectory(engine)

# =============================================================================
# Games (R-Type game library must be built before network due to dependencies)
# =============================================================================

# R-Type Game (systems library - used by network library)
add_subdirectory(games/rtype)

# =============================================================================
# Network Libraries (depends on rtype_game for GameServer/GameClient)
# =============================================================================
add_subdirectory(libs/network)

add_executable(r-type_server server/main.cpp)
# R-Type Server
add_executable(r-type_server games/rtype/server/main.cpp)
target_link_libraries(r-type_server PRIVATE rtype_network rtype_asio_network)

add_executable(r-type_client
client/main.cpp
client/src/MenuState.cpp
client/src/SettingsState.cpp
client/src/room/RoomListState.cpp
client/src/LobbyState.cpp
client/src/GameState.cpp
client/src/ResultsState.cpp
client/src/EditorState.cpp
client/src/editor/EditorCanvasManager.cpp
client/src/editor/EditorAssetLibrary.cpp
client/src/editor/EditorUIManager.cpp
client/src/editor/EditorEntityManager.cpp
client/src/editor/EditorFileManager.cpp
client/src/editor/EditorInputHandler.cpp
client/src/editor/EditorDrawing.cpp
client/src/editor/EditorPropertyManager.cpp
client/src/editor/EditorColliderManager.cpp
games/rtype/client/main.cpp
games/rtype/client/src/MenuState.cpp
games/rtype/client/src/SettingsState.cpp
games/rtype/client/src/room/RoomListState.cpp
games/rtype/client/src/LobbyState.cpp
games/rtype/client/src/GameState.cpp
games/rtype/client/src/ResultsState.cpp
games/rtype/client/src/EditorState.cpp
games/rtype/client/src/editor/EditorCanvasManager.cpp
games/rtype/client/src/editor/EditorAssetLibrary.cpp
games/rtype/client/src/editor/EditorUIManager.cpp
games/rtype/client/src/editor/EditorEntityManager.cpp
games/rtype/client/src/editor/EditorFileManager.cpp
games/rtype/client/src/editor/EditorInputHandler.cpp
games/rtype/client/src/editor/EditorDrawing.cpp
games/rtype/client/src/editor/EditorPropertyManager.cpp
games/rtype/client/src/editor/EditorColliderManager.cpp
)
target_include_directories(r-type_client PRIVATE
${CMAKE_SOURCE_DIR}/client/include
${CMAKE_SOURCE_DIR}/games/rtype/client/include
${CMAKE_SOURCE_DIR}/games/rtype/include
)
target_link_libraries(r-type_client PRIVATE
rtype_network
rtype_asio_network
rtype_ecs
rtype_game
rtype_ecs_core
rtype_core
rtype_sfml_renderer
rtype_sfml_audio
)

# Breakout Game (demo of engine reusability)
if(TARGET rtype_sfml_renderer)
add_executable(breakout
games/breakout/src/main.cpp
games/breakout/src/BreakoutPhysicsSystem.cpp
games/breakout/src/BreakoutRenderSystem.cpp
games/breakout/src/BallAccelerationSystem.cpp
)
target_include_directories(breakout PRIVATE
${CMAKE_SOURCE_DIR}/games/breakout/include
)
target_link_libraries(breakout PRIVATE
rtype_core
rtype_ecs_core
rtype_sfml_renderer
)
message(STATUS "breakout will be built (engine reusability demo)")
endif()

# Metroidvania Game (NEW - to be developed)
# add_subdirectory(games/metroidvania)

# =============================================================================
# Tests
# =============================================================================
enable_testing()

add_executable(test_lobby tests/test_lobby.cpp)
target_link_libraries(test_lobby PRIVATE rtype_network rtype_asio_network)

add_executable(test_sparse_array tests/test_sparse_array.cpp)
target_link_libraries(test_sparse_array PRIVATE rtype_ecs)
target_link_libraries(test_sparse_array PRIVATE rtype_ecs_core)

add_executable(test_udp_protocol tests/test_udp_protocol.cpp)
target_link_libraries(test_udp_protocol PRIVATE rtype_network rtype_asio_network)
Expand All @@ -84,49 +132,48 @@ message(STATUS "test_udp_protocol will be built (UDP game protocol test)")
add_executable(test_tcp_framing tests/test_tcp_framing.cpp)
target_link_libraries(test_tcp_framing PRIVATE rtype_asio_network)

add_executable(test_event_bus tests/test_event_bus.cpp)
target_link_libraries(test_event_bus PRIVATE rtype_core)

add_executable(test_scene_manager tests/test_scene_manager.cpp)
target_link_libraries(test_scene_manager PRIVATE rtype_core rtype_ecs_core)

add_executable(test_camera_system tests/test_camera_system.cpp)
target_link_libraries(test_camera_system PRIVATE rtype_core rtype_ecs_core)

if(TARGET rtype_sfml_renderer)
add_executable(test_renderer tests/test_renderer.cpp)
target_link_libraries(test_renderer PRIVATE
rtype_core
rtype_ecs
rtype_ecs_core
)
message(STATUS "test_renderer will be built (loads renderer plugin dynamically)")

add_executable(test_player_system tests/test_player_system.cpp)
target_include_directories(test_player_system PRIVATE
${CMAKE_SOURCE_DIR}/games/rtype/include
)
target_link_libraries(test_player_system PRIVATE
rtype_core
rtype_ecs
rtype_game
)
message(STATUS "test_player_system will be built (loads renderer plugin dynamically)")

add_executable(test_health_system tests/test_health_system.cpp)
target_include_directories(test_health_system PRIVATE
${CMAKE_SOURCE_DIR}/games/rtype/include
)
target_link_libraries(test_health_system PRIVATE
rtype_core
rtype_ecs
rtype_game
)
message(STATUS "test_health_system will be built (loads renderer plugin dynamically)")

add_executable(test_background tests/test_background.cpp)
target_link_libraries(test_background PRIVATE
rtype_core
rtype_ecs
rtype_ecs_core
rtype_sfml_renderer
)
message(STATUS "test_background will be built")

add_executable(breakout
breakout/src/main.cpp
breakout/src/BreakoutPhysicsSystem.cpp
breakout/src/BreakoutRenderSystem.cpp
breakout/src/BallAccelerationSystem.cpp
)
target_include_directories(breakout PRIVATE
${CMAKE_SOURCE_DIR}/breakout/include
)
target_link_libraries(breakout PRIVATE
rtype_core
rtype_ecs
rtype_sfml_renderer
)
message(STATUS "breakout will be built (second game demo)")
endif()
19 changes: 19 additions & 0 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Engine CMakeLists.txt - Generic Game Engine
#
# This builds the generic engine libraries that can be used by any game.
# Game-specific code belongs in games/<game_name>/

# Core subsystem (Logger, Engine, Module system)
add_subdirectory(src/Core)

# ECS subsystem (split into generic and rtype-specific)
add_subdirectory(src/ECS)

# Renderer plugin (SFML implementation)
add_subdirectory(src/Renderer)

# Audio plugin (SFML implementation)
add_subdirectory(src/Audio)

# Animation system
add_subdirectory(src/Animation)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include "Module.hpp"
#include "ModuleLoader.hpp"
#include "Logger.hpp"
#include "SceneManager.hpp"
#include "ResourceManager.hpp"
#include "InputManager.hpp"
#include "EventBus.hpp"
#include "../ECS/Registry.hpp"
#include "../ECS/ISystem.hpp"
#include <string>
Expand Down Expand Up @@ -48,6 +52,11 @@ namespace RType {
template <typename T>
void RegisterSystem(std::unique_ptr<T> system);
void UpdateSystems(float deltaTime);
SceneManager& GetSceneManager() { return m_sceneManager; }
ResourceManager& GetResourceManager() { return m_resourceManager; }
InputManager& GetInputManager() { return m_inputManager; }
EventBus& GetEventBus() { return m_eventBus; }

private:
void SortModulesByPriority();
bool InitializeModules();
Expand All @@ -61,6 +70,12 @@ namespace RType {
std::vector<IModule*> m_sortedModules;
ECS::Registry m_registry;
std::vector<std::unique_ptr<ECS::ISystem>> m_systems;

SceneManager m_sceneManager;
ResourceManager m_resourceManager;
InputManager m_inputManager;
EventBus m_eventBus;

bool m_initialized{false};
};

Expand Down
Loading