摄像机系统,和子对象绑定
This commit is contained in:
@@ -19,10 +19,6 @@ void register_square_behaviors() {
|
||||
"square_tick",
|
||||
[](boundard::Actor& actor, float dt, const boundard::render::InputMap& input) {
|
||||
const float t = actor.age();
|
||||
actor.set_facing({
|
||||
std::cos(t * 1.5F),
|
||||
std::sin(t * 1.5F),
|
||||
});
|
||||
|
||||
if (actor.mesh() != nullptr) {
|
||||
actor.mesh()->set_color({
|
||||
@@ -34,7 +30,7 @@ void register_square_behaviors() {
|
||||
}
|
||||
|
||||
auto position = actor.position();
|
||||
const float move_speed = 0.7F;
|
||||
constexpr float move_speed = 0.7F;
|
||||
position[0] += input.get_axis("move_left", "move_right") * move_speed * dt;
|
||||
position[1] += input.get_axis("move_up", "move_down") * move_speed * dt;
|
||||
actor.set_position(position);
|
||||
@@ -54,12 +50,8 @@ void register_square_behaviors() {
|
||||
|
||||
behaviors.register_tick(
|
||||
"square_alt_tick",
|
||||
[](boundard::Actor& actor, float dt, const boundard::render::InputMap& input) {
|
||||
[](boundard::Actor& actor, const float dt, const boundard::render::InputMap& input) {
|
||||
const float t = actor.age();
|
||||
actor.set_facing({
|
||||
std::sin(t * 1.3F),
|
||||
std::cos(t * 1.3F),
|
||||
});
|
||||
|
||||
if (actor.mesh() != nullptr) {
|
||||
actor.mesh()->set_color({
|
||||
@@ -71,7 +63,7 @@ void register_square_behaviors() {
|
||||
}
|
||||
|
||||
auto position = actor.position();
|
||||
const float move_speed = 0.7F;
|
||||
constexpr float move_speed = 0.7F;
|
||||
position[0] += input.get_axis("move_left", "move_right") * move_speed * dt;
|
||||
position[1] += input.get_axis("move_up", "move_down") * move_speed * dt;
|
||||
actor.set_position(position);
|
||||
|
||||
Reference in New Issue
Block a user