1
General discussions / Re: BOx2d with SFML
« on: June 16, 2024, 08:44:13 am »
I'm attaching a video that shows part of the problem, i need to use Box2D because its part of a project in University.
Also, here's the movement code:
Also, here's the movement code:
void Player::move(sf::Time time)
{
b2Vec2 boxPos = getBox()->GetPosition();
auto dt = time.asSeconds();
getBox()->SetTransform(boxPos + b2Vec2(VELOCITY * dt, 0.0f), getBox()->GetAngle());
setPosition(sf::Vector2f(boxPos.x * 30, boxPos.y * 30));
}
{
b2Vec2 boxPos = getBox()->GetPosition();
auto dt = time.asSeconds();
getBox()->SetTransform(boxPos + b2Vec2(VELOCITY * dt, 0.0f), getBox()->GetAngle());
setPosition(sf::Vector2f(boxPos.x * 30, boxPos.y * 30));
}