Skip to content
Open
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
7 changes: 5 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ name: cpp-linter
on:
pull_request:
types: [assigned, opened, synchronize, reopened]

jobs:
cpp-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: cpp-linter/cpp-linter-action@v2
id: linter
env:
Expand All @@ -16,7 +18,8 @@ jobs:
style: file
lines-changed-only: true
tidy-checks: -*
version: 16 # todo find minimal viable version
version: 18

- name: Fail fast?!
if: steps.linter.outputs.checks-failed > 0
run: echo "Some files failed the linting checks!"
Expand Down
94 changes: 67 additions & 27 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,88 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
CONAN_USER_HOME: "${{ github.workspace }}/release/"
CONAN_USER_HOME_SHORT: "${{ github.workspace }}/release/short"
CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm-cache

jobs:
build:
strategy:
fail-fast: false
matrix:
#version: [10, 12, 14]
os: [ubuntu-latest]
os: [ubuntu-latest, macos-latest]
build_type: [Debug, Release]
include:
- os: ubuntu-latest
preset: unixlike-gcc-debug
preset_release: unixlike-gcc-release
- os: macos-latest
preset: unixlike-clang-debug
preset_release: unixlike-clang-release

runs-on: ${{ matrix.os }}

steps:
- name: Set up cache
id: cache-cpm
uses: actions/cache@v2
- name: Checkout code
uses: actions/checkout@v4

- name: Set up CPM cache
uses: actions/cache@v4
with:
path: ~/cpm-cache
key: ${{ runner.os }}-cpm-${{ hashFiles('**/') }}
restore-keys: |
${{ runner.os }}-cpm-
- uses: actions/checkout@v3
- name: Setup GCC
uses: pkgxdev/setup@v1
path: ${{ env.CPM_SOURCE_CACHE }}
key: ${{ runner.os }}-cpm-${{ hashFiles('**/CMakeLists.txt', 'cmake/**/*.cmake') }}
restore-keys: |
${{ runner.os }}-cpm-

- name: Set up build cache
uses: actions/cache@v4
with:
+: gcc@14
path: |
out/build/${{ matrix.build_type == 'Debug' && matrix.preset || matrix.preset_release }}
key: ${{ runner.os }}-build-${{ matrix.build_type }}-${{ hashFiles('**/*.cpp', '**/*.hpp', '**/*.h', '**/*.c') }}
restore-keys: |
${{ runner.os }}-build-${{ matrix.build_type }}-
${{ runner.os }}-build-

- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build gcc-14 g++-14
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100

- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: brew install ninja

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCPM_SOURCE_CACHE=~/cpm-cache

run: |
if [ "${{ matrix.build_type }}" == "Debug" ]; then
cmake --preset=${{ matrix.preset }}
else
cmake --preset=${{ matrix.preset_release }}
fi
shell: bash

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
run: |
if [ "${{ matrix.build_type }}" == "Debug" ]; then
cmake --build --preset=${{ matrix.preset }}
else
cmake --build --preset=${{ matrix.preset_release }}
fi
shell: bash

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}
run: |
if [ "${{ matrix.build_type }}" == "Debug" ]; then
ctest --preset=test-${{ matrix.preset }}
else
ctest --preset=test-${{ matrix.preset_release }}
fi
shell: bash
19 changes: 13 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ project(2dPlayground)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED True)


#some global compiler settings
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
#add_compile_options(/W4 /WX)
add_compile_options(/W3)
add_compile_options(/bigobj)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wall -Wno-c++98-compat -Wno-c++98-compat-pedantic)
else()
add_compile_options(-Wall)
endif()
#options
option(ENABLE_COVERAGE "Enable coverage" OFF)
option(ENABLE_SANDBOXES "Enable sandbox projects" OFF)
#bigobj
if (MSVC)
add_compile_options(/bigobj)
endif()

#add cmake script to download conan-cmake integrations
#include(cmake/conan_config.cmake)
Expand All @@ -22,14 +27,16 @@ include(cmake/stacktrace.cmake)
include(cmake/setup_cpm.cmake)
include(cmake/deps_cpm.cmake)
include(cmake/disable_3rd_party_warnings.cmake)
make_all_targets_system()


enable_testing()
add_subdirectory(libs)
add_subdirectory(apps)
add_subdirectory(tests)
add_subdirectory(tools)

