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

Pages: [1]
1
Graphics / Re: [solved] SFML 2.0 - Shape.move stretches the shape Oo
« on: June 20, 2012, 12:29:53 pm »
Thanks :)

2
Graphics / Re: SFML 2.0 - Shape.move stretches the shape Oo
« on: June 20, 2012, 02:18:43 am »
Screw it, I forgot to clear the window.

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

3
Sry for being stupid :D. Although, you should change that.
Is that the whole error message? And is that the code you are using?

I tried to run that on my comp, you are missing a closing bracket on the line
grass.setTextureRect(IntRect(0,0,45,45);

Also, according to the documentation there is no such method: "sf::Sprite setX()".

But the main error you are talking of seems to be somewhere else. Did you try to remove the other errors? Which IDE are you using, Visual Studio?

4
According to the documentation, Image.loadFromFile() is returning true if the texture was loaded correctly. But you close the program if it was successfull:

    if(terrain.loadFromFile("terrain.png"))
    {
        return EXIT_FAILURE;
    }

You should change that ;)

So it seems your file could not be loaded. Is it readable? If you are using Linux, try "$ chmod 0777 terrain.png" (making the file world-readable via command shell). Otherwise, check the folder you have loaded the file into - maybe it's located on the wrong subfolder?

5
Graphics / [solved] SFML 2.0 - Shape.move stretches the shape Oo
« on: June 20, 2012, 01:13:21 am »
Hey.

I got a strange error.
I am using RectangleShape::move(10, 0) in an inherited class and it stretches the rectangle Oo. The start position X seems to stay the same, only the width seems to increase.

The method "beforeDraw()" is called before the texture is drawn in the window. The code is very small and simple, so I don't see where my error is...

Any suggestions? :/

Greetings,
SargTeX

class Jake : public sf::RectangleShape {
private:
        sf::Vector2f targetPosition;
        float speed;
       
public:
        Jake(sf::Vector2f size):RectangleShape(size),targetPosition(0, 0),speed(0.5) {
                setFillColor(sf::Color::Red);
                setPosition(10, 100);
                targetPosition = getPosition();
        }
       
        //Setter...
       
        void beforeDraw() {
                //the target position was changed of course
                if (targetPosition != getPosition()) {
                        if (targetPosition.x > getPosition().x) {
                                move(speed, 0);               //this seems to stretch the shape/change the width, not to change its x
                                cout << "move!" << endl;       //this makes the correct output
                        }
                }
        }
       
};

int gameMain() {
        sf::RenderWindow app(sf::VideoMode(800, 600), "Adventure Time!", sf::Style::Default);
       
        //SFML & OpenGL Settings...
       
        Jake jake(sf::Vector2f(20, 20));
   
        //draw frames
        while (running) {
                //event polling aso...
       
                //draw
                jake.beforeDraw();
                app.draw(jake, sf::RenderStates::Default);
       
                //display
                app.display();
        }
   
        //Shutdown everything...
}

Pages: [1]
anything