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

Pages: [1]
1
Window / Mouse Button retrive information
« on: December 03, 2012, 01:03:05 pm »
Hi,

i want to find out if any Mousebutton is Down. Is there a more elegant way of doing it than this?
if(myMouse.isButtonPressed(sf::Mouse::Left) || myMouse.isButtonPressed(sf::Mouse::Right) || ...)  {
   ...
}

2
Graphics / Re: SFML 2.0 and Custom Shape
« on: December 02, 2012, 08:22:31 pm »
Ok, i just implemented it as a single Vertexarray within a HexagonBorad class and yeah it's Fast as Hell(compared to before, where 15x15 wasn't possible), 200x200 Hexagons in Debugmode no Problem. But implementing the Mousechecks was quite a pain, because the tiles have Spacings between them, what made it difficult for me to calculate mouse coordinates to Board tiles. Before i just used Hexagon.isInside(Vector2i MouseCoordinates).

3
Graphics / Re: SFML 2.0 and Custom Shape
« on: November 30, 2012, 03:37:50 pm »
Ok, thanks for the advise. But i want to click on the Hexagons, color them, etc., and it has to be somewhat OOP.
I just testet 50x50 Sprites(50*50*2=5'000 Triangles) and 20x20 Hexagons(20*20*6=2'400 Triangles). All fit's on the screen, with no overlaping. The FPS with Sprites is OK, the FPS with Hexagons is horroble, even though the Hexagons have no Outline and no Texture. Can you explain why's this? And how can i improve performance without packing everything into a Vertexarray.

4
Graphics / Re: SFML 2.0 and Custom Shape
« on: November 30, 2012, 03:11:51 pm »
Ok, i started from scratch and it works now, sadly i have no clue what went wrong in first place.

But now comes the next problem, creating a 15x15 Hexagonboard is not possible, because the Framerate drops to ~10fps in release mode, in debug mode it's like a screenshot. 15x15, that's 225 Hexagons, assume that a Hexagon is 6 Triangles = 1'350 Triangles or 675 "Sprites".

If i create 2'000 sprites with texture and draw them the Framerate is much higher. Am i missing here something??

5
Graphics / Re: SFML 2.0 and Custom Shape
« on: November 30, 2012, 02:17:54 pm »
Indeed, i did not update the Shape, inserted it at the end of the Constructor, but still can't see any Hexagon...
also tryed to align the Points CCW and CW, both doesn't work.

And i tried that one, which works:

                        sf::ConvexShape polygon;
                        polygon.setPointCount(6);
                        const float s = 1.f*100.f;
                        const float h = 0.5f*100.f;                     //sin(30°)
                        const float r = 0.86602540f*100.f;      //cos(30°)
                        polygon.setPoint(0, sf::Vector2f(0.f, -s));
                        polygon.setPoint(1, sf::Vector2f( -r, -h));
                        polygon.setPoint(2, sf::Vector2f( -r, +h));
                        polygon.setPoint(3, sf::Vector2f(0.f, +s));
                        polygon.setPoint(4, sf::Vector2f( +r, +h));
                        polygon.setPoint(5, sf::Vector2f( +r, -h));
                        //polygon.setOutlineColor(sf::Color::Red);
                        //polygon.setOutlineThickness(5);
                        polygon.setPosition(200, 200);
                        App.draw(polygon);

so, i decided to update imediatly after inserting a point:
class Hexagon : public sf::Shape {
        private:
            static std::vector<sf::Vector2f> m_Coordinates;
        protected:        
            virtual unsigned int getPointCount() const {
                return m_Coordinates.size();
            }

            virtual sf::Vector2f getPoint(unsigned int index) const {
                return m_Coordinates[index];
            }
};

//In the Constructor
    if(m_Coordinates.empty()) {
        //More Details in image /Misc/hex_geometry.jpg
        const float s = 1.f;
        const float h = 0.5f;           //sin(30°)
        const float r = 0.86602540f;    //cos(30°)

        m_Coordinates.reserve(6);
        m_Coordinates.push_back(sf::Vector2f(0.f, -s)); //Top
        Shape::update();
        m_Coordinates.push_back(sf::Vector2f( -r, -h)); //Top-Left
        Shape::update();
        m_Coordinates.push_back(sf::Vector2f( -r, +h)); //Bottom-Left
        Shape::update();
        m_Coordinates.push_back(sf::Vector2f(0.f, +s)); //Bottom
        Shape::update();
        m_Coordinates.push_back(sf::Vector2f( +r, +h)); //Bottom-Right
        Shape::update();
        m_Coordinates.push_back(sf::Vector2f( +r, -h)); //Top-Right
        Shape::update();

        Shape::scale(1000.f, 1000.f);
        Shape::setFillColor(sf::Color(255.f, 0.f, 0.f));
        Shape::setPosition(sf::Vector2f(200.f, 200.f));
    }

But it does not work...

Well, now i derived from sf::ConvexShape. It works, but i still want to know why it doesn't work with sf::Shape, also i don't want to create the same points for every Hexagon over and over again, it's  a waste, the solution would be to make ConvexShape a static member, but that's ugly again. I really want to inherit from sf::Shape, as it makes the most sense...
 

6
Graphics / SFML 2.0 and Custom Shape
« on: November 30, 2012, 01:57:49 pm »
Hi, i tried to implement a Custom Shape:

class Hexagon : public sf::Shape {
                private:
                        static std::vector<sf::Vector2f> m_Coordinates;
                protected:                     
                        virtual unsigned int getPointCount() const {
                                return 6;
                        }

                        virtual sf::Vector2f getPoint(unsigned int index) const {
                                return m_Coordinates[index];
                        }
};

//In the Constructor
        if(m_Coordinates.empty()) {
                //More Details in image /Misc/hex_geometry.jpg
                const float s = 1.f;
                const float h = 0.5f;                   //sin(30°)
                const float r = 0.86602540f;    //cos(30°)

                m_Coordinates.reserve(6);
                m_Coordinates.push_back(sf::Vector2f(0.f, -s)); //Top
                m_Coordinates.push_back(sf::Vector2f( +r, -h)); //Top-Right
                m_Coordinates.push_back(sf::Vector2f( +r, +h)); //Bottom-Right
                m_Coordinates.push_back(sf::Vector2f(0.f, +s)); //Bottom
                m_Coordinates.push_back(sf::Vector2f( -r, +h)); //Bottom-Left
                m_Coordinates.push_back(sf::Vector2f( -r, -h)); //Top-Left

                Shape::scale(1000.f, 1000.f);
                Shape::setFillColor(sf::Color(255.f, 0.f, 0.f));
                Shape::setPosition(sf::Vector2f(200.f, 200.f));
        }
 

but it won't appear if i use
Hexagon myShape;
App.draw(myShape);

i scaled it to 1000.f to be sure i can see it...

Pages: [1]
anything