diff --git a/CMakeLists.txt b/CMakeLists.txt index 44c13b1..241d53e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15) project(sdl-test - LANGUAGES CXX) + LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 26) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -10,7 +10,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$") add_subdirectory(deps EXCLUDE_FROM_ALL) -set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) add_subdirectory(src) diff --git a/include/GameObject.h b/include/GameObject.h new file mode 100644 index 0000000..b6d1caa --- /dev/null +++ b/include/GameObject.h @@ -0,0 +1,18 @@ +#pragma once +#include + +#include "Graphics.h" +#include "components/GraphicsComponent.h" + +class GameObject : std::enable_shared_from_this { +public: + GameObject(std::unique_ptr graphics) + : m_graphics(std::move(graphics)) {} + + void update(Graphics &graphics) { + m_graphics->update(graphics); + } + +private: + std::unique_ptr m_graphics; +}; diff --git a/include/Graphics.h b/include/Graphics.h new file mode 100644 index 0000000..004777f --- /dev/null +++ b/include/Graphics.h @@ -0,0 +1,8 @@ +#pragma once + +class Graphics { +public: + Graphics(){} +private: +}; + diff --git a/include/components/GraphicsComponent.h b/include/components/GraphicsComponent.h new file mode 100644 index 0000000..eb2cb9f --- /dev/null +++ b/include/components/GraphicsComponent.h @@ -0,0 +1,13 @@ +#pragma once + +#include "Graphics.h" + +class GraphicsComponent { + +public: + virtual ~GraphicsComponent() {} + virtual void update(Graphics &graphics) = 0; + +private: +}; + diff --git a/include/components/PlayerGraphics.h b/include/components/PlayerGraphics.h new file mode 100644 index 0000000..c44d4d4 --- /dev/null +++ b/include/components/PlayerGraphics.h @@ -0,0 +1,11 @@ +#pragma once + +#include "Graphics.h" +#include "GraphicsComponent.h" +#include + +class PlayerGraphics : public GraphicsComponent { + void update(Graphics &graphics) { + std::print("Updating player graphics"); + } +}; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 72d8b9f..59b6ba2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,7 @@ -add_executable(${PROJECT_NAME} main.cpp) - -target_include_directories(${PROJECT_NAME} PRIVATE ${INCLUDE_DIR}) +set(SOURCES + components/PlayerGraphics.cpp + components/GraphicsComponent.cpp) + add_executable(${PROJECT_NAME} main.cpp ${SOURCES}) target_link_libraries(${PROJECT_NAME} PRIVATE SDL3::SDL3) diff --git a/src/components/GraphicsComponent.cpp b/src/components/GraphicsComponent.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/components/PlayerGraphics.cpp b/src/components/PlayerGraphics.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/main.cpp b/src/main.cpp index 418ff3b..47b1db7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,9 +17,18 @@ #include #include +#include + +#include "components/PlayerGraphics.h" +#include "Graphics.h" +#include "GameObject.h" + static SDL_Window *window = nullptr; static SDL_Renderer *renderer = nullptr; +GameObject player(std::make_unique()); +Graphics graphics; + /* This function runs once at startup. */ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) {