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.


Messages - The Strangled Bear

Pages: [1]
1
Graphics / Create rectangle from two points
« on: November 17, 2013, 05:07:33 am »
Hi.
I can't seem to create a RectangleShape using simply two points to define it. I can define one point as it's position, (thereby defining it's top left corner) but that only gets me halfway.

Specifically I am trying to implement a drag box for a simple RTS game, so it would be very convenient to create the box from just two mouse positions (the inital mouse position, and the position where the mouse is currently), which I already have variables for.

2
We are on a game project and we are trying to figure out how to check if a vertex line collides with a sprite.

The vertex is supposed to go from the player position to a position determined by mouse (this part is all done), and then check if certains object collides with the line (this is where we get stuck). We would show some source code, but we basically don't have any code to show, since we don't really know how to approach this.
Any help would be apprechiated!

3
I have decided to go for a different solution all together. The sound manager will now be responsible for loading and playing of sounds. Therefore I won't need to pass data around between the manager and the main code, all I need is to call a simple function that plays the sound I want to play.

Thanks for your support, but I will work around it.

4
Thank you for your help so far, the code was certainly interesting, but it doesn't solve my issue. My problem is most likley due to memory loss while transferring the buffer from my manager class to my main loop.
If I do all the steps in one place it works.

5
I can't find the source code for the example in my SFML folder, is it not supposed to be there? Anyhow, the .exe won't launch because of a missing .dll, but my code does not have this problem.

6
Good tip, but it doesn't solve my problem. I still have the same problem. I realize know that using a reference like this won't work, as the SoundBuffer will fall out of scope before it's used. But neither passing the buffer as a reference, nor passing the actual data, will make a sound anyway  :o

7
You should provide a minimal and complete example that reproduces the problem, so we can tell you what you're doing wrong.

My guess is this:
the Manager class contains a simple getBuffer() function that I use to return the SoundBuffer instance

Are you passing it as a copy, reference or smart pointer?
I tried both passing it as a reference and a copy. I started out with a reference, but then tried passing the whole thing, to be sure I wasn't some syntax thng wrong. At least one of them should have worked.

SoundManager:
Code: [Select]
void Manager::IntSounds()
{
buffer.loadFromFile("myfilename.ogg");

}
...

sf::SoundBuffer& Manager::getBuffer()
{

return buffer;
}
Th sound is loaded to main and played just before the game loop starts:
Code: [Select]
       Sound sound;
SoundBuffer buffer = manager.getBuffer();
sound.setBuffer(buffer);
        sound.play();
As long as I don't destroy the Manager instance before I call manager.getBuffer() this should, no?

8
Hi, I am new with audio programming and I am making a simple class for handling sounds in a game I'm working on. The purpose of this class is to load all the sounds needed into sf::SoundBuffer instances and feed this information to the actual sf::Sound instances that will be played in the gamestate.

My simple prototype works like this:
A SoundBuffer is created in my Manager class, the Manager class contains a simple getBuffer() function that I use to return the SoundBuffer instance to the game loop. Once it's there I simply feed the information to the relevant sf::Sound and play it.

I am pretty sure it's some technicality about the SoundBuffer class I am missing, but if that's not the case I could send you my source code.

Pages: [1]