Checkpoint 2: integrate native Editor, MCP, gameplay builds and standalone export
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#include "Gameplay.hpp"
|
||||
|
||||
namespace faset::gameplay {
|
||||
void registerGameplay(runtime::Runtime& world) {
|
||||
runtime::Behavior mover;
|
||||
mover.update = [](runtime::Runtime& game, runtime::EntityHandle self, double delta) {
|
||||
// fields() returns a configuration copy. transform() returns a live pose copy.
|
||||
const auto settings = game.fields(self, "tutorial.move_x");
|
||||
const float speed = settings.value("speed", 2.0f); // metres per second
|
||||
auto pose = game.transform(self);
|
||||
pose.position[0] += speed * static_cast<float>(delta);
|
||||
game.setTransform(self, pose); // This object has no rigid body.
|
||||
};
|
||||
world.registerBehavior("tutorial.move_x", std::move(mover));
|
||||
}
|
||||
|
||||
nlohmann::json schema() {
|
||||
// The FieldId is the map key. Keep it stable if you change a display name.
|
||||
return nlohmann::json::array({{{"id", "tutorial.move_x"},
|
||||
{"version", 1},
|
||||
{"name", "Move along X"},
|
||||
{"fields",
|
||||
{{"speed",
|
||||
{{"id", "speed"},
|
||||
{"type", "number"},
|
||||
{"default", 2.0},
|
||||
{"min", -20.0},
|
||||
{"max", 20.0},
|
||||
{"units", "m/s"}}}}}}});
|
||||
}
|
||||
} // namespace faset::gameplay
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include <faset/runtime/Runtime.hpp>
|
||||
|
||||
namespace faset::gameplay {
|
||||
void registerGameplay(runtime::Runtime& world);
|
||||
nlohmann::json schema();
|
||||
} // namespace faset::gameplay
|
||||
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"format": "faset.scene",
|
||||
"version": 1,
|
||||
"id": "tutorial-moving",
|
||||
"name": "Moving tutorial",
|
||||
"dimension": 2,
|
||||
"simulation": {
|
||||
"fixed_delta": 0.016666666666666666,
|
||||
"max_catch_up_ticks": 4,
|
||||
"physics_substeps": 4,
|
||||
"gravity": [
|
||||
0,
|
||||
-9.81,
|
||||
0
|
||||
]
|
||||
},
|
||||
"entities": [
|
||||
{
|
||||
"id": "actor",
|
||||
"name": "actor",
|
||||
"parent": null,
|
||||
"components": [
|
||||
{
|
||||
"id": "actor-faset.transform",
|
||||
"type": "faset.transform",
|
||||
"version": 1,
|
||||
"fields": {
|
||||
"position": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"rotation": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"scale": [
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "actor-faset.sprite",
|
||||
"type": "faset.sprite",
|
||||
"version": 1,
|
||||
"fields": {
|
||||
"color": [
|
||||
0.2,
|
||||
0.7,
|
||||
0.9,
|
||||
1
|
||||
],
|
||||
"size": [
|
||||
1,
|
||||
1
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "actor-tutorial.move_x",
|
||||
"type": "tutorial.move_x",
|
||||
"version": 1,
|
||||
"fields": {
|
||||
"speed": 2
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"instances": []
|
||||
}
|
||||
Reference in New Issue
Block a user