1234567891011121314151617181920212223242526272829 |
- #include "Body.h"
-
- namespace Swan {
-
- void Body::friction(float coef) {
- force_ += -vel_ * coef;
- }
-
- void Body::gravity(Vec2 g) {
- force_ += g * mass_;
- }
-
- void Body::outline(Win &win) {
- win.setPos(pos_);
-
- sf::RectangleShape rect(size_);
- rect.setFillColor(sf::Color::Transparent);
- rect.setOutlineColor(sf::Color(128, 128, 128));
- rect.setOutlineThickness(2 / UNIT_SIZE);
- win.draw(rect);
- }
-
- void Body::update(float dt) {
- vel_ += (force_ / mass_) * dt;
- pos_ += vel_ * dt;
- force_ = { 0, 0 };
- }
-
- }
|