Category : collision

I’ve seen there is a lot of posts about this already but I can’t find one that relates to what I want to do, I used the formula from here: https://www.vobarian.com/collisions/2dcollisions2.pdf As well as this one: https://www.plasmaphysics.org.uk/programs/coll2d_cpp.htm I think they area basically the same thing, now my problem is one of my circles is always ..

Read more

The errors that I get: initial value of reference to non-const must be a lvalue bool Collider::CheckCollision(Collider &, float)’:cannot convert argument 1 from ‘Collider’ to ‘Collider &’ Collider.h: #pragma once #include <SFML/Graphics.hpp> class Collider { public: Collider(sf::RectangleShape& body); ~Collider(); void Move(float dx, float dy) { body.move(dx, dy); } bool CheckCollision(Collider& other, float push); sf::Vector2f GetPosition() ..

Read more

I am trying to make my moving rectangle bounce off the window borders when it collides with them, however the rectangle is rotating. I’m not sure how to define my collision functions, this is what I came up with: //left border collision if(rectangle.getPosition().y<0){ rectangle.setPosition(rectangle.getPosition().x,0); //top border collision }; if(rectangle.getPosition().x<0){ rectangle.setPosition(0,rectangle.getPosition().y); }; //right border collision if(rectangle.getPosition().y+rectangle.getGlobalBounds().width>WINDOW_W){ ..

Read more