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

Pages: [1]
1
Graphics / Re: Problem with rotation
« on: December 29, 2015, 10:35:51 pm »
thanks it works , mind explaining a little how does rotate() work?

2
Graphics / Re: Problem with rotation
« on: December 29, 2015, 10:30:25 pm »
check this code :

#include <SFML/Graphics.hpp>

int main()
{
        sf::CircleShape s;
        s.setFillColor(sf::Color::Red);
        s.setRadius(100.f);

        s.setPosition(700.f, 350.f);

        sf::RenderWindow win(sf::VideoMode(1600, 900), "test");

        while (win.isOpen())
        {
                sf::Event e;
                while (win.pollEvent(e))
                {
                        if (e.type == sf::Event::Closed)
                                win.close();
                }


                win.clear();
                s.rotate(1); //rotate 1 degree each iteration
                win.draw(s);
                win.display();
                sf::sleep(sf::seconds(0.01));
        }

        return 0;
}

the circle is indeed rotating but its initial position changes aswell, the question is how do i rotate the circle so the position wont change

3
Graphics / Re: Problem with rotation
« on: December 29, 2015, 10:11:47 pm »
I just gave it ...

just give me an example on how to rotate a circle or rectangle on its standing position like this, the rotate function rotates it in a weird way,  i would be glad if someone explains me how rotate() really works, but first this problem :

http://imgur.com/4qnse4t

4
Graphics / Re: Problem with rotation
« on: December 29, 2015, 09:49:05 pm »
so I have a head of a snake which can pose in 4 different states, with the face up, down, left and right , what I wanted to do is make use of rotations to rotate the head so that it faces the desired directions without changing the position of the head on the screen

I have made a workaround using texture rectangle...

if (mIsMovingUp)
        {
                movement.y -= mPlayerSpeed;
                //how ?
        }
        if (mIsMovingDown)
        {
                movement.y += mPlayerSpeed;
                //how ?
        }
        if (mIsMovingLeft)
        {
                movement.x -= mPlayerSpeed;
                mPlayer[0].setTextureRect(sf::IntRect(64, 0, -32, 32));
                //sprite face left
        }
        if (mIsMovingRight)
        {
                movement.x += mPlayerSpeed;
                mPlayer[0].setTextureRect(sf::IntRect(32, 0, 32, 32));
                //sprite face right
        }

5
Graphics / Problem with rotation
« on: December 29, 2015, 08:35:12 pm »
I have a circle sprite which I try to rotate it accordingly for my game, but I dont seem to understand how SMFL rotation works . I even set the origin of the sprite in the center but always the positions changes when I rotate..

Pages: [1]
anything