Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Zephilinox

Pages: [1]
1
Audio / When the first sound ends, so does the second.
« on: December 13, 2013, 02:58:36 pm »
Are there any obvious mistakes I'm making here?

Noteworthy: m_Sounds and m_SoundBuffer are static private member variables. m_Sounds is a vector and m_SoundBuffer is a map.

void ResourceManager::Update()
{
    for (unsigned int i = 0; i < m_Sounds.size(); ++i)
    {
        std::cout << "Sound " << i << " = " << m_Sounds[i].getPlayingOffset().asSeconds() << "\n";

        if (m_Sounds[i].getStatus() == sf::Sound::Stopped)
        {
            std::cout << i+1 << " / " << m_Sounds.size() << " was Killed\n";
            m_Sounds.erase(m_Sounds.begin() + i);
            continue;
        }
    }
}

sf::SoundBuffer& ResourceManager::soundBuffer(std::string fileName)
{
        std::map<std::string, sf::SoundBuffer>::iterator it = m_SoundBuffers.find(fileName);

        if (it == m_SoundBuffers.end()) //not found
        {
                sf::SoundBuffer sb;
                assert(sb.loadFromFile("audio/" + fileName + ".wav"));
                std::cout << "SoundBuffer Loaded: " << "audio/" << fileName << ".wav\n";
                m_SoundBuffers.insert(std::make_pair(fileName, sb));
                return m_SoundBuffers.find(fileName)->second;
        }

        return it->second;
}

void ResourceManager::sound(std::string fileName)
{
    sf::Sound s(this->soundBuffer(fileName));
    m_Sounds.push_back(s);
    m_Sounds.back().play();
}
 

case sf::Event::MouseButtonPressed:
{
    ResMan.sound("fireworks");
    break;
}
 



only when I close the RenderWindow do I get the segmentation fault


2
I've had issues using SFML's networking part of the library in the past and want to create a multiplayer game, are there any open-source games made with SFML that use the SFML networking library that I could take a look at?

3
Graphics / SFML 2, window styles gone?
« on: September 08, 2012, 01:48:18 pm »
I don't want my window to be resized, but there is no sf::Style::xyz, they are all gone. I can't find any documentation on it either, have they been removed or..?

4
Graphics / Crashes on RenderWindow
« on: August 09, 2012, 05:28:43 pm »
I've tried 're-installing' SFML2 without any luck, it was working for me before. however when cmake failed to compile SFML2 this started happening, I removed SFML completely from the MinGW folder and the folder I used to use for linking, downloaded sfml2-rc, placed it in a folder outside of MinGW, linked it normally, added the .DLL's and this is still happening.

Windows Crash Report:

Problem Event Name:     APPCRASH
  Application Name:     SFML Test Dependency Project.exe
  Application Version:  0.0.0.0
  Application Timestamp:        5023d0a5
  Fault Module Name:    sfml-window-d-2.dll
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp:       4f7e379d
  Exception Code:       c0000005
  Exception Offset:     00002b85
  OS Version:   6.1.7600.2.0.0.256.1
  Locale ID:    2057
  Additional Information 1:     0a9e
  Additional Information 2:     0a9e372d3b4ad19135b953a78882e789
  Additional Information 3:     0a9e
  Additional Information 4:     0a9e372d3b4ad19135b953a78882e789



Ideas?

Oh, and the examples work fine.

5
Network / Help with sending/receiving packets on LAN/WAN
« on: August 05, 2012, 01:58:28 pm »
When I run this code on myself, it works fine, but when I run it on two computers and try to connect to each other, both can send but only one can receive, what's wrong? it's not a problem with the router/firewalls, I've set it up properly and it shouldn't affect the LAN anyway.

sf::IpAddress ip;
unsigned short int port = 2222;
void client()
{
    sf::TcpSocket clientSocket;
    sf::Packet clientPacket;

    clientSocket.connect(ip, port);

    while (true)
    {
        std::string send;
        std::getline(std::cin, send);
        clientPacket << send;
        clientSocket.send(clientPacket);
        clientPacket.clear();
    }
}

void server()
{
    sf::TcpListener listener;
    sf::TcpSocket serverSocket;
    sf::Packet serverPacket;

    listener.listen(port);
    listener.accept(serverSocket);
    while (true)
    {
        std::string receive;
        serverSocket.receive(serverPacket);
        serverPacket >> receive;
        std::cout << receive << "[received]" << std::endl;
        serverPacket.clear();
    }
}