# Apply system includes to all external dependencies after they're all loaded
make_all_targets_system()
install(DIRECTORY
data/
DESTINATION
Expand Down
7 changes: 3 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CPM_SOURCE_CACHE": "${sourceDir}/out/.cache/cpm/",
//"ENABLE_SANDBOXES": "ON"
"ENABLE_SANDBOXES": "ON"
}
},
{
Expand Down Expand Up @@ -114,8 +114,7 @@
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl",
"CMAKE_BUILD_TYPE": "Release",
"ENABLE_DEVELOPER_MODE": "OFF",

"ENABLE_DEVELOPER_MODE": "OFF"
}
},
{
Expand All @@ -126,7 +125,7 @@
"cacheVariables": {
"CMAKE_C_COMPILER": "clang-cl",
"CMAKE_CXX_COMPILER": "clang-cl",
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_BUILD_TYPE": "Debug"
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
Expand Down
2 changes: 1 addition & 1 deletion apps/_template/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
{
textdemo_main();
return 0;
}
}
4 changes: 2 additions & 2 deletions apps/asteroids/components/SoundEntities.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ namespace asteroids {
//
struct Sound
{
std::string identifier; //< usually the path or some resource identifier
float gain{1.0f}; //< range 0.0f to 1.0f
std::string identifier; ///< usually the path or some resource identifier
float gain{1.0f}; ///< range 0.0f to 1.0f
float pitch{1.0f};
bool loop{false};
} // namespace asteroids
2 changes: 1 addition & 1 deletion apps/asteroids/events/Collision.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ struct Collision : public pgf::TypeRegistrar<Collision, "Collision">
entt::entity c1;
entt::entity c2;
};
}} // namespace asteroids::events
}} // namespace asteroids::events
2 changes: 1 addition & 1 deletion apps/asteroids/events/LaserFired.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ struct LaserFired : pgf::TypeRegistrar<LaserFired, "LaserFired">
pg::fVec2 offset;
entt::entity shooter;
};
}} // namespace asteroids::events
}} // namespace asteroids::events
5 changes: 3 additions & 2 deletions apps/asteroids/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
try
{
pg::game::Game game({.vfsConfigs{{.root = "../data", .alias = "data"}}, .resourcePrefix = "data"});
pg::game::Game game(
{.vfsConfigs{{.root = "../data", .alias = "data"}, {.root = "../data/Meteors", .alias = "Meteors"}}});

pg::game::SystemsFactory::registerSystem<asteroids::Lasers>("lasers");
pg::game::SystemsFactory::registerSystem<asteroids::Player>("player");
Expand Down Expand Up @@ -66,4 +67,4 @@ catch (...)
std::print("Unhandled exception\n");
errorTrace::printErrorTrace();
return -1;
}
}
8 changes: 4 additions & 4 deletions apps/asteroids/systems/Asteroids.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class Asteroids : public pg::game::SystemInterface
/**
* @brief Creates an asteroid entity in the game.
*
* @param position The initial position of the asteroid.
* @param velocity The initial velocity of the asteroid.
* @param size The size of the asteroid. This affects the sprite used, as well as the hitpoints and damage of the
* /param position The initial position of the asteroid.
* /param velocity The initial velocity of the asteroid.
* /param size The size of the asteroid. This affects the sprite used, as well as the hitpoints and damage of the
* asteroid.
*/
void createAsteroid(const pg::fVec2& position, const pg::fVec2& velocity, Size size);
Expand All @@ -60,4 +60,4 @@ class Asteroids : public pg::game::SystemInterface
std::deque<events::Collision> collisions;
};

} // namespace asteroids
} // namespace asteroids
4 changes: 1 addition & 3 deletions apps/asteroids/systems/Background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
void asteroids::Background::handle(const pg::FrameStamp&)
{
// TODO: base scrolling speed on the player's velocity
auto view = _game.getGlobalRegistry().view<pg::Transform2D, asteroids::Dynamics, backgroundTag>();
// auto view = _game.getGlobalRegistry().view<pg::Transform2D, asteroids::Dynamics, backgroundTag>();
}

void asteroids::Background::setup(std::string_view /*scene_id*/)
Expand All @@ -18,9 +18,7 @@ void asteroids::Background::setup(std::string_view /*scene_id*/)
auto background = registry.create();

auto backgroundImg = pg::SpriteFactory::makeSprite(_game.getApp().getRenderer(), "../data/spr_stars01.png");
auto windowDetails = _game.getCurrentScene().getSingleton<pg::game::WindowDetails>();
// TODO add entities as references to the classes
auto backgroundRect = pg::iVec2{windowDetails.windowRect.w, windowDetails.windowRect.h};

