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

Pages: [1]
1
Graphics / Re: Why are my tiles not displayed?
« on: May 08, 2013, 12:03:50 am »
Okay so using the debug libraries fixed it, thank you.

Also thank you Raphman for pointing out that i was loading the texture too often ^^

2
Graphics / Re: Why are my tiles not displayed?
« on: May 07, 2013, 11:30:08 pm »
Well yeah i feel like a bit of an idiot for not realising that simply changing the colour doesn't do anything if there is no texture loaded.

When I run the code, attempting to load the texture, it breaks at the line:

if (!grass.loadFromFile("Grass.png"))

with the error:

"Unhandled exception at 0x71521f34 in First SFML work.exe: 0xC0000005: Access violation reading location 0x00304000."

I have the image, with the correct name, of course, in the debug folder for the project (Visual Studio 2010\Projects\First SFML work\Debug) which I believe is the correct place but just incase also stored it in the folder (Visual Studio 2010\Projects\First SFML work\First SFML work) as well.

Having looked at other forum posts I don't think this is a coding error but something to do with how i've set up SFML or where I've stored the image. However the only similar errors i can see have been when loading audio, not textures, if that's of any consequence.

3
Graphics / Why are my tiles not displayed?
« on: May 07, 2013, 07:58:23 pm »
Hi, I'm really new to SFML and objects and classes so please bare with me ^^.
I'm trying to just get started and display a set of 32x24 tiles depending on the value of the grid. My problem is that the sprite's just aren't displayed.

I know that the array 'grid' is full of 'G's so that shouldn't be a problem. SIZEX and SIZEY are both 10.

and as an added extra can anybody tell me why I get an unhandled exception error when I try to load from file ^^

Thanks.


void displayFloor(char grid[][SIZEY], sf::RenderWindow& window)
{
        sf::Texture grass;
        //if (!grass.loadFromFile("Grass.png"))
        //{
        //      cout << "Can't load grass";
        //}
        sf::Sprite grassSprite;
        //grassSprite.setTexture(grass);
        grassSprite.setColor(sf::Color(50, 255, 50, 0));
        grassSprite.setScale(32,24);
        for( int row(1); row<=SIZEY; ++row )
        {
                for( int col(1); col<=SIZEX; ++col )
                {
                        float x = 0 + col * 32;
                        float y = 0 + row * 24;
                        switch( grid[row][col] )
                        {
                        case 'G':
                                grassSprite.setPosition( x, y );
                                window.draw( grassSprite );
                                break;
                        }
                }
        }
}

Pages: [1]