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 Terminator

Pages: 1 [2] 3 4 ... 15
16
Got it working. Thanks a lot for the detailed explanation G, I was just confused on how to exactly construct the tile's FloatRect, but you cleared that up.

Thanks again!

17
I did exactly that, but it was not accurate and often didn't work. I'm not using a sprite for the tiles, since it's a vertex array tilemap.

18
Would I have to create four FloatRects? One for each vertice?

19
Oh I see. So when checking if the player's position is contained within a tile, check all the four vertices of the square?

20
Here's the methods where I check if the next position requested by the user is feasible. I was just trying to get it working so please excuse the dirty code:

bool SPlayer::nextPosValid(const sf::Vector2f& offset)
    {
        sf::Vector2f offsettedPos(m_sprite.getPosition().x + offset.x, m_sprite.getPosition().y + offset.y);

        //The bounding rectangle of the future player
        sf::FloatRect rect(offsettedPos,
                           sf::Vector2f(m_sprite.getGlobalBounds().width, m_sprite.getGlobalBounds().height));

        if (SSceneManager::getWorld().getCurrentCell()->getTileMap().check(offsettedPos, 2))
        {
            Ataxia::TileMap::Tile tempTile = SSceneManager::getWorld().getCurrentCell()->getTileMap().check2(rect, 2);

            if (rect.intersects(tempTile.bounds))
                return false;
        }

        return true;
    }

bool check(const sf::Vector2f& pos, int tileType)
        {
            for (auto& iter : m_tiles)
            {
                if (iter.tileType == tileType)
                {
                    if (iter.bounds.contains(pos))
                        return true;
                }
            }

            return false;
        }

        Tile& check2(const sf::FloatRect& rect, int tileType)
        {
            for (auto& iter : m_tiles)
            {
                if (iter.tileType == tileType)
                {
                    if (iter.bounds.intersects(rect))
                        return iter;
                }
            }
        }

Thanks!

21
Hi there,

I've utilized the vertex array tilemap, but I'm having issues with collision. My current system is really hit and miss and often doesn't work at all, and it depends on checking for bounding-box intersection between the tiles (in the form of FloatRects). Is there a better way to more accurately measure collision?

Thanks

22
Window / Events outside loop
« on: April 18, 2014, 08:36:17 pm »
Is OpenGL ever going to be multithreaded? Or is it sort of out of its scope?

23
Network / [Solved] Opening Website File to show in Window
« on: April 16, 2014, 08:01:02 pm »
Have a look at Awesomium. It sounds like exactly what you need. It's a fairly good library.

24


Yep would be a good idea to pick easy to remember and common names that don't need changing. XD

....?

25
I did several optimizations in the rendering and updating of the tiles, and I brought my fps back up to about ~130 fps. I think I will stick with the approach I have because 3000 tiles will be like the max amount I will be drawing.

Thanks for all the responses!

26
How do you pack the textures into one image in the tutorials Laurent?

27
Thanks for the response. Do you think you could give me an example of using the vertex array the way that I want it? I looked at the vertex array tutorial but I'm sort of confused on how the vertex array actually gets the pixel data and how to draw it.

Thanks again!

28
Hi there,

I have a couple questions on how to approach an issue I'm having. I have a tilemap that I just designed that draws ~3000 tiles, but slows to a crawl (~35 fps from 200 fps earlier). What I'm doing right now is having a "tile" be represented as a drawable sprite, and in its constructor the sprite is given a pointer to a texture in my resource manager. Because of this, only 1 texture has to be created per type of tile.

Now sf::Sprite is a very lightweight class, but I'm pretty confused as to why it's really bringing down fps, especially since there's an extremely low number of sf::Texture 's being used (Exactly 1, lol).

This brings me to my first question: why is this approach slowing down my program so significantly?

Second question: Would a sf::VertexArray be a much better approach? I'm pretty confused on how to define the vertices because my tile images are not packed into one sprite sheet, they're individual .png files.

Thanks!

29
SFML projects / 3DEE
« on: April 02, 2014, 10:44:26 pm »
I've been waiting for something like this for a long time. Definitely will be using this in my later games, it looks amazing!

30
General discussions / Future release of SFML 2.2 (feedback needed)
« on: April 01, 2014, 02:12:35 pm »
I definitely agree with the technology preview of iOS and Android. I think that any API breaks should wait until SFML 3.

Pages: 1 [2] 3 4 ... 15
anything