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
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ 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)
else()
#add_compile_options(-Wall -Wextra -Wpedantic -Werror -Wno-c++98-compat -Wno-c++98-compat-pedantic)
add_compile_options(-Wall -Wno-c++98-compat -Wno-c++98-compat-pedantic)
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 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
6 changes: 4 additions & 2 deletions apps/galaxy/behaviors/MakeDrone.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <components/Tags.hpp>
#include <components/Lifetime.hpp>
#include <pgGame/components/RenderState.hpp>
#include <events/DroneEvents.hpp>
#include <entt/entt.hpp>

namespace behavior {

Expand Down Expand Up @@ -72,8 +74,8 @@ class MakeDrone : public BehaviorActionNode

pg::game::addComponent<galaxy::Behavior>(
game.getGlobalRegistry(), entity, galaxy::Behavior{std::move(behavior_tree), {}});

game.getDispatcher().trigger<galaxy::events::DroneCreatedEvent>({.entity = entity, .transform = transform.pos});
game.getDispatcher().trigger<galaxy::events::DroneCreatedEvent>(
galaxy::events::DroneCreatedEvent{.entity = entity, .faction = faction, .transform = transform.pos});
return BT::NodeStatus::SUCCESS;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/galaxy/behaviors/utils/Context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ struct Context
};

using ContextPtr = std::shared_ptr<Context>;
} // namespace behavior
} // namespace behavior
6 changes: 3 additions & 3 deletions apps/galaxy/behaviors/utils/PortInjection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ class PortInjector
{
for (const auto& port : forcedInput)
{
if (!config.input_ports.contains(port)) { config.input_ports.insert({port, ""}); };
if (!config.input_ports.contains(port)) { config.input_ports.insert({port, ""}); }
}
for (const auto& port : forcedOutput)
{
if (!config.output_ports.contains(port)) { config.output_ports.insert({port, ""}); };
if (!config.output_ports.contains(port)) { config.output_ports.insert({port, ""}); }
}
}

Expand All @@ -64,4 +64,4 @@ class PortInjector
std::unordered_set<std::string> forcedOutput;
};

} // namespace behavior
} // namespace behavior
2 changes: 1 addition & 1 deletion apps/galaxy/components/Faction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ struct Faction
{
std::string name;
};
} // namespace galaxy
} // namespace galaxy
8 changes: 4 additions & 4 deletions apps/galaxy/components/StarSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
namespace galaxy {
enum class ColonizationStatus
{
Unexplored, //< No one has been here yet
Planned, //< A probe has been sent to this system
Explored, //< A probe has been here and sent back data
Colonized, //< A probe has established production facilities and started building more probes
Unexplored, ///< No one has been here yet
Planned, ///< A probe has been sent to this system
Explored, ///< A probe has been here and sent back data
Colonized, ///< A probe has established production facilities and started building more probes
};

struct StarSystemState
Expand Down
2 changes: 1 addition & 1 deletion apps/galaxy/events/DroneEvents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ struct DroneDestroyedEvent : pgf::TypeRegistrar<DroneDestroyedEvent, "DroneDestr
// {
// entt::entity entity;
// };
} // namespace galaxy::events
} // namespace galaxy::events
2 changes: 1 addition & 1 deletion apps/galaxy/events/UIEvents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ struct MenuButtonPressed : public pgf::TypeRegistrar<MenuButtonPressed, "MenuBut
std::string buttonName;
};

} // namespace galaxy::events
} // namespace galaxy::events
2 changes: 1 addition & 1 deletion apps/galaxy/gui/MainMenuWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class MainMenuWidget : public galaxy::gui::GameGuiWidget
// center vertically
ImGui::SetCursorPos(ImVec2(centering.x, (ImGui::GetIO().DisplaySize.y * 0.5f) - (size_y * 0.5f)));
// background sprite
ImGui::Image((ImTextureID)_dot_texture.get()->get(),
ImGui::Image(reinterpret_cast<ImTextureID>(_dot_texture.get()->get()),
ImVec2(static_cast<float>(size_x), static_cast<float>(size_y)));
// TODO: style from config
pgf::gui::StyleStack stack;
Expand Down
2 changes: 1 addition & 1 deletion apps/galaxy/gui/menus/OptionsMenu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,4 @@ static bool optionsMenu(galaxy::config::Galaxy& galaxy_config,

return save;
}
} // namespace galaxy::gui
} // namespace galaxy::gui
9 changes: 3 additions & 6 deletions apps/galaxy/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ try
game_config.windowConfig.size = {800, 600};
game_config.windowConfig.windowName = "Galaxy";

game_config.vfsConfigs.push_back({.root = "../data", .alias = "data"});
game_config.vfsConfigs.push_back({.root = "../data", .alias = "::resources"});
game_config.vfsConfigs.push_back(
{.root = "../data", .alias = "data", .type = pg::game::VFSConfig::VFSType::PHYSICAL});
game_config.vfsConfigs.push_back(
{.root = "../data", .alias = "::resources", .type = pg::game::VFSConfig::VFSType::PHYSICAL});
game_config.vfsConfigs.push_back({.root = "../data/music/cylinders/Chris Zabriskie - Cylinders.zip",
.alias = "music/soundtracks/cylinders",
.type = pg::game::VFSConfig::VFSType::ZIP});
{.root = "../data/music/cylinders/Chris Zabriskie - Cylinders.zip", .alias = "music/soundtracks/cylinders"});
{
galaxy::GalacticCore gc(std::move(game_config));
gc.setup();
Expand Down
1 change: 1 addition & 0 deletions apps/galaxy/systems/DroneSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ void galaxy::DroneSystem::createFactions(const pg::FrameStamp& frameStamp)
// event
_game.getDispatcher().enqueue<galaxy::events::SystemOwnerChangedEvent>({
.system_entity = starsystem_entity,
.previous_owner = "",
.owner_faction = faction.name,
.status = ColonizationStatus::Colonized,
.old_status = ColonizationStatus::Unexplored,
Expand Down
2 changes: 1 addition & 1 deletion apps/galaxy/systems/DroneSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class DroneSystem : public pg::game::SystemInterface

behavior::ContextPtr ctx{};
};
} // namespace galaxy
} // namespace galaxy
8 changes: 4 additions & 4 deletions apps/sandboxes/productionSandbox/ProductionLine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class ProductionLine
public:
enum class State
{
EMPTY_QUEUE, //< currently no items in queue
WAITING_FOR_RESOURCES, //< currently produced item waits for resources
FINISHED, //< item production finished
RUNNING, //< currently producing
EMPTY_QUEUE, ///< currently no items in queue
WAITING_FOR_RESOURCES, ///< currently produced item waits for resources
FINISHED, ///< item production finished
RUNNING, ///< currently producing
};

ProductionLine(Storage& input_storage, Storage& output_storage, float capacity = 1.0)
Expand Down
5 changes: 3 additions & 2 deletions apps/sandboxes/resourceLoaderSandbox/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project(resourceLoaderSandBox)

add_executable(${PROJECT_NAME} main.cpp)
add_executable(${PROJECT_NAME})

target_sources(${PROJECT_NAME}
PUBLIC
Expand All @@ -11,7 +11,8 @@ target_link_libraries(${PROJECT_NAME}
PUBLIC
pgEngine::pgEngine
pgGame::pgGame
vfspp
PhysFSPP::PhysFSPP
#vfspp
)

if (ENABLE_COVERAGE)
Expand Down
Loading
Loading