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

Pages: [1]
1
SFML projects / Re: My current project using SFML
« on: January 27, 2013, 04:41:58 pm »
Looks nice but I cant play it because game works too fast.

Did you add FPS limit?

2
General / Re: Sprite rotation to mouse problem
« on: October 03, 2012, 11:15:09 pm »
                sf::Vector2i cursor = sf::Mouse::getPosition(game);
                sf::Vector2f worldCursor = game.convertCoords(sf::Vector2i(cursor.x, cursor.y));
                sf::Vector2f direction = (worldCursor - Player.getPosition());
                Player.setRotation(std::atan2(direction.y, direction.x) * 180 / 3.14);
 

Now its working.

Thanks

3
General / Sprite rotation to mouse problem
« on: October 03, 2012, 09:49:48 pm »
Hi.

I've got strange problem with sprite rotation to mouse coords.

sf::Vector2i cursor = sf::Mouse::getPosition(game);
sf::Vector2f worldCursor = game.convertCoords(cursor.x, cursor.y);
sf::Vector2f direction = (worldCursor - Player.getPosition());
Player.setRotation(std::atan2(direction.y, direction.x));
 

Player is not rotating properly.
I found this code on this forum and to compile i need to add sf::Vector2i to worldCursor.

Thanks in advance for help.

4
General / Re: [SFML 2.0] sf::Event::MouseMoveEvent problems
« on: June 17, 2012, 01:06:33 pm »
Code: [Select]
            if (event.type == sf::Event::MouseMoved) {
             int x = event.mouseMove.x;
             paletka.setPosition(x, 5);
             std::cout << x << std::endl;
            }

It works! Thanks :)

5
General / [SFML 2.0] sf::Event::MouseMoveEvent problems
« on: June 17, 2012, 02:29:37 am »
Hi. I have a problem with sf::Event::MouseMoveEvent

#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
    sf::RenderWindow window(sf::VideoMode(1280, 720, 32), "LIKE A PONG TEST", sf::Style::Fullscreen);
    window.setFramerateLimit(60);
    sf::Mouse::setPosition(sf::Vector2i(100, 200), window);
    sf::Event::MouseMoveEvent mouse;
    sf::Event event;
    sf::Text paletka("|");

    while (window.isOpen())
    {
         while (window.pollEvent(event))
         {
             if (event.type == sf::Event::Closed)
                 window.close();

             if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
                 window.close();

             if (event.type == sf::Event::MouseMoved) {
                 int x = mouse.x;
                 paletka.setPosition(x, 5);
                 std::cout << x << std::endl;
             }

         }

        window.clear();
        window.draw(paletka);
        window.display();
    }
}
 

I'm trying to get text x equal to mouse x, but when I am moving the mouse it writes (in cmd) the same x always!
I don't know what to do...

Thanks in advance for help.

Pages: [1]