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

Pages: [1] 2 3 ... 5
1
do this

const sf::Texture& texture = *Game::texture;

2
General / Re: sf::Text::getLocalBounds causes segmentation fault?
« on: January 03, 2016, 01:07:16 am »
Building with visual studio and release libs results in the same crash but using the debug libs works fine.
The same can't be said for mingw though, both release and debug have the same issue.
I'm not sure what info from the visual studio debugger you want me to give you, gdb gave me more info than I got from vs.

I checked it on Win 10 64 bits with SFML 2.3 32bit and both (debug and realease) and VS 2015 (v140) are working fine.

3
SFML projects / Re: Zombie Shooter 2000
« on: January 02, 2016, 01:30:17 am »
I looked at your code a little.

In Entity.cpp - If you use something more than once, I think it's better to store it ( getGlobalBounds could do something extra each call )
        auto globalBounds = entSprite.getGlobalBounds();
        entSprite.setOrigin(globalBounds.width / 2, globalBounds.height / 2);

In textureManager.cpp
sf::Texture* textureManager::addTexture(const std::string &filepath, const std::string &name)
{
        sf::Texture* newTexture = getTexture(name);
        if( newTexture )
                return newTexture;

        newTexture = new sf::Texture;

        if(newTexture->loadFromFile(filepath)) // otherwise, load a new texture from desired path
        {
                s_allTextures[name] = std::make_shared<sf::Texture>(*newTexture); // and then add it to the map
                return newTexture;
        }

        std::cout << "Could not load " << filepath << std::endl;    // if it can't load, filepath didn't work
        return nullptr;
}

sf::Texture* textureManager::getTexture(const std::string &name)
{
        auto ret = m_allTextures.find(name);
        if( ret != m_allTextures.end() )
        {
                return ret->second;
        }

        return nullptr;
}

I didn't test it. I wrote getTexture more clear. Same with creating new Texture

Old
sf::Texture *newTexture = new sf::Texture;
newTexture = getTexture(name);

if (newTexture)       // check if getTexture doesnt return nullptr
        {
                return newTexture;    // if it does, return it
        }

newTexture = new sf::Texture;

if (newTexture->loadFromFile(filepath)) // otherwise, load a new texture from desired path
        {
                allTextures[name] = std::make_shared<sf::Texture>(*newTexture); // and then add it to the map
                return allTextures[name].get();
        }

std::cout << "Could not load " << filepath << std::endl;    // if it can't load, filepath didn't work
return nullptr;
 

