diff --git a/include/physics_engine.h b/include/physics_engine.h index bcd4853..3bc092e 100644 --- a/include/physics_engine.h +++ b/include/physics_engine.h @@ -4,6 +4,7 @@ #include #include #include "physics_object.h" +#include "physics_circle.h" class PhysicsEngine{ private: @@ -12,9 +13,9 @@ class PhysicsEngine{ static bool(*collisionTable)(PhysicsObject*, PhysicsObject*) [4][4]; public: - void addObject(std::unique_ptr obj); - - + void addCircle(float radius, ShapeID ID, + sf::Vector2f pos, sf::Vector2f vel, sf::Vector2f acc, + float angle, float ang_acc, float ang_vel, PhysicalAttributes attr, bool isStatic); void update(sf::Time dt); void draw(sf::RenderWindow& window); }; diff --git a/include/physics_engine.h~ b/include/physics_engine.h~ new file mode 100644 index 0000000..e69de29 diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..038d624 --- /dev/null +++ b/main.cpp @@ -0,0 +1,23 @@ +#include +#include +using namespace std; + +void func() { + for (int i = 0; i < 10; i++) { + cout << "Thread 1" << endl; + } +} + +int main() { + sf::Thread thread1(&func), thread2(&func); + thread1.launch(); + thread2.launch(); + + for(int i = 0; i < 10; i++) { + cout << "Main thread" << endl; + } + + return 0; +} + + diff --git a/main.cpp~ b/main.cpp~ new file mode 100644 index 0000000..9ad31e8 --- /dev/null +++ b/main.cpp~ @@ -0,0 +1,27 @@ +#include +#include +using namespace std; + +void func() { + for (int i = 0; i < 10; i++) { + cout << "Thread 1" << endl; + } +} + +int main() { + sf::Thread thread(&func); + // wait + + //wait + + //wait + thread.launch(); + + for(int i = 0; i < 10; i++) { + cout << "Main thread" << endl; + } + + return 0; +} + + diff --git a/sfml-app b/sfml-app new file mode 100755 index 0000000..3e69497 Binary files /dev/null and b/sfml-app differ diff --git a/src/physics_engine.cpp b/src/physics_engine.cpp index 9394463..0e56828 100644 --- a/src/physics_engine.cpp +++ b/src/physics_engine.cpp @@ -33,7 +33,20 @@ namespace{ *PhysicsEngine::collisionTable[0][0] = circlecircleCollision; -void PhysicsEngine::addObject(std::unique_ptr obj) { +void PhysicsEngine::addCircle(float radius, ShapeID ID, + sf::Vector2f pos, sf::Vector2f vel, sf::Vector2f acc, + float angle, float ang_acc, float ang_vel, const PhysicalAttributes &attr, bool isStatic) { + std::unique_ptr obj = new Circle(radius, pos); + + obj->setPosition(pos); + obj->setVelocity(vel); + obj->setAcceleration(acc); + obj->setAngle(angle); + obj->setAngularAcceleration(ang_acc); + obj->setAngularVelocity(ang_vel); + obj->setAttributes(attr); + obj->setIsStatic(isStatic); + objects.push_back(std::move(obj)); } @@ -54,5 +67,6 @@ void PhysicsEngine::draw(sf::RenderWindow& window) { for (auto& obj : objects) obj->draw(window); } +