aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-04-15 22:38:14 +0100
committerYann Herklotz <ymherklotz@gmail.com>2017-04-15 22:38:14 +0100
commit325d8c2348b5cabe32d1e90ce28a049f278e3f8c (patch)
treed90a4f188a7489f46b9835eae007c9b45f6627c2 /src
parentdaa032e2f6c86da16902f654055d8b040d7670bb (diff)
downloadYAGE-325d8c2348b5cabe32d1e90ce28a049f278e3f8c.tar.gz
YAGE-325d8c2348b5cabe32d1e90ce28a049f278e3f8c.zip
Added test bench
Diffstat (limited to 'src')
-rw-r--r--src/rectanglecollider.cpp24
-rw-r--r--src/resourcemanager.cpp2
-rw-r--r--src/rigidbody.cpp16
3 files changed, 41 insertions, 1 deletions
diff --git a/src/rectanglecollider.cpp b/src/rectanglecollider.cpp
new file mode 100644
index 00000000..812b10d1
--- /dev/null
+++ b/src/rectanglecollider.cpp
@@ -0,0 +1,24 @@
+#include "Physics/rectanglecollider.hpp"
+
+namespace yage
+{
+
+RectangleCollider::RectangleCollider(const glm::vec2 &position, const glm::vec2 &size) :
+ Collider(position, size)
+{}
+
+bool RectangleCollider::collides(const Collider &collider) const
+{
+ for(int i=position_.x; i<position_.x+size_.x; ++i)
+ for(int j=position_.y; j<position_.y+size_.y; ++j)
+ return collider.inside(glm::vec2(i, j));
+ return false;
+}
+
+inline bool RectangleCollider::inside(const glm::vec2 &point) const
+{
+ return position_.x<point.x && position_.x+size_.x>point.x &&
+ position_.y<point.y && position_.y+size_.y>point.y;
+}
+
+} // yage
diff --git a/src/resourcemanager.cpp b/src/resourcemanager.cpp
index 06f71078..4105f4e4 100644
--- a/src/resourcemanager.cpp
+++ b/src/resourcemanager.cpp
@@ -7,7 +7,7 @@ TextureCache ResourceManager::texture_cache_;
Texture ResourceManager::getTexture(const std::string &texture_path)
{
- return texture_cache_.getTexture(texture_path);
+ return texture_cache_.getTexture(texture_path);
}
} // yage
diff --git a/src/rigidbody.cpp b/src/rigidbody.cpp
new file mode 100644
index 00000000..3f719784
--- /dev/null
+++ b/src/rigidbody.cpp
@@ -0,0 +1,16 @@
+#include "Physics/rigidbody.hpp"
+
+namespace yage
+{
+
+RigidBody::RigidBody(const glm::vec2 &center_of_mass, double mass, const glm::vec2 &velocity, bool gravity) :
+ Body(center_of_mass, mass, velocity, gravity)
+{}
+
+void RigidBody::applyForce(const glm::vec2 &force)
+{
+ // a=F/m
+ glm::vec2 acceleration(force.x/mass_, force.y/mass_);
+}
+
+} // yage