Here - sf::Texture *newTexture = new sf::Texture; - you created a new texture and than ?
BUM - newTexture = getTexture(name); - you request a pointer to texture (old texture wasn't released)
and 7 lines under BAM - newTexture = new sf::Texture; again new texture ( this time is needed ). So you had mem leak.

In collision.cpp
sf::Vector2f clsn::handleCollision(sf::FloatRect &AABBFirst, sf::FloatRect &AABBSecond)   // A is object colliding. I.E, player and the wall
{
        sf::Vector2f ret(0, 0);
        sf::Vector2f centerA(AABBFirst.left + (AABBFirst.width / 2), AABBFirst.top + (AABBFirst.height / 2));
        sf::Vector2f centerB(AABBSecond.left + (AABBSecond.width / 2), AABBSecond.top + (AABBSecond.height / 2));

        sf::Vector2f distance(centerA - centerB);
        sf::Vector2f minDistance((AABBFirst.width / 2) + (AABBSecond.width / 2), (AABBFirst.height / 2) + (AABBSecond.height / 2));

        if (abs(distance.x) < minDistance.x && abs(distance.y) < minDistance.y)
        {
                ret = sf::Vector2f(distance.x > 0 ? minDistance.x - distance.x : -minDistance.x - distance.x,
                                                   distance.y > 0 ? minDistance.y - distance.y : -minDistance.y - distance.y);
        }

        return ret;
}

You could have just 1 return.

I don't have time for checking whole code. Keep going.

4
SFML projects / Re: Untitled (Zombienation) - 2D survival zombie shooter
« on: September 12, 2015, 06:39:44 pm »


Working veeeery slowly on this old project again. I had to rewrite whole code just cause I fucked up :D

5
SFML projects / Re: Untitled (Zombienation) - 2D survival zombie shooter
« on: February 08, 2015, 01:13:07 pm »
Hi my old frends!
Check out what I've done last weekend.


6
SFML projects / Re: SFML Light System - Let There Be Light
« on: June 03, 2014, 09:52:50 am »
std::vector<ltbl::ConvexHull* > test;

for(int i = 0; i < walls.size(); i ++)
    {
        test.push_back(new ltbl::ConvexHull() );
        test->loadShape("data/testShape.txt");
        test->calculateNormals();
        test->generateAABB();
        test->setWorldCenter(Vec2f(walls.getPosition().x + 32,720 - walls.getPosition().y + 32));
        ls.addConvexHull(test);
    }

You made some local variables and each loop pass alloc memory for new ConvexShape and leave in memory old.

7
SFML projects / Re: SFML Light System - Let There Be Light
« on: May 08, 2014, 11:23:03 pm »
        void LightSystem::RenderLights()
        {
                // So will switch to main render textures from SFML projection
                m_currentRenderTexture = cur_lightStatic;

                Vec2f viewCenter(m_viewAABB.GetCenter());
                Vec2f viewSize(m_viewAABB.GetDims());

                glDisable(GL_TEXTURE_2D);

                if(m_useBloom)
                {
                        // Clear the bloom texture
                        SwitchBloom();
                        glLoadIdentity();

            m_bloomTexture.clear(m_ambientColor);

            glColor4f(0.5f, 0.5f, 0.5f, 0.5f);

                        glBlendFunc(GL_ONE, GL_ZERO);

                        // Clear with quad, since glClear is not working for some reason... if results in very ugly artifacts
            /*glBegin(GL_QUADS);
                                glVertex2f(0.0f, 0.0f);
                                glVertex2f(viewSize.x, 0.0f);
                                glVertex2f(viewSize.x, viewSize.y);
                                glVertex2f(0.0f, viewSize.y);
                        glEnd();

            glColor4f(1.0f, 1.0f, 1.0f, 1.0f);*/

                }

#589 line

8
SFML projects / Re: SFML Light System - Let There Be Light
« on: April 26, 2014, 03:45:11 pm »
Light class is pure virtual so you only could use it as base class for your own light class. Emmisive is light for rendering a light with a shape of texture. I use only Point_Light class.

Your bug is strange. I did't occur this kind of glitches. You could try to rebuild your whole code ;) When I get back to home I'll upload my version of ltbl with my blend modes and changes.

9
SFML projects / Re: SFML Light System - Let There Be Light
« on: April 26, 2014, 02:58:58 pm »
There is function setAlwaysUpdate. At first you have to add light to light system and then setAlwaysUpdate.

Quote
lSystem.AddLight(player.getLight());
    player.getLight()->SetAlwaysUpdate(true);

10
SFML projects / Re: SFML Light System - Let There Be Light
« on: April 26, 2014, 02:26:54 pm »
I mean make quad with max int value. Could you post screen shot? Are you set alwaysUpdate to true?

11
SFML projects / Re: SFML Light System - Let There Be Light
« on: April 26, 2014, 11:21:56 am »
I'm creating light system by "create" function. I have some glitches when I was using only constructor.

Maybe large size (int_min, int_max) could solve your problem. I have bug in editor map. When I add new light i have to "reload" light system by setting view position to 0,0.

When I had only 1 (flashlight) I have ugly effect. No penumbra. I had at first add light and then I had to move it, that was only solve I know.

I have 0,0 x 10k,10k quad tree and all works fine.

12
SFML projects / Re: SFML Light System - Let There Be Light
« on: April 26, 2014, 01:45:04 am »
I think this is a quad tree bug. Try to set bigger quad or make size of quad to 0, 0. That's all that I could say without code.

13
SFML projects / Re: Zombienation - 2D survival zombie shooter
« on: April 25, 2014, 12:04:47 am »


larger version -> http://warsztat.gd/screens/afd094d8b5dfded81648a9cac872313b.png

Hah small update.
I added laser, walkman (if you find it you will be able to listen to your music (you have to put music in "walkman" dir)), and I started work at first part of map. I fixed some bugs like reloading empty magazines. I hope you like that ;)

I know walkman looks like magazine. ;)

14
SFML projects / Re: Space - Level Editor
« on: March 04, 2014, 07:27:47 am »
I think that writing map editor clearly in SFML is not good idea. Better use Qt or something else for GUI. It's harder on begin, but later you will see the difference.

15
SFML projects / Re: Zombination - 2D survival zombie shooter
« on: March 01, 2014, 09:32:04 pm »
I will be your rival instead in making a survival game hehe :)

You told that earlier ;) PM me with more info ;)


Pages: [1] 2 3 ... 5