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 - Antonio9227

Pages: 1 [2]
16
Graphics / Re: Crash when draw() is used
« on: February 02, 2015, 10:51:31 pm »
I had some spare time today so I read my code. I found my mistake and it had nothing to do with SFML. I had a function to load the level and that function did not worked properly. At a point my function was accessing items from an array (that was holding my tile information), my index was out of bound and I think it somehow managed to modify some bytes of the place where my vertex array was stored in the memory. Is this even possible?
Anyways, this is the only explanation I could come up with, thanks anyways for trying to help.

17
Graphics / [SOLVED] Crash when draw() is used
« on: January 28, 2015, 08:49:01 am »
Hello, I am a object oriented programming newbie and I've encountered a weird problem while trying to make a level class. My application crashes every time I try to draw a level object, here is the code I'm using:
virtual void draw(sf::RenderTarget &target,sf::RenderStates states) const
{
    states.transform *=getTransform();
    states.texture = m_texture;
    target.draw(m_vertices,states); //Crashes here
}
 

During debug I receive an SIGSEGV segmentation fault signal when that specific line is executed. If I disable it the program runs as expected. m_vertices is a sf::VertexArray and m_texture is a sf::Texture pointer.
Also it doesn't matter if I constructed a mesh inside the vertex array or not, it still crashes. I've used the exact same piece of code for another class and it works just fine.

I really don't know what the problem could be and some help would be appreciated. 
Thanks in advance, regards Antonio.

18
Audio / Re: Two sound buffer into one.
« on: February 05, 2014, 12:20:26 pm »
As FRex said, it is pretty easy to do this when your sounds have the same sample rate and channels count.
Here is a sample code I just wrote, if you need to do the action multiple times I suggest making a function out of it.
    sf::SoundBuffer sb1;
    sf::SoundBuffer sb2;
    sf::SoundBuffer sb3;

//Declare a array of shorts to store all the samples from both buffers
//We use dynamic allocation to give it the proper size to hold the data
    short *samples= new short[sb1.getSampleCount() + sb2.getSampleCount()];

//Copy all the samples of sb1 into our array
    for(int i=0; i<sb1.getSampleCount(); i++)
        samples[i]=sb1.getSamples()[i];

//Copy all the samples of sb2 into our array, in addition to the samples from sb1
    for(int i=0; i<sb2.getSampleCount; i++)
        samples[i+sb1.getSampleCount()]=sb2.getSamples()[i];

//Finally load sb3 from samples
//  sb3.loadFromSamples( <samples> , <how many samples to load> , <how many channels our sound has> , <our sampleRate>)
    sb3.loadFromSamples(samples,sb1.getSampleCount() + sb2.getSampleCount(),sb1.getChannelCount(),sb1.getSampleRate());

//After using the array, free the memory
        delete [] samples;
*This will only work properly if the sounds have the same samplerate and channel count!

However, SFML does not support doing this directly :)

19
SFML projects / Re: My small 2D game creation software - [Game Inventor]
« on: January 20, 2014, 03:38:27 pm »
I have downloaded the application and the platform example and It's quite nice what you managed to do.
The Editor looks very intuitive and professional and the runtime runs smooth (at least for the project I tried).
It works just fine. Keep up the good work :D

20
Window / Keyboard question
« on: December 03, 2013, 03:55:44 pm »
Hello guys, I am still working on my first SFML game and I have another question for you today.This time I have a problem with the keyboard.

My code looks something like this:
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left) || sf::Keyboard::isKeyPressed(sf::Keyboard::A))
//Move Left
It works as supposed, the object moves to left, but it also works when I'm outside of the render window. For example if I leave the game open and go write some text somewhere, every time I use "ASDW" the object moves. It's like sensing the keys globally.

Well since I test if the key is pressed, this make total sense (the game sits back and tests if keys are pressed).

 Is there any better way of doing this?

21
Graphics / Re: View ports
« on: November 12, 2013, 04:48:49 pm »
Well it was... incredibly easy...  XD

Thanks mate.

22
Graphics / View ports
« on: November 12, 2013, 04:24:02 pm »
I am trying to add a minimap to my game. I already used views for moving cameras, but I can't figure out how to use viewports. I know what they are supposed to do, but I still can't figure it out.

Here is what I was trying to do. I have "view" which is what I'm using for the game and "minimap" which should be the minimap.
view.setViewport(sf::FloatRect(0,0,1,1));
sf::View minimap;
minimap.reset(sf::FloatRect(0,0,level.x*56,level.y*56));
minimap.setViewport(sf::FloatRect(0.75f, 0, 0.25f, 0.25f));
They are working separately, if I bind one of them to my window ( window.setView(view); ) it works, but I can't figure out how to display them both. I searched on google but I couldn't find anything usefull.

If you can help me, leave a reply below.

23
Graphics / Applying contextual settings at runtime
« on: October 13, 2013, 11:23:45 am »
I want to change the antialiasing level during runtime for a sf::RenderWindow.
How can I do it?

24
Graphics / Re: Check for sprite collision
« on: October 02, 2013, 04:07:30 pm »
Thanks for the fast reply :D

25
Graphics / [SOLVED]Check for sprite collision
« on: October 02, 2013, 03:51:29 pm »
Is there any way to check if 2 sprites are collided?

Pages: 1 [2]
anything