Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Personwwww

Pages: [1]
1
Graphics / Re: C++ SFML Collision Bug
« on: May 12, 2020, 12:48:24 am »
It barely is reacting at all. I want it to react by stopping the object that is colliding.

2
Graphics / Re: C++ SFML Collision Bug
« on: May 12, 2020, 12:02:05 am »
What doesn't work exactly? It's still detecting the collision fine?

What you are doing with pos and the unit increments, we can only guess without more information.

The collision detection is working fine but I am stuck on how to react.

3
Graphics / C++ SFML Collision Bug
« on: May 11, 2020, 07:29:49 pm »
I wrote some collision code that responds to collisions. So, I put it in a function. Then, the response to the collision stopped working but the collision detection still worked.

P.S OG_INFO means printf.
#include "Collision.h"

void OpenGEC::Collision::AddCollider(Sprite& sprite, Sprite& _sprite)
{

    if (sprite.getGlobalBounds().intersects(_sprite.getGlobalBounds())) {
        Vector2f pos_ = _sprite.getPosition();
        Vector2f pos = sprite.getPosition();
        if (pos.y > pos_.y) {
            pos.y++;
            sprite.setPosition(pos);
            _sprite.setPosition(pos_);
            OG_INFO("{0},{1}", pos.x, pos.y);
        }
        else if (pos.y < pos_.y) {
            pos.y--;
            sprite.setPosition(pos);
            _sprite.setPosition(pos_);
            OG_INFO("{0},{1}", pos.x, pos.y);
        }
        else if (pos.x > pos_.x) {
            pos.x++;
            sprite.setPosition(pos);
            _sprite.setPosition(pos_);
            OG_INFO("{0},{1}", pos.x, pos.y);
        }
        else if (pos.x < pos_.x) {
            pos.x --;
            sprite.setPosition(pos);
            _sprite.setPosition(pos_);
            OG_INFO("{0},{1}", pos.x, pos.y);
        }
    }
}

Pages: [1]
anything