Skip to content

Commit

Permalink
Added first behaviour example
Browse files Browse the repository at this point in the history
  • Loading branch information
iWas-Coder committed Sep 17, 2024
1 parent 8592340 commit c86f452
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/TurningAround.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
struct TurningAround : volt::runtime::IBehaviour {
int speed = 100;
float angularSpeed = 45;

void Update(volt::runtime::Entity &e) final {
auto &t = e.GetComponent<volt::runtime::TransformComponent>();
t.rotation += angularSpeed * volt::core::GetDeltaTime();
t.position += (volt::core::Vector2<>::down().Rotate(t.rotation) * speed) * volt::core::GetDeltaTime();
}
};

0 comments on commit c86f452

Please sign in to comment.