nothing works

This commit is contained in:
Stiffly
2015-09-14 17:07:25 +02:00
parent 760574f454
commit ff00e2bf9c
3 changed files with 164 additions and 24 deletions
+5 -2
View File
@@ -66,15 +66,18 @@ public:
m_World = std::make_shared<World>(m_EventBroker);
//TODO: Move this out of engine.h
m_World->ComponentFactory.Register<Components::Transform>();
m_World->SystemFactory.Register<Systems::TransformSystem>(
[this]() { return new Systems::TransformSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::TransformSystem>();
m_World->AddSystem<Systems::Sound>();
m_World->ComponentFactory.Register<Components::Model>();
m_World->ComponentFactory.Register<Components::Template>();
m_World->Initialize();
m_World->AddSystem<Systems::Sound>();
m_World->SystemFactory.Register<Systems::Sound>([this]() { return new Systems::Sound(m_World.get(), m_EventBroker); });
m_World->ComponentFactory.Register<Components::Sprite>();
+33 -8
View File
@@ -5,13 +5,12 @@
#ifndef DAYDREAM_SOUND_H
#define DAYDREAM_SOUND_H
#include "../../deps/include/AL/al.h"
#include "../../deps/include/AL/alc.h"
#include "Core/EKeyDown.h"
#include "Core/EventBroker.h"
#include "AL/al.h"
#include "AL/alc.h"
#include "Core/System.h"
#include "Core/World.h"
#include "Core/EKeyDown.h"
#include "Core/EventBroker.h"
namespace dd
@@ -21,16 +20,42 @@ namespace Systems
class Sound : public System {
public:
Sound(World *world, std::shared_ptr<dd::EventBroker> eventBroker)
: System(world, eventBroker) { EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &Sound::OnKeyDown); }
: System(world, eventBroker) { }
void Init();
//void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
void Update(double dt) override;
//void OnComponentCreated(std::string type, std::shared_ptr<Component> component) override;
//void OnComponentRemoved(std::string type, Component* component) override;
//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 StopSound(std::shared_ptr<Components::SoundEmitter> emitter);
void Initialize() override;
private:
dd::EventRelay<Sound, dd::Events::KeyDown> m_EKeyDown;
ALuint LoadFile(std::string fileName);
ALuint CreateSource();
//File-info
char m_type[4];
unsigned long m_size, m_chunkSize;
short m_formatType, m_channels;
unsigned long m_sampleRate, m_avgBytesPerSec;
short m_bytesPerSample, m_bitsPerSample;
unsigned long m_dataSize;
std::map<Component*, ALuint> m_Sources;
std::map<std::string, ALuint> m_BufferCache;
bool OnKeyDown(const dd::Events::KeyDown &event);
void HelloWorld();
//Temp
ALuint m_source;
};
}