int main()
{
    std::cin >> ip;
    std::cin.clear();
    std::cin.ignore();
    sf::Thread cThread(client);
    sf::Thread sThread(server);
    cThread.launch();
    sThread.launch();
}
 

6
Graphics / Key Released?
« on: March 15, 2012, 10:21:04 pm »
I'm trying to get a functioning ping pong game working in sfml2, despite reading and re-reading the documentation, I can't figure out how to find if a key was released, so that I can stop individual paddles from moving.

Code: [Select]
switch (Event.type)
{
case sf::Event::Closed:
Window.close();
break;
            case sf::Event::MouseButtonPressed:
                Ball.setPosition(sf::Mouse::getPosition(Window).x - Texture1.getWidth() / 2, sf::Mouse::getPosition(Window).y  - Texture1.getHeight() / 2); // test, disable for release
                break;
            case sf::Event::KeyPressed:
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))
                    {IsMovingUp1 = true; IsMoving1 = true;}
                else if (sf::Keyboard::isKeyPressed(sf::Keyboard::S))
                    {IsMovingUp1 = false; IsMoving1 = true;}

                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
                    {IsMovingUp2 = true; IsMoving2 = true;}
                else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
                    {IsMovingUp2 = false; IsMoving2 = true;}
                break;
            case sf::Event::KeyReleased: // need to figure out a way of knowing which key it was so I don't stop both paddles
                IsMoving1 = false;
                IsMoving2 = false;
                break;
default:
break;
}

7
General / Can't compile code, 'class sf::X' has no member named 'Y'
« on: March 12, 2012, 11:16:34 pm »
I've recently moved to ubuntu from windows, in windows I could get SFML working but I can't seem to get it working in ubuntu, I'm pretty sure I made it [sfml 2.0] properly so it must be a linker/compiler problem.

I'm using codeblocks.

I'm trying to compile this:

Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
sf::RenderWindow Window(sf::VideoMode(800, 600, 32), "SFML Sample Application");

while (Window.IsOpen())
{
sf::Event Event;
while (Window.PollEvent(Event))
{
switch (Event.Type)
{
case sf::Event::Closed:
Window.Close();
break;
default:
break;
}
}

Window.Clear(sf::Color(0, 255, 255));
Window.Display();
}

return 0;
}



with static libraries, in settings>compiler>global compiler>search directories>compiler I have "/home/z/Programming/sfml2/include" and in settings>compiler>global compiler>search directories>linker I have "/home/z/Programming/sfml2/lib", in settings>compiler>global compiler>compiler settings>#defines I have "SFML_STATIC".

then in my project build options, I have this in debug>linker settings>link libraries

Code: [Select]

sfml-graphics-s-d
sfml-audio-s-d
sfml-window-s-d
sfml-network-s-d
sfml-system-s-d


and I have this in release>linker settings>link libraries

Code: [Select]

sfml-graphics-s
sfml-audio-s
sfml-window-s
sfml-network-s
sfml-system-s


Am I missing something? these are the errors I'm getting:

Code: [Select]

/media/Storage/Programming/C++/Real Projects/SFML/SFML START 1[LINUX]/main.cpp||In function ‘int main()’:|
/media/Storage/Programming/C++/Real Projects/SFML/SFML START 1[LINUX]/main.cpp|7|error: ‘class sf::RenderWindow’ has no member named ‘IsOpen’|
/media/Storage/Programming/C++/Real Projects/SFML/SFML START 1[LINUX]/main.cpp|10|error: ‘class sf::RenderWindow’ has no member named ‘PollEvent’|
/media/Storage/Programming/C++/Real Projects/SFML/SFML START 1[LINUX]/main.cpp|12|error: ‘class sf::Event’ has no member named ‘Type’|
/media/Storage/Programming/C++/Real Projects/SFML/SFML START 1[LINUX]/main.cpp|15|error: ‘class sf::RenderWindow’ has no member named ‘Close’|
/media/Storage/Programming/C++/Real Projects/SFML/SFML START 1[LINUX]/main.cpp|22|error: ‘class sf::RenderWindow’ has no member named ‘Clear’|
/media/Storage/Programming/C++/Real Projects/SFML/SFML START 1[LINUX]/main.cpp|23|error: ‘class sf::RenderWindow’ has no member named ‘Display’|
||=== Build finished: 6 errors, 0 warnings ===|

Pages: [1]
anything