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

Pages: [1]
1
Graphics / Pentagon not being quite right?
« on: March 29, 2011, 02:52:40 am »
/facepalm. I can't believe I was that stupid... It works now, thanks!

2
Graphics / Pentagon not being quite right?
« on: March 28, 2011, 10:01:45 pm »
Hi, I'm trying to draw a star. A pentagon would be OK too, so that's what I'm working towards. I'm drawing 5 points at 72 degree intervals around the origin, then moving the shape to where you can see it. Unfortunately, it's not working. The angles aren't coming out right. What am I doing wrong?

Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <math.h>


int main()
{
const int pi=3.141592654;
    // Create main window
    sf::RenderWindow App(sf::VideoMode(800, 600), "SFML Graphics");

    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        // Clear screen
        App.Clear();

        // Draw apredefined shape
        //App.Draw(sf::Shape::Circle(200, 200, 100, sf::Color::Yellow, 10, sf::Color::Blue));
sf::Shape Star;
//Star.AddPoint((200*cos(((2*pi)/5))), (200*sin(((2*pi)/5))),  sf::Color::Yellow, sf::Color::Red);
// Star.AddPoint((200*cos(((4*pi)/5))), (200*sin(((4*pi)/5))),  sf::Color::Yellow, sf::Color::Blue);
// Star.AddPoint((200*cos(((6*pi)/5))), (200*sin(((6*pi)/5))),  sf::Color::Yellow, sf::Color::Green);
// Star.AddPoint((200*cos(((8*pi)/5))), (200*sin(((8*pi)/5))),  sf::Color::Yellow, sf::Color::Magenta);
// Star.AddPoint((200*cos(10*pi/5)), (200*sin(10*pi/5)),  sf::Color::Yellow, sf::Color::White);

Star.AddPoint((200*cos(((2*pi)/5))), (200*sin(((2*pi)/5))),  sf::Color::Yellow, sf::Color::Red);
//Star.AddPoint((200*cos(((4*pi)/5))), (200*sin(((4*pi)/5))),  sf::Color::Yellow, sf::Color::Blue);
Star.AddPoint((200*cos(((6*pi)/5))), (200*sin(((6*pi)/5))),  sf::Color::Yellow, sf::Color::Green);
//Star.AddPoint((200*cos(((8*pi)/5))), (200*sin(((8*pi)/5))),  sf::Color::Yellow, sf::Color::Magenta);
Star.AddPoint((200*cos(10*pi/5)), (200*sin(10*pi/5)),  sf::Color::Yellow, sf::Color::White);
Star.AddPoint((200*cos(((4*pi)/5))), (200*sin(((4*pi)/5))),  sf::Color::Yellow, sf::Color::Blue);
Star.AddPoint((200*cos(((8*pi)/5))), (200*sin(((8*pi)/5))),  sf::Color::Yellow, sf::Color::Magenta);
Star.Move(300, 300);
Star.EnableFill(true);
Star.EnableOutline(true);
Star.SetOutlineWidth(25);
App.Draw(Star);

        // Finally, display the rendered frame on screen
        App.Display();

    }

    return EXIT_SUCCESS;
}

Pages: [1]
anything