Fulhack.
This commit is contained in:
@@ -17,6 +17,7 @@ struct Input : Component
|
|||||||
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> MouseState;
|
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> MouseState;
|
||||||
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> LastMouseState;
|
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> LastMouseState;
|
||||||
float dX, dY;
|
float dX, dY;
|
||||||
|
float WheelDelta;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace Components
|
|||||||
struct SoundEmitter : Component
|
struct SoundEmitter : Component
|
||||||
{
|
{
|
||||||
float Gain;
|
float Gain;
|
||||||
//float MaxDistance;
|
float MaxDistance;
|
||||||
float ReferenceDistance;
|
float ReferenceDistance;
|
||||||
float Pitch;
|
float Pitch;
|
||||||
bool Loop;
|
bool Loop;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>GLEW_STATIC;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>GLEW_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<MinimalRebuild>true</MinimalRebuild>
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
|||||||
@@ -39,26 +39,26 @@ void GameWorld::Initialize()
|
|||||||
pointLight->spotExponent = 0.0f;
|
pointLight->spotExponent = 0.0f;
|
||||||
model = AddComponent<Components::Model>(ent, "Model");
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
model->ModelFile = "Models/sphere.obj";*/
|
model->ModelFile = "Models/sphere.obj";*/
|
||||||
ent = CreateEntity();
|
auto sun = CreateEntity();
|
||||||
SetProperty(ent, "Name", std::string("Sun"));
|
SetProperty(sun, "Name", std::string("Sun"));
|
||||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
transform = AddComponent<Components::Transform>(sun, "Transform");
|
||||||
transform->Position = glm::vec3(0.f, 100.f, 30.f);
|
transform->Position = glm::vec3(0.f, 100.f, 30.f);
|
||||||
AddComponent<Components::Input>(ent, "Input");
|
AddComponent<Components::Input>(sun, "Input");
|
||||||
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
|
pointLight = AddComponent<Components::PointLight>(sun, "PointLight");
|
||||||
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
|
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
|
||||||
pointLight->Diffuse = glm::vec3(1.0, 0.45, 0.0);
|
pointLight->Diffuse = glm::vec3(1.0, 0.45, 0.0);
|
||||||
pointLight->constantAttenuation = 0.009f;
|
pointLight->constantAttenuation = 0.009f;
|
||||||
pointLight->linearAttenuation = -0.0177f;
|
pointLight->linearAttenuation = -0.0177f;
|
||||||
pointLight->quadraticAttenuation = 0.00043f;
|
pointLight->quadraticAttenuation = 0.00043f;
|
||||||
pointLight->spotExponent = 0.0f;
|
pointLight->spotExponent = 0.0f;
|
||||||
model = AddComponent<Components::Model>(ent, "Model");
|
model = AddComponent<Components::Model>(sun, "Model");
|
||||||
model->ModelFile = "Models/sphere.obj";
|
model->ModelFile = "Models/sphere.obj";
|
||||||
|
|
||||||
//ground
|
//ground
|
||||||
ent = CreateEntity();
|
auto ground = CreateEntity();
|
||||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
transform = AddComponent<Components::Transform>(ground, "Transform");
|
||||||
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
||||||
model = AddComponent<Components::Model>(ent, "Model");
|
model = AddComponent<Components::Model>(ground, "Model");
|
||||||
model->ModelFile = "Models/plane.obj";
|
model->ModelFile = "Models/plane.obj";
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
@@ -77,6 +77,8 @@ void GameWorld::Initialize()
|
|||||||
m_Player = CreateEntity();
|
m_Player = CreateEntity();
|
||||||
SetProperty(m_Player, "Name", std::string("Player"));
|
SetProperty(m_Player, "Name", std::string("Player"));
|
||||||
SetProperty(m_Player, "Camera", entcamera);
|
SetProperty(m_Player, "Camera", entcamera);
|
||||||
|
SetProperty(m_Player, "Ground", ground);
|
||||||
|
SetProperty(m_Player, "Sun", sun);
|
||||||
transform = AddComponent<Components::Transform>(m_Player, "Transform");
|
transform = AddComponent<Components::Transform>(m_Player, "Transform");
|
||||||
transform->Position = glm::vec3(0.f, 2.f, -5.f);
|
transform->Position = glm::vec3(0.f, 2.f, -5.f);
|
||||||
transform->Velocity = glm::vec3(10.f, 0.f, 100.f);
|
transform->Velocity = glm::vec3(10.f, 0.f, 100.f);
|
||||||
@@ -89,9 +91,12 @@ void GameWorld::Initialize()
|
|||||||
collision->Interested = true;
|
collision->Interested = true;
|
||||||
bounds = AddComponent<Components::Bounds>(m_Player, "Bounds");
|
bounds = AddComponent<Components::Bounds>(m_Player, "Bounds");
|
||||||
bounds->Origin = glm::vec3(0, 0, 2.f);
|
bounds->Origin = glm::vec3(0, 0, 2.f);
|
||||||
bounds->VolumeVector = glm::vec3(3.4f, 0.7f, 1);
|
bounds->VolumeVector = glm::vec3(2.7f, 0.7f, 1);
|
||||||
|
soundEmitter = AddComponent<Components::SoundEmitter>(m_Player, "SoundEmitter");
|
||||||
|
soundEmitter->Gain = 2.5f;
|
||||||
// Player light
|
// Player light
|
||||||
auto playerLight = CreateEntity(m_Player);
|
auto playerLight = CreateEntity(m_Player);
|
||||||
|
SetProperty(m_Player, "LightLeft", playerLight);
|
||||||
transform = AddComponent<Components::Transform>(playerLight, "Transform");
|
transform = AddComponent<Components::Transform>(playerLight, "Transform");
|
||||||
transform->Position = glm::vec3(1.5f, 0.25f, 2.5f);
|
transform->Position = glm::vec3(1.5f, 0.25f, 2.5f);
|
||||||
pointLight = AddComponent<Components::PointLight>(playerLight, "PointLight");
|
pointLight = AddComponent<Components::PointLight>(playerLight, "PointLight");
|
||||||
@@ -104,6 +109,7 @@ void GameWorld::Initialize()
|
|||||||
bounds = AddComponent<Components::Bounds>(playerLight, "Bounds");
|
bounds = AddComponent<Components::Bounds>(playerLight, "Bounds");
|
||||||
bounds->VolumeVector = glm::vec3(0.5f);
|
bounds->VolumeVector = glm::vec3(0.5f);
|
||||||
playerLight = CreateEntity(m_Player);
|
playerLight = CreateEntity(m_Player);
|
||||||
|
SetProperty(m_Player, "LightRight", playerLight);
|
||||||
transform = AddComponent<Components::Transform>(playerLight, "Transform");
|
transform = AddComponent<Components::Transform>(playerLight, "Transform");
|
||||||
transform->Position = glm::vec3(-1.5f, 0.25f, 2.5f);
|
transform->Position = glm::vec3(-1.5f, 0.25f, 2.5f);
|
||||||
pointLight = AddComponent<Components::PointLight>(playerLight, "PointLight");
|
pointLight = AddComponent<Components::PointLight>(playerLight, "PointLight");
|
||||||
|
|||||||
Binary file not shown.
@@ -7,7 +7,7 @@ Systems::LevelGenerationSystem::LevelGenerationSystem( World* world )
|
|||||||
|
|
||||||
velocity = 0;
|
velocity = 0;
|
||||||
startx = 0;
|
startx = 0;
|
||||||
startyz = glm::vec2(0, -1000);
|
startyz = glm::vec2(0, -1500);
|
||||||
spawnFrequency = 0.1f;
|
spawnFrequency = 0.1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,8 +31,9 @@ void Systems::LevelGenerationSystem::SpawnObstacle()
|
|||||||
|
|
||||||
sound->Loop = true;
|
sound->Loop = true;
|
||||||
sound->Gain = 1.f;
|
sound->Gain = 1.f;
|
||||||
sound->ReferenceDistance = 0.5f;
|
sound->MaxDistance = 2.f;
|
||||||
m_World->GetSystem<Systems::SoundSystem>("SoundSystem")->PlaySound(sound, "Sounds/hum.wav");
|
sound->ReferenceDistance = 1.f;
|
||||||
|
m_World->GetSystem<Systems::SoundSystem>("SoundSystem")->PlaySound(sound.get(), "Sounds/hum.wav");
|
||||||
|
|
||||||
if(typeRandom >= 0 && typeRandom < 1) // Mountain stuff :D
|
if(typeRandom >= 0 && typeRandom < 1) // Mountain stuff :D
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Systems::PlayerSystem::PlayerSystem( World* world ) : System(world)
|
Systems::PlayerSystem::PlayerSystem( World* world ) : System(world)
|
||||||
{
|
{
|
||||||
m_PlayerSpeed = 20;
|
m_PlayerSpeed = 35;
|
||||||
m_PlayerOriginalBounds = glm::vec3(0);
|
m_PlayerOriginalBounds = glm::vec3(0);
|
||||||
|
|
||||||
m_CameraOffset = glm::vec3(0.f, 5.f, 14.f);
|
m_CameraOffset = glm::vec3(0.f, 5.f, 14.f);
|
||||||
@@ -11,8 +11,8 @@ Systems::PlayerSystem::PlayerSystem( World* world ) : System(world)
|
|||||||
|
|
||||||
freecamEnabled = false;
|
freecamEnabled = false;
|
||||||
m_poweruptimeleft = 0;
|
m_poweruptimeleft = 0;
|
||||||
m_basespeed = 100.f;
|
m_basespeed = 125.f;
|
||||||
m_maxspeed = 100.f;
|
m_maxspeed = 125.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Systems::PlayerSystem::Update(double dt)
|
void Systems::PlayerSystem::Update(double dt)
|
||||||
@@ -29,18 +29,40 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
if (input == nullptr)
|
if (input == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto collision = m_World->GetComponent<Components::Collision>(entity, "Collision");
|
|
||||||
|
|
||||||
auto name = m_World->GetProperty<std::string>(entity, "Name");
|
auto name = m_World->GetProperty<std::string>(entity, "Name");
|
||||||
if(collision != nullptr)
|
|
||||||
|
if (name == "Sun") {
|
||||||
|
auto light = m_World->GetComponent<Components::PointLight>(entity, "PointLight");
|
||||||
|
|
||||||
|
if (input->KeyState[GLFW_KEY_KP_ADD])
|
||||||
{
|
{
|
||||||
for(auto ent : collision->CollidingEntities)
|
if (input->KeyState[GLFW_KEY_1]) {
|
||||||
{
|
light->constantAttenuation += 0.001;
|
||||||
if(m_World->GetProperty<std::string>(ent, "Name") == "Obstacle")
|
}
|
||||||
{
|
if (input->KeyState[GLFW_KEY_2]) {
|
||||||
m_World->RemoveEntity(entity);
|
light->linearAttenuation += 0.001;
|
||||||
|
}
|
||||||
|
if (input->KeyState[GLFW_KEY_3]) {
|
||||||
|
light->quadraticAttenuation += 0.00001;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (input->KeyState[GLFW_KEY_KP_SUBTRACT])
|
||||||
|
{
|
||||||
|
if (input->KeyState[GLFW_KEY_1]) {
|
||||||
|
light->constantAttenuation -= 0.001;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (input->KeyState[GLFW_KEY_2]) {
|
||||||
|
light->linearAttenuation -= 0.001;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (input->KeyState[GLFW_KEY_3]) {
|
||||||
|
light->quadraticAttenuation -= 0.00001;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DEBUG("Constant: %f\nLinear: %f\nQuadratic: %f", light->constantAttenuation, light->linearAttenuation, light->quadraticAttenuation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name == "Camera") {
|
if (name == "Camera") {
|
||||||
@@ -104,12 +126,15 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
m_PlayerOriginalBounds = bounds->VolumeVector;
|
m_PlayerOriginalBounds = bounds->VolumeVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto soundEmitter = m_World->GetComponent<Components::SoundEmitter>(entity, "SoundEmitter");
|
||||||
|
|
||||||
glm::vec3 Ship_Right = glm::vec3(glm::vec4(1, 0, 0, 0));
|
glm::vec3 Ship_Right = glm::vec3(glm::vec4(1, 0, 0, 0));
|
||||||
glm::vec3 Ship_Forward = glm::vec3(glm::vec4(0, 0, 1, 0));
|
glm::vec3 Ship_Forward = glm::vec3(glm::vec4(0, 0, 1, 0));
|
||||||
|
|
||||||
float TurnSpeed = 1.0f;
|
float TurnSpeed = 1.0f;
|
||||||
glm::vec3 Euler = glm::degrees(glm::eulerAngles(transform->Orientation));
|
glm::vec3 Euler = glm::degrees(glm::eulerAngles(transform->Orientation));
|
||||||
|
|
||||||
|
// Controls
|
||||||
if(input->KeyState[GLFW_KEY_LEFT]) {
|
if(input->KeyState[GLFW_KEY_LEFT]) {
|
||||||
transform->Position -= Ship_Right * (float)dt * (m_PlayerSpeed + Euler.z);
|
transform->Position -= Ship_Right * (float)dt * (m_PlayerSpeed + Euler.z);
|
||||||
|
|
||||||
@@ -159,16 +184,24 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
bounds->VolumeVector.x = m_PlayerOriginalBounds.x * glm::cos(glm::radians(Euler.z));
|
bounds->VolumeVector.x = m_PlayerOriginalBounds.x * glm::cos(glm::radians(Euler.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//powerup
|
|
||||||
auto cameraEntity = m_World->GetProperty<EntityID>(entity, "Camera");
|
auto cameraEntity = m_World->GetProperty<EntityID>(entity, "Camera");
|
||||||
auto cameracamera = m_World->GetComponent<Components::Camera>(cameraEntity, "Camera");
|
auto cameracamera = m_World->GetComponent<Components::Camera>(cameraEntity, "Camera");
|
||||||
cameracamera->FOV = glm::radians(20.f + transform->Velocity.z/3 );
|
cameracamera->FOV = glm::radians(45.f + transform->Velocity.z/3.f );
|
||||||
|
|
||||||
auto collisionComponent = m_World->GetComponent<Components::Collision>(entity, "Collision");
|
auto collision = m_World->GetComponent<Components::Collision>(entity, "Collision");
|
||||||
for(auto ent : collisionComponent->CollidingEntities)
|
if(collision != nullptr)
|
||||||
|
{
|
||||||
|
// Obstacle collision
|
||||||
|
for(auto ent : collision->CollidingEntities)
|
||||||
|
{
|
||||||
|
if(m_World->GetProperty<std::string>(ent, "Name") == "Obstacle")
|
||||||
|
{
|
||||||
|
m_World->RemoveEntity(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//powerup
|
||||||
|
for(auto ent : collision->CollidingEntities)
|
||||||
{
|
{
|
||||||
std::string name = m_World->GetProperty<std::string>(ent, "Name");
|
std::string name = m_World->GetProperty<std::string>(ent, "Name");
|
||||||
if(name == "PowerUp")
|
if(name == "PowerUp")
|
||||||
@@ -177,12 +210,15 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
m_maxspeed = powerupComp->Speed;
|
m_maxspeed = powerupComp->Speed;
|
||||||
m_poweruptimeleft = 5.f;
|
m_poweruptimeleft = 5.f;
|
||||||
m_World->RemoveEntity(ent);
|
m_World->RemoveEntity(ent);
|
||||||
|
SetPlayerLightColor(entity, glm::vec3(0.0, 1.0, 0.0));
|
||||||
|
auto soundSystem = m_World->GetSystem<Systems::SoundSystem>("SoundSystem");
|
||||||
|
soundSystem->PlaySound(soundEmitter, "Sounds/boom.wav");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(m_poweruptimeleft <= 0)
|
if(m_poweruptimeleft <= 0)
|
||||||
{
|
{
|
||||||
m_maxspeed = m_basespeed;
|
m_maxspeed = m_basespeed;
|
||||||
|
SetPlayerLightColor(entity, glm::vec3(0.05f, 0.36f, 1.f));
|
||||||
}
|
}
|
||||||
if(transform->Velocity.z < m_maxspeed)
|
if(transform->Velocity.z < m_maxspeed)
|
||||||
{
|
{
|
||||||
@@ -196,8 +232,7 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
if(transform->Velocity.z <= m_maxspeed)
|
if(transform->Velocity.z <= m_maxspeed)
|
||||||
transform->Velocity.z = m_maxspeed;
|
transform->Velocity.z = m_maxspeed;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update camera
|
// Update camera
|
||||||
if(! freecamEnabled)
|
if(! freecamEnabled)
|
||||||
@@ -210,6 +245,32 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update ground
|
||||||
|
auto groundEntity = m_World->GetProperty<EntityID>(entity, "Ground");
|
||||||
|
if (m_World->ValidEntity(groundEntity)) {
|
||||||
|
auto groundTransform = m_World->GetComponent<Components::Transform>(groundEntity, "Transform");
|
||||||
|
groundTransform->Position.x = transform->Position.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update Sun
|
||||||
|
auto sunEntity = m_World->GetProperty<EntityID>(entity, "Sun");
|
||||||
|
if (m_World->ValidEntity(sunEntity)) {
|
||||||
|
auto sunTransform = m_World->GetComponent<Components::Transform>(sunEntity, "Transform");
|
||||||
|
sunTransform->Position.x = transform->Position.x;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Systems::PlayerSystem::SetPlayerLightColor(EntityID player, glm::vec3 color)
|
||||||
|
{
|
||||||
|
auto light1 = m_World->GetProperty<EntityID>(player, "LightLeft");
|
||||||
|
auto light2 = m_World->GetProperty<EntityID>(player, "LightRight");
|
||||||
|
|
||||||
|
auto lightComponent1 = m_World->GetComponent<Components::PointLight>(light1, "PointLight");
|
||||||
|
auto lightComponent2 = m_World->GetComponent<Components::PointLight>(light2, "PointLight");
|
||||||
|
|
||||||
|
lightComponent1->Diffuse = color;
|
||||||
|
lightComponent2->Diffuse = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,15 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
|
#include "Systems/SoundSystem.h"
|
||||||
#include "Components/Transform.h"
|
#include "Components/Transform.h"
|
||||||
#include "Components/Input.h"
|
#include "Components/Input.h"
|
||||||
#include "Components/Collision.h"
|
#include "Components/Collision.h"
|
||||||
#include "Components/Camera.h"
|
#include "Components/Camera.h"
|
||||||
#include "Components/Bounds.h"
|
#include "Components/Bounds.h"
|
||||||
#include "Components/PowerUp.h"
|
#include "Components/PowerUp.h"
|
||||||
|
#include "Components/PointLight.h"
|
||||||
|
#include "Components/SoundEmitter.h"
|
||||||
|
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|
||||||
@@ -39,6 +42,9 @@ namespace Systems
|
|||||||
float m_maxspeed;
|
float m_maxspeed;
|
||||||
|
|
||||||
float m_poweruptimeleft;
|
float m_poweruptimeleft;
|
||||||
|
|
||||||
|
void SetPlayerLightColor(EntityID player, glm::vec3 color);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public:
|
|||||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||||
void OnComponentCreated(std::string type, std::shared_ptr<Component> component) override;
|
void OnComponentCreated(std::string type, std::shared_ptr<Component> component) override;
|
||||||
void OnComponentRemoved(std::string type, Component* component) override;
|
void OnComponentRemoved(std::string type, Component* component) override;
|
||||||
void PlaySound(std::shared_ptr<Components::SoundEmitter> emitter, std::string path); // Use if you want to play a temporary .wav file not from component
|
void PlaySound(Components::SoundEmitter* emitter, std::string path); // Use if you want to play a temporary .wav file not from component
|
||||||
void PlaySound(std::shared_ptr<Components::SoundEmitter> emitter); // Use if you want to play .wav file from component // imon no hate plx T.T
|
void PlaySound(std::shared_ptr<Components::SoundEmitter> emitter); // Use if you want to play .wav file from component // imon no hate plx T.T
|
||||||
void StopSound(std::shared_ptr<Components::SoundEmitter> emitter);
|
void StopSound(std::shared_ptr<Components::SoundEmitter> emitter);
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ Systems::SoundSystem::SoundSystem(World* world)
|
|||||||
alGetError();
|
alGetError();
|
||||||
|
|
||||||
alSpeedOfSound(340.29f); // Speed of sound
|
alSpeedOfSound(340.29f); // Speed of sound
|
||||||
alDistanceModel(AL_INVERSE_DISTANCE);
|
alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Systems::SoundSystem::Update(double dt)
|
void Systems::SoundSystem::Update(double dt)
|
||||||
@@ -75,15 +75,15 @@ void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID par
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Systems::SoundSystem::PlaySound(std::shared_ptr<Components::SoundEmitter> emitter, std::string fileName)
|
void Systems::SoundSystem::PlaySound(Components::SoundEmitter* emitter, std::string fileName)
|
||||||
{
|
{
|
||||||
if (m_Sources.find(emitter.get()) == m_Sources.end())
|
if (m_Sources.find(emitter) == m_Sources.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ALuint buffer = LoadFile(fileName);
|
ALuint buffer = LoadFile(fileName);
|
||||||
ALuint source = m_Sources[emitter.get()];
|
ALuint source = m_Sources[emitter];
|
||||||
alSourcei(source, AL_BUFFER, buffer);
|
alSourcei(source, AL_BUFFER, buffer);
|
||||||
alSourcePlay(m_Sources[emitter.get()]);
|
alSourcePlay(m_Sources[emitter]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Systems::SoundSystem::PlaySound(std::shared_ptr<Components::SoundEmitter> emitter)
|
void Systems::SoundSystem::PlaySound(std::shared_ptr<Components::SoundEmitter> emitter)
|
||||||
|
|||||||
Reference in New Issue
Block a user