-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into Arms/Dev
- Loading branch information
Showing
18 changed files
with
151 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
[[ ! $(git --version) ]] && exit 1 | ||
|
||
output=$(git diff) | ||
|
||
if [[ "$output" != "" ]]; then | ||
echo "One or more source files are not formatted!" | ||
exit 1 | ||
fi | ||
|
||
echo "All source files are formatted" | ||
exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: ci | ||
on: [push] | ||
jobs: | ||
format-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: format code | ||
run: tools/format_code.sh | ||
- name: check diff | ||
run: .github/format_check_diff.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <dog/components/physics.hpp> | ||
|
||
namespace dog::component { | ||
|
||
void Physics::tick(bave::Seconds dt) { | ||
static constexpr bave::Seconds ft{0.005}; // 5ms | ||
|
||
if (dt.count() > tick_limit_v.count()) { | ||
return; | ||
} // return for unexpected dt values, particularly during the beginning of the state | ||
|
||
for (dt += m_residue; dt > ft; dt -= ft) { integrate(ft); } | ||
m_residue = dt; | ||
} | ||
|
||
void Physics::integrate(bave::Seconds dt) { | ||
acceleration.y += gravity * dt.count(); | ||
velocity = (velocity + (acceleration / mass) * dt.count()) * friction; | ||
|
||
velocity = glm::clamp(velocity, -max_velocity_v, max_velocity_v); | ||
|
||
position += velocity * dt.count(); | ||
} | ||
} // namespace dog::component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
#include <bave/app.hpp> | ||
#include <bave/graphics/sprite.hpp> | ||
|
||
namespace dog::component { | ||
class Physics { | ||
|
||
static constexpr glm::vec2 default_friction{0.99f}; | ||
static constexpr float default_gravity{-1000.f}; | ||
static constexpr float default_mass{1.f}; | ||
|
||
static constexpr glm::vec2 max_velocity_v{1000.f}; | ||
static constexpr bave::Seconds tick_limit_v{100ms}; | ||
|
||
bave::Seconds m_residue{}; | ||
|
||
public: | ||
Physics(glm::vec2 friction = default_friction, float gravity = default_gravity, float mass = default_mass) | ||
: friction(friction), gravity(gravity), mass(mass) {} | ||
|
||
glm::vec2 position{}; | ||
glm::vec2 velocity{}; | ||
glm::vec2 acceleration{}; | ||
|
||
glm::vec2 friction{}; | ||
float gravity{}; | ||
float mass{}; | ||
|
||
void tick(bave::Seconds dt); | ||
void integrate(bave::Seconds dt); | ||
}; | ||
} // namespace dog::component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
DogTales/src/services/service.hpp → DogTales/dog/services/service.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#pragma once | ||
#include <bave/core/polymorphic.hpp> | ||
|
||
namespace dog { | ||
/// \brief Base class for all services. | ||
class IService : public bave::Polymorphic {}; | ||
} // namespace dog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
[[ ! $(clang-format --version) ]] && exit 1 | ||
|
||
script_path=${0%/*} | ||
tools_root=${script_path%/*} | ||
project_root=$tools_root/.. | ||
|
||
if [[ "$0" != "$project_root" ]] && [[ "$project_root" != "" ]]; then | ||
cd "$project_root" || exit 1 | ||
echo "-- Changed pwd to $(pwd)" | ||
fi | ||
|
||
files=$(find DogTales -name "*.?pp") | ||
if [[ "$files" == "" ]]; then | ||
echo "-- No source files found" | ||
exit | ||
fi | ||
|
||
clang-format -i $files | ||
echo -e "-- Formatted Files:\n$files\n" | ||
|
||
exit |