Collisions are still broke

This commit is contained in:
Zoe Roux
2021-06-07 11:37:16 +02:00
parent e624a2f7fe
commit f47dd669f1
3 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ namespace WAL
//! @brief True if the engine should close after the end of the current tick.
bool shouldClose = false;
//! @brief The time between each fixed update.
static constexpr std::chrono::nanoseconds timestep = std::chrono::milliseconds(16);
static constexpr std::chrono::nanoseconds timestep = std::chrono::milliseconds(32);
//! @brief Create a new system in place.
//! @return The wal instance used to call this function is returned. This allow method chaining.
+1 -1
View File
@@ -19,7 +19,7 @@ namespace BBM
auto &pos = entity.getComponent<PositionComponent>();
const auto &wallPos = wall.getComponent<PositionComponent>();
auto diff = pos.position + mov->getVelocity() - wallPos.position;
std::cout << diff << std::endl;
// mov->_velocity = Vector3f();
if (diff.x <= 0 && mov->_velocity.x < 0)
mov->_velocity.x = 0;
if (diff.x >= 0 && mov->_velocity.x > 0)
+6
View File
@@ -72,6 +72,12 @@ namespace BBM
scene->addEntity("camera")
.addComponent<PositionComponent>(8, 20, 7)
.addComponent<CameraComponent>(Vector3f(8, 0, 8));
// scene->addEntity("cube")
// .addComponent<PositionComponent>(5, 0, 5)
// .addComponent<Drawable3DComponent, RAY3D::Cube>(Vector3f(-5, 0, -5), Vector3f(3, 3, 3), RED)
// .addComponent<ControllableComponent>()
// .addComponent<KeyboardComponent>()
// .addComponent<CollisionComponent>(WAL::Callback<WAL::Entity &, const WAL::Entity &>(), &MapGenerator::wallCollide, 3);
std::srand(std::time(nullptr));
MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16), scene);
return scene;