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

Pages: [1]
1
Dude, your game looks good especially only for 14 days work. Guess you have some prior experience?
I have had prior experience making games but not with SFML (first game with SFML). I was thinking to just using OpenGL but I thought I'd use SFML as it was easier to use/learn and I would not have to setup too much. Luckily the documentation for SFML is absolutely superb; compared to many that I have read, it you don't even need tutorials even though there are many!

2
Quote
I wonder why a non integer view centre would cause the textures of the sprites to shift though.
Because of OpenGL rasterization rules, which become more complicated in this case and may lead to such artifacts because texture pixels no longer match the window's pixels 1:1.

Looking at the OpenGL specs, I think I can see why this may happen. Thank you for all the help.

3
Did you try aligning your view to integer coordinates?

I'm updating my view by moving it my how much my character moves each update cycle. Sorry but I don't understand what you mean my aligning the view to integer coordinates.

If your caracter position is [27.6 : 125.14] you may want to set your view center at [28 : 125].
You may also want to do the same for sprites position if not already the case.

Thank you so much! I think this has fixed the problem; I've been trying to fix this for days! I wonder why a non integer view centre would cause the textures of the sprites to shift though.

4
Did you try aligning your view to integer coordinates?

I'm updating my view by moving it my how much my character moves each update cycle. Sorry but I don't understand what you mean my aligning the view to integer coordinates.

5
General / Tilemap engine causing textures to move when view is moved.
« on: August 19, 2013, 01:48:25 pm »
Hi I've been make this game about a fortnight now and I've been having this problem with the tiles/blocks being rendered when the view is moved.

I've been fixing the view to the character but when the character/view is moved in the y-axis (and sometimes the x-axis but very rare) the tiles seem have these lines:



I've figured out that these lines are cause by the texturerect of the tile (which is a sprite) is being moved cause some of the rest of the texture to be show in it. The Blue lines are where texture is transparent and the brown lines on some of the grass tiles, the texture is showing another tile.


I would show some minimal code if I could but I cannot seem to replicate this on a small level so here are snippets of my code:

Place tiles into sprites
m_tiles => std::Vector<sf::Sprite>
terrain2.png is a 256x256 png containing 256 tiles (akin to older version of minecraft)

for (uint8_t y = 0; y < 16; y++)
{
        for (uint8_t x = 0; x < 16; x++)
        {
                sf::Sprite stemp;
                stemp.setTexture(textureManager.getTexture("res/image/terrain2.png"));
                stemp.setTextureRect( sf::IntRect(16*x, 16*y, 16, 16) );
                stemp.setOrigin(8, 8);
                m_tiles.push_back(stemp);
        }
}
 

Display Tiles
mapLevel => std::vector< std::vector<uint8_t> > this way I call a tile like mapLevel[x][y]

// Only display what is on screen
        int drawRangeX = window.getSize().x/64;
        int drawRangeY = window.getSize().y/64;

// Add one to draw range
        drawRangeX++;
        drawRangeY++;

        for (unsigned int y = std::max((m_character.getPosition().y/16.0f)-drawRangeY, 0.0f);
             y < std::min((m_character.getPosition().y/16.0f)+drawRangeY, (float)(gridSize.y-1)); y++)
        {
                for (unsigned int x = std::max((m_character.getPosition().x/16.0f)-drawRangeX, 0.0f);
                     x < std::min((m_character.getPosition().x/16.0f)+drawRangeX, (float)(gridSize.x-1)); x++)
                {
                        uint8_t tileId = mapLevel[x][y];
                        if (tileId != 0x00)
                        {
                                switch (tileId) // used to "randomize" tiles or get specific tile
                                {
                                case 0x05: // Grass
                                        tileId += (x+y)%2;
                                        break;
                                case 0x30: // Ore
                                        tileId += (3*x + 2*y)%2;
                                        break;
                                case 0x0C: // Leaves
                                        if (mapLevel[x-1][y] != 0x0C && mapLevel[x][y-1] != 0x0C)
                                                tileId += 1;
                                        else if (mapLevel[x+1][y] != 0x0C && mapLevel[x][y-1] != 0x0C)
                                                tileId += 2;
                                        break;
                                default:
                                        break;
                                }

                                sf::Sprite temp = m_tiles[tileId];
                                temp.setPosition(x*16, y*16);
                                if (layerBrightness != 0xFF)
                                        temp.setColor(sf::Color(layerBrightness, layerBrightness, layerBrightness));

                                window.draw(temp);
                        }
                }
        }
 

6
Window / SFML 2.1 on Mac - Using sf::Mouse::isButtonPressed crashes app
« on: August 16, 2013, 10:59:05 am »
Anytime sf::Mouse::isButtonPressed is used, it caused the application to crash. Using GDB to check the error, I get this:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
0x00007fff969cd310 in IOHIDElementGetDevice ()
(gdb) bt
#0  0x00007fff969cd310 in IOHIDElementGetDevice ()
#1  0x000000010004cbd1 in sf::priv::HIDInputManager::isMouseButtonPressed ()
#2  0x000000010004c7e7 in sf::priv::InputImpl::isMouseButtonPressed ()
#3  0x00000001000486f9 in sf::Mouse::isButtonPressed ()
#4  0x0000000100006285 in main ()

I'm using SFML 2.1 on Mac OS X 10.8.4.

Pages: [1]