Merge branch 'master' of https://git.epicsparrow.com/epicsparrow/SparrowEngine
This commit is contained in:
commit
82c6b29b4e
33
src/scene/musicnode.cpp
Normal file
33
src/scene/musicnode.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "musicnode.h"
|
||||
|
||||
MusicNode::MusicNode(std::string musicFileName):
|
||||
m_music_file(musicFileName)
|
||||
{
|
||||
}
|
||||
|
||||
void MusicNode::init(){
|
||||
m_valid = m_music.openFromFile(m_music_file);
|
||||
}
|
||||
|
||||
void MusicNode::play()
|
||||
{
|
||||
if (m_valid)
|
||||
m_music.play();
|
||||
}
|
||||
|
||||
void MusicNode::pause()
|
||||
{
|
||||
if(m_valid)
|
||||
m_music.pause();
|
||||
}
|
||||
|
||||
void MusicNode::stop()
|
||||
{
|
||||
if(m_valid)
|
||||
m_music.stop();
|
||||
}
|
||||
|
||||
void MusicNode::setPlayingOffset(int offset)
|
||||
{
|
||||
m_music.setPlayingOffset(sf::seconds(offset));
|
||||
}
|
21
src/scene/musicnode.h
Normal file
21
src/scene/musicnode.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef MUSICNODE_H
|
||||
#define MUSICNODE_H
|
||||
|
||||
#include "scenenode.h"
|
||||
#include "SFML/Audio.hpp"
|
||||
|
||||
class MusicNode : public SceneNode
|
||||
{
|
||||
sf::Music m_music;
|
||||
std::string m_music_file;
|
||||
bool m_valid;
|
||||
public:
|
||||
MusicNode(std::string musicFileName);
|
||||
void init();
|
||||
void play();
|
||||
void pause();
|
||||
void stop();
|
||||
void setPlayingOffset(int offset);
|
||||
};
|
||||
|
||||
#endif // MUSICNODE_H
|
@ -11,6 +11,7 @@
|
||||
#include "scenetree.h"
|
||||
#include "lightnode.h"
|
||||
#include <SFML/System.hpp>
|
||||
#include <SFML/Audio.hpp>
|
||||
|
||||
#define DEFAULT_ROTATION_SPEED 0.001f
|
||||
#define TRIGGER_VALUE 15
|
||||
@ -297,6 +298,10 @@ void PlayerCharacterNode::update()
|
||||
m_rigidBody->setLinearVelocity(newVelocity);
|
||||
}
|
||||
m_playerLightNode->update();
|
||||
glm::vec3 p = this->getEyePosition();
|
||||
sf::Listener::setPosition(p.x,p.y,p.z);
|
||||
glm::vec3 d = getDirection();
|
||||
sf::Listener::setDirection(d.x,d.y,d.z);
|
||||
}
|
||||
|
||||
void PlayerCharacterNode::toggleNoClip()
|
||||
|
47
src/scene/soundnode.cpp
Normal file
47
src/scene/soundnode.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
#include "soundnode.h"
|
||||
#include "resourcemanager.h"
|
||||
|
||||
SoundNode::SoundNode(std::string soundFileName):
|
||||
m_sound_file(soundFileName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SoundNode::init()
|
||||
{
|
||||
if ((m_valid = RESOURCE_CHECK(sf::SoundBuffer,m_sound_file)))
|
||||
m_sound.setBuffer(*RESOURCE_GET(sf::SoundBuffer, m_sound_file));
|
||||
else{
|
||||
sf::SoundBuffer* buffer;
|
||||
m_valid = buffer->loadFromFile(m_sound_file);
|
||||
if(m_valid){
|
||||
RESOURCE_ADD(buffer,sf::SoundBuffer,m_sound_file);
|
||||
m_sound.setBuffer(*buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SoundNode::play()
|
||||
{
|
||||
if (m_valid)
|
||||
m_sound.play();
|
||||
}
|
||||
|
||||
void SoundNode::pause()
|
||||
{
|
||||
if(m_valid)
|
||||
m_sound.pause();
|
||||
}
|
||||
|
||||
void SoundNode::stop()
|
||||
{
|
||||
if(m_valid)
|
||||
m_sound.stop();
|
||||
}
|
||||
|
||||
void SoundNode::setPosition(glm::vec3 pos,bool relative)
|
||||
{
|
||||
m_sound.setPosition(pos.x,pos.y,pos.z);
|
||||
m_sound.setRelativeToListener(relative);
|
||||
}
|
||||
|
22
src/scene/soundnode.h
Normal file
22
src/scene/soundnode.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef SOUNDNODE_H
|
||||
#define SOUNDNODE_H
|
||||
|
||||
#include "scene/scenenode.h"
|
||||
#include "SFML/Audio.hpp"
|
||||
#include "glm/vec3.hpp"
|
||||
|
||||
class SoundNode : public SceneNode
|
||||
{
|
||||
sf::Sound m_sound;
|
||||
std::string m_sound_file;
|
||||
bool m_valid;
|
||||
public:
|
||||
SoundNode(std::string soundFileName);
|
||||
void init();
|
||||
void play();
|
||||
void pause();
|
||||
void stop();
|
||||
void setPosition(glm::vec3 pos, bool relative);
|
||||
};
|
||||
|
||||
#endif // SOUNDNODE_H
|
@ -85,6 +85,7 @@ public:
|
||||
|
||||
unsigned int getIndex(){return m_buffer->getIndex();}
|
||||
ShellBuffer* getBuffer(){return m_buffer;}
|
||||
ScriptNode* getScript(){return m_script;}
|
||||
|
||||
void setInputs(int cursor_left, int cursor_right, int history_up, int history_down);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user