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

Pages: [1]
General / Determining if player is on air/ground
« on: January 13, 2016, 04:06:17 pm »
I've implemented some gravity and collision in my 2d side-scroller/platformer game, but i needed to know if the player is currently grounded or mid-air. I really can't think of anything, especially because I can't define a fixed minimum height (because of the tilemap i've implemented can have some weird combinations and i would like to avoid imposing limits to the level design).

Anyone has an interesting insight on this?

Maybe I'm just looking at it from the wrong perspective...

Graphics / Culling problem
« on: December 13, 2015, 06:08:00 pm »
Hello, I've been trying to implement a culling algorithm in my game, but instead of only calling draw() when the tiles are in view, it draws everything untill the camera starts moving (side-scroller camera). After that, it just stops drawing everything.

Here's my best attempt so far:
        sf::View cam = target.getView();
    sf::FloatRect screenRect(sf::Vector2f(
                cam.getCenter().x - (cam.getSize().x/2.f),
                cam.getCenter().y - (cam.getSize().y/2.f)),

        for (int i = 0; i < m_map.size(); i++)
                for (int j = 0; j < m_map[i].size(); j++)
                        if (m_map[i][j].x != -1 && m_map[i][j].y != -1 && screenRect.intersects(sf::FloatRect(m_map[i][j].x * 32, m_map[i][j].y * 32, 32, 32)))
                                m_tilesprite.setPosition(j * tileSize, i * tileSize);
                                m_tilesprite.setTextureRect(sf::IntRect(m_map[i][j].x * tileSize, m_map[i][j].y * tileSize, tileSize, tileSize));

m_map is a 2d vector of sf::Vector2i that contains coordinates for tiles in the current level.

What am I doing wrong?

Pages: [1]