moar collisionz
This commit is contained in:
@@ -7,7 +7,7 @@ void GameWorld::Initialize()
|
||||
|
||||
//AddSystem("LevelGenerationSystem");
|
||||
AddSystem("InputSystem");
|
||||
//AddSystem("CollisionSystem");
|
||||
AddSystem("CollisionSystem");
|
||||
//AddSystem("ParticleSystem");
|
||||
AddSystem("PlayerSystem");
|
||||
AddSystem("SoundSystem");
|
||||
@@ -17,19 +17,26 @@ void GameWorld::Initialize()
|
||||
std::shared_ptr<Components::Model> model;
|
||||
std::shared_ptr<Components::PointLight> pointLight;
|
||||
std::shared_ptr<Components::Camera> camera;
|
||||
std::shared_ptr<Components::Bounds> bounds;
|
||||
std::shared_ptr<Components::Collision> collision;
|
||||
EntityID ent;
|
||||
|
||||
// Camera
|
||||
ent = CreateEntity();
|
||||
SetProperty(ent, "Name", std::string("Camera"));
|
||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||
AddComponent<Components::Input>(ent, "Input");
|
||||
entcamera = CreateEntity();
|
||||
SetProperty(entcamera, "Name", std::string("Camera"));
|
||||
transform = AddComponent<Components::Transform>(entcamera, "Transform");
|
||||
AddComponent<Components::Input>(entcamera, "Input");
|
||||
transform->Position = glm::vec3(0.f, 2.f, 10.f);
|
||||
camera = AddComponent<Components::Camera>(ent, "Camera");
|
||||
camera = AddComponent<Components::Camera>(entcamera, "Camera");
|
||||
camera->FOV = 45.f;
|
||||
camera->FarClip = 1000.f;
|
||||
camera->NearClip = 0.01f;
|
||||
transform->Orientation = glm::angleAxis<float>(glm::radians(25.0f),glm::vec3(1,0,0));
|
||||
collision = AddComponent<Components::Collision>(entcamera, "Collision");
|
||||
collision->Phantom = false;
|
||||
bounds = AddComponent<Components::Bounds>(entcamera, "Bounds");
|
||||
bounds->Origin = transform->Position;
|
||||
bounds->VolumeVector = glm::vec3(4.f,2.f,2.f);
|
||||
|
||||
// Fucking lights
|
||||
ent = CreateEntity();
|
||||
@@ -84,22 +91,35 @@ void GameWorld::Initialize()
|
||||
model->ModelFile = "plane.obj";
|
||||
|
||||
// Player
|
||||
ent = CreateEntity();
|
||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||
player1 = CreateEntity();
|
||||
transform = AddComponent<Components::Transform>(player1, "Transform");
|
||||
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
||||
model = AddComponent<Components::Model>(ent, "Model");
|
||||
model = AddComponent<Components::Model>(player1, "Model");
|
||||
model->ModelFile = "ship.obj";
|
||||
collision = AddComponent<Components::Collision>(player1, "Collision");
|
||||
collision->Phantom = false;
|
||||
bounds = AddComponent<Components::Bounds>(player1, "Bounds");
|
||||
bounds->Origin = transform->Position;
|
||||
bounds->VolumeVector = glm::vec3(10.f,10.f,5.f);
|
||||
|
||||
ent = CreateEntity();
|
||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||
|
||||
player2 = CreateEntity();
|
||||
transform = AddComponent<Components::Transform>(player2, "Transform");
|
||||
transform->Position = glm::vec3(10.f, 0.f, 0.f);
|
||||
model = AddComponent<Components::Model>(ent, "Model");
|
||||
model = AddComponent<Components::Model>(player2, "Model");
|
||||
model->ModelFile = "ship.obj";
|
||||
collision = AddComponent<Components::Collision>(player2, "Collision");
|
||||
collision->Phantom = false;
|
||||
bounds = AddComponent<Components::Bounds>(player2, "Bounds");
|
||||
bounds->Origin = transform->Position;
|
||||
bounds->VolumeVector = glm::vec3(2.f,2.f,2.f);
|
||||
}
|
||||
|
||||
void GameWorld::Update(double dt)
|
||||
{
|
||||
World::Update(dt);
|
||||
if(GetSystem<Systems::CollisionSystem>("CollisionSystem")->Intersects(player1, entcamera))
|
||||
assert(false);
|
||||
}
|
||||
|
||||
void GameWorld::RegisterComponents()
|
||||
@@ -124,7 +144,7 @@ void GameWorld::RegisterSystems()
|
||||
{
|
||||
//m_SystemFactory.Register("LevelGenerationSystem", [this]() { return new Systems::LevelGenerationSystem(this); });
|
||||
m_SystemFactory.Register("InputSystem", [this]() { return new Systems::InputSystem(this, m_Renderer); });
|
||||
//m_SystemFactory.Register("CollisionSystem", [this]() { return new Systems::CollisionSystem(this); });
|
||||
m_SystemFactory.Register("CollisionSystem", [this]() { return new Systems::CollisionSystem(this); });
|
||||
//m_SystemFactory.Register("ParticleSystem", [this]() { return new Systems::ParticleSystem(this); });
|
||||
m_SystemFactory.Register("PlayerSystem", [this]() { return new Systems::PlayerSystem(this); });
|
||||
m_SystemFactory.Register("SoundSystem", [this]() { return new Systems::SoundSystem(this); });
|
||||
|
||||
Reference in New Issue
Block a user