mirror of
https://github.com/zoriya/Bomberman.git
synced 2025-12-22 14:25:10 +00:00
collisions are working ok with user defined offsets
This commit is contained in:
@@ -10,13 +10,16 @@
|
||||
#include "Component/Renderer/Drawable2DComponent.hpp"
|
||||
#include "Drawables/ADrawable3D.hpp"
|
||||
|
||||
|
||||
#include "Component/Collision/CollisionComponent.hpp"
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
RenderSystem::RenderSystem(WAL::Wal &wal, RAY::Window &window, bool debugMode)
|
||||
: System(wal),
|
||||
_window(window),
|
||||
_camera(Vector3f(), Vector3f(), Vector3f(0, 1, 0), 50, CAMERA_PERSPECTIVE),
|
||||
_debugMode(debugMode)
|
||||
_window(window),
|
||||
_camera(Vector3f(), Vector3f(), Vector3f(0, 1, 0), 50, CAMERA_PERSPECTIVE),
|
||||
_debugMode(debugMode)
|
||||
{
|
||||
this->_window.setFPS(this->FPS);
|
||||
}
|
||||
@@ -29,6 +32,26 @@ namespace BBM
|
||||
|
||||
this->_window.useCamera(this->_camera);
|
||||
for (auto &[_, pos, drawable] : this->_wal.scene->view<PositionComponent, Drawable3DComponent>()) {
|
||||
if (_.getName() == "cube") {
|
||||
auto col = _.getComponent<CollisionComponent>();
|
||||
DrawCubeWires({pos.position.x, pos.position.y, pos.position.z},
|
||||
col.bound.x,
|
||||
col.bound.y,
|
||||
col.bound.z,
|
||||
WHITE);
|
||||
DrawPoint3D({pos.position.x, pos.position.y, pos.position.z}, BLUE);
|
||||
DrawPoint3D({pos.position.x + col.bound.x, pos.position.y + col.bound.y, pos.position.z + col.bound.z}, BLUE);
|
||||
}
|
||||
if (_.getName() == "player") {
|
||||
auto col = _.getComponent<CollisionComponent>();
|
||||
DrawCubeWires({pos.position.x, pos.position.y, pos.position.z},
|
||||
col.bound.x,
|
||||
col.bound.y,
|
||||
col.bound.z,
|
||||
WHITE);
|
||||
DrawPoint3D({pos.position.x, pos.position.y, pos.position.z}, BLUE);
|
||||
DrawPoint3D({pos.position.x + col.bound.x, pos.position.y + col.bound.y, pos.position.z + col.bound.z}, BLUE);
|
||||
}
|
||||
drawable.drawable->setPosition(pos.position);
|
||||
drawable.drawable->drawOn(this->_window);
|
||||
}
|
||||
@@ -44,7 +67,8 @@ namespace BBM
|
||||
this->_window.endDrawing();
|
||||
}
|
||||
|
||||
void RenderSystem::onUpdate(WAL::ViewEntity<CameraComponent, PositionComponent> &entity, std::chrono::nanoseconds dtime)
|
||||
void
|
||||
RenderSystem::onUpdate(WAL::ViewEntity<CameraComponent, PositionComponent> &entity, std::chrono::nanoseconds dtime)
|
||||
{
|
||||
const auto &pos = entity.get<PositionComponent>();
|
||||
const auto &cam = entity.get<CameraComponent>();
|
||||
|
||||
Reference in New Issue
Block a user