Renamed
This commit is contained in:
+9
-9
@@ -1,25 +1,25 @@
|
||||
cmake_minimum_required(VERSION 3.10.0)
|
||||
project(opencge VERSION 0.1.0 LANGUAGES C CXX)
|
||||
project(Boundard VERSION 0.1.0 LANGUAGES C CXX)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
add_library(opencge STATIC
|
||||
src/opencge.cpp
|
||||
add_library(boundard STATIC
|
||||
src/boundard.cpp
|
||||
src/game.cpp
|
||||
src/render.cpp
|
||||
src/config.cpp
|
||||
src/engine.cpp
|
||||
)
|
||||
target_include_directories(opencge PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
target_compile_features(opencge PUBLIC cxx_std_17)
|
||||
target_include_directories(boundard PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
target_compile_features(boundard PUBLIC cxx_std_17)
|
||||
|
||||
find_package(glfw3 REQUIRED)
|
||||
find_package(Vulkan REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(JSONCPP REQUIRED IMPORTED_TARGET jsoncpp)
|
||||
target_link_libraries(opencge PUBLIC glfw Vulkan::Vulkan PkgConfig::JSONCPP)
|
||||
target_link_libraries(boundard PUBLIC glfw Vulkan::Vulkan PkgConfig::JSONCPP)
|
||||
|
||||
add_executable(square_example examples/square/main.cpp)
|
||||
target_link_libraries(square_example PRIVATE opencge)
|
||||
target_link_libraries(square_example PRIVATE boundard)
|
||||
|
||||
add_executable(opencge_engine src/engine_main.cpp)
|
||||
target_link_libraries(opencge_engine PRIVATE opencge)
|
||||
add_executable(boundard_engine src/engine_main.cpp)
|
||||
target_link_libraries(boundard_engine PRIVATE boundard)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <openceg.hpp>
|
||||
#include <boundard.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
void register_square_behaviors() {
|
||||
auto& behaviors = openceg::BehaviorRegistry::getInstance();
|
||||
auto& behaviors = boundard::BehaviorRegistry::getInstance();
|
||||
|
||||
behaviors.register_init("square_init", [](openceg::Actor& actor) {
|
||||
behaviors.register_init("square_init", [](boundard::Actor& actor) {
|
||||
actor.set_position({0.0F, 0.0F});
|
||||
actor.set_facing({1.0F, 0.0F});
|
||||
if (actor.mesh() != nullptr) {
|
||||
@@ -17,7 +17,7 @@ void register_square_behaviors() {
|
||||
|
||||
behaviors.register_tick(
|
||||
"square_tick",
|
||||
[](openceg::Actor& actor, float dt, const openceg::render::InputMap& input) {
|
||||
[](boundard::Actor& actor, float dt, const boundard::render::InputMap& input) {
|
||||
const float t = actor.age();
|
||||
actor.set_facing({
|
||||
std::cos(t * 1.5F),
|
||||
@@ -45,5 +45,5 @@ void register_square_behaviors() {
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
register_square_behaviors();
|
||||
return openceg::run_engine(argc, argv, "examples/square/config.ceg");
|
||||
return boundard::run_engine(argc, argv, "examples/square/config.ceg");
|
||||
}
|
||||
|
||||
+3
-3
@@ -9,11 +9,11 @@
|
||||
#include <game.hpp>
|
||||
#include <mesh.hpp>
|
||||
|
||||
namespace openceg::render {
|
||||
namespace boundard::render {
|
||||
class InputMap;
|
||||
}
|
||||
|
||||
namespace openceg {
|
||||
namespace boundard {
|
||||
|
||||
class Actor {
|
||||
private:
|
||||
@@ -109,4 +109,4 @@ class Actor {
|
||||
void set_mesh(std::shared_ptr<Mesh> mesh) { mesh_ = std::move(mesh); }
|
||||
};
|
||||
|
||||
} // namespace openceg
|
||||
} // namespace boundard
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
#include <actor.hpp>
|
||||
|
||||
namespace openceg::render {
|
||||
namespace boundard::render {
|
||||
class InputMap;
|
||||
}
|
||||
|
||||
namespace openceg {
|
||||
namespace boundard {
|
||||
|
||||
using ActorInitHandler = std::function<void(Actor&)>;
|
||||
using ActorTickHandler = std::function<void(Actor&, float, const render::InputMap&)>;
|
||||
@@ -62,4 +62,4 @@ class BehaviorRegistry {
|
||||
std::unordered_map<std::string, ActorTickHandler> tick_handlers_;
|
||||
};
|
||||
|
||||
} // namespace openceg
|
||||
} // namespace boundard
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace openceg {
|
||||
namespace boundard {
|
||||
|
||||
struct WindowConfig {
|
||||
int width = 800;
|
||||
@@ -51,4 +51,4 @@ class ConfigLoader {
|
||||
std::string last_error_;
|
||||
};
|
||||
|
||||
} // namespace openceg
|
||||
} // namespace boundard
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
namespace openceg {
|
||||
namespace boundard {
|
||||
|
||||
// 通用引擎入口:读取 config.ceg,实例化场景并驱动 Actor 的 init/tick。
|
||||
// 具体游戏行为通过 BehaviorRegistry 注册,因此引擎本身不内置任何游戏逻辑。
|
||||
int run_engine(int argc, char** argv, const char* default_config_path = "config.ceg");
|
||||
|
||||
} // namespace openceg
|
||||
} // namespace boundard
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
|
||||
namespace openceg {
|
||||
namespace boundard {
|
||||
class Game {
|
||||
private:
|
||||
size_t id_cnt;
|
||||
@@ -18,4 +18,4 @@ class Game {
|
||||
void launch();
|
||||
size_t new_id();
|
||||
};
|
||||
} // namespace openceg
|
||||
} // namespace boundard
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace openceg {
|
||||
namespace boundard {
|
||||
|
||||
// 渲染组件:描述 Actor 的几何形状、颜色和纹理占位。
|
||||
class Mesh {
|
||||
@@ -48,4 +48,4 @@ class Mesh {
|
||||
std::array<float, 4> color_{1.0F, 1.0F, 1.0F, 1.0F};
|
||||
};
|
||||
|
||||
} // namespace openceg
|
||||
} // namespace boundard
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <actor.hpp>
|
||||
|
||||
namespace openceg::render {
|
||||
namespace boundard::render {
|
||||
|
||||
struct InputEvent {
|
||||
enum class Type {
|
||||
@@ -136,4 +136,4 @@ class RenderLoop {
|
||||
std::vector<Actor*> actors_;
|
||||
};
|
||||
|
||||
} // namespace openceg::render
|
||||
} // namespace boundard::render
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include <boundard.hpp>
|
||||
+2
-2
@@ -8,7 +8,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace openceg {
|
||||
namespace boundard {
|
||||
namespace {
|
||||
|
||||
std::string lowercase(std::string value) {
|
||||
@@ -320,4 +320,4 @@ const std::string& ConfigLoader::last_error() const {
|
||||
return last_error_;
|
||||
}
|
||||
|
||||
} // namespace openceg
|
||||
} // namespace boundard
|
||||
|
||||
+3
-3
@@ -7,9 +7,9 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include <openceg.hpp>
|
||||
#include <boundard.hpp>
|
||||
|
||||
namespace openceg {
|
||||
namespace boundard {
|
||||
|
||||
int run_engine(int argc, char** argv, const char* default_config_path) {
|
||||
std::string config_path = default_config_path != nullptr ? default_config_path : "config.ceg";
|
||||
@@ -114,4 +114,4 @@ int run_engine(int argc, char** argv, const char* default_config_path) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace openceg
|
||||
} // namespace boundard
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include <engine.hpp>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
return openceg::run_engine(argc, argv);
|
||||
return boundard::run_engine(argc, argv);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include <game.hpp>
|
||||
|
||||
namespace openceg {
|
||||
namespace boundard {
|
||||
|
||||
Game::Game() { id_cnt = 0; }
|
||||
Game::~Game() = default;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
#include <openceg.hpp>
|
||||
+2
-2
@@ -12,7 +12,7 @@
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
namespace openceg::render {
|
||||
namespace boundard::render {
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -1337,4 +1337,4 @@ void Renderer::Impl::destroy() {
|
||||
initialized = false;
|
||||
}
|
||||
|
||||
} // namespace openceg::render
|
||||
} // namespace boundard::render
|
||||
|
||||
Reference in New Issue
Block a user