registry.emplace<pg::game::Drawable>(background, std::make_unique<pg::ScrollingSprite>(std::move(backgroundImg)));
registry.emplace<pg::Transform2D>(background);
Expand Down
2 changes: 1 addition & 1 deletion apps/asteroids/systems/Background.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class Background : public pg::game::SystemInterface
void handle(const pg::FrameStamp& frameStamp);
};

} // namespace asteroids
} // namespace asteroids
2 changes: 1 addition & 1 deletion apps/asteroids/systems/Collisions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class Collisions : public pg::game::SystemInterface
void handleCollision(entt::entity id1, entt::entity id2, float intrusion);
};

} // namespace asteroids
} // namespace asteroids
2 changes: 1 addition & 1 deletion apps/asteroids/systems/DynamicsSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ class DynamicsSystem : public pg::game::SystemInterface
void setup(std::string_view scene_id) override;
void handle(const pg::FrameStamp& frameStamp) override;
};
} // namespace asteroids
} // namespace asteroids
2 changes: 1 addition & 1 deletion apps/asteroids/systems/Lasers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void asteroids::Lasers::setup(std::string_view /*scene_id*/)
void asteroids::Lasers::createShot(const events::LaserFired& event)
{
auto& renderer = _game.getApp().getRenderer();
auto sprite = _game.getResource<pg::Sprite, sdl::Renderer&>("laserBlue01.png", renderer);
auto sprite = _game.getResource<pg::Sprite, sdl::Renderer&>("data/laserBlue01.png", renderer);

pg::game::Drawable d(sprite);
// determine shoot position
Expand Down
3 changes: 1 addition & 2 deletions apps/asteroids/systems/Lasers.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ class Lasers : public pg::game::SystemInterface
private:
std::vector<events::LaserFired> queued;
};

} // namespace asteroids
} // namespace asteroids
2 changes: 1 addition & 1 deletion apps/asteroids/systems/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void asteroids::Player::setup(std::string_view /*scene_id*/)
auto& registry = _game.getGlobalRegistry();

auto& keyStateMap = _game.getCurrentScene().getKeyStateMap();
auto sprite = _game.getResource<pg::Sprite>("playerShip1_blue.png");
auto sprite = _game.getResource<pg::Sprite>("data/playerShip1_blue.png");
auto windowDetails = _game.getCurrentScene().getSingleton<pg::game::WindowDetails>();

auto player = pg::game::makeEntity<pg::BoundingSphere, pg::game::Drawable, pg::Transform2D, asteroids::Dynamics>(
Expand Down
2 changes: 1 addition & 1 deletion apps/asteroids/systems/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ class Player : public pg::game::SystemInterface

void handle(const pg::FrameStamp& frameStamp);
};
} // namespace asteroids
} // namespace asteroids
2 changes: 1 addition & 1 deletion apps/asteroids/systems/RenderSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class RenderSystem : public pg::game::SystemInterface

void handle(const pg::FrameStamp& frameStamp);
};
} // namespace asteroids
} // namespace asteroids
4 changes: 2 additions & 2 deletions apps/asteroids/systems/ScriptSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class ScriptSystem : public pg::game::SystemInterface

virtual ~ScriptSystem() = default;

void setup(std::string_view scene_id) override
void setup(std::string_view /*scene_id*/) override
{
_scripter = std::make_unique<pg::scripting::PythonScripter>(
pg::scripting::PythonScripter::scriptFromFile("../data/scripts/test.py"));
_scripter->addModule("mymodule");
}

void handle(const pg::FrameStamp& frameStamp) override { _scripter->run(); }
void handle(const pg::FrameStamp& /*frameStamp*/) override { _scripter->run(); }

private:
std::unique_ptr<pg::scripting::PythonScripter> _scripter;
Expand Down
3 changes: 1 addition & 2 deletions apps/asteroids/systems/SoundSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ class SoundSystem : public pg::game::SystemInterface
std::unique_ptr<soundEngineX::SoundEngine> _soundEngine;
std::unique_ptr<soundEngineX::BackgroundPlayer> _bgPlayer;
};

} // namespace asteroids
} // namespace asteroids
1 change: 1 addition & 0 deletions apps/galaxy/behaviors/GetTargetsAvailable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <behaviors/utils/BehaviorActionNode.hpp>
#include <helpers/GalaxyHelpers.hpp>
#include <spdlog/spdlog.h>
#include <entt/entt.hpp>

namespace BT {

Expand Down
Loading
Loading