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.


Topics - Khaos

Pages: [1]
1
SFML projects / Tic Tac Toe
« on: May 23, 2012, 04:50:20 am »
Here's the Tic Tac Toe app: http://d.pr/f/gh1L

Credit goes to EnigmaticFellow (http://en.sfml-dev.org/forums/index.php?topic=6953.0) for supplying the Grid, X, and O images.

I used none of the code from that project, but the images supplied in that pack were too perfect to pass up.

Source Code: http://pastebin.com/Q6gAbHwV

I supply the source code in hopes that it will help many beginners learn the basics.

Enjoy!

2
Graphics / How to draw a sprite on top of another?
« on: May 23, 2012, 12:13:00 am »
    while (window.isOpen())
    {
        //Processes events
        sf::Event event;

        //Fills Event with data
        while(window.pollEvent(event))
        {
            switch(event.type)
            {
                case sf::Event::Closed:
                window.close();
                break;
                default:
                break;
            }
        }
        window.clear();
        window.draw(bgs);
        window.display();
        xTurn();
    }

void xTurn()
{
    bool xturn = true;

    while(xturn)
    {
    if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
    {
        sf::Vector2i mousePosition = sf::Mouse::getPosition(window);

        if((mousePosition.x < 200 && mousePosition.y < 200)
               && sf::Mouse::isButtonPressed(sf::Mouse::Left))
           {
        X.setPosition(25, 20);
        window.draw(X);
        std::cout << "hi";
        xturn = false;
           }

    }
    }

There's part of my main method and my whole xTurn code. Essentially when you left click, I want the sprite X to be printed. Also, that buttonispressed seems to activate multiple times (hi prints out 30+ times as opposed to just once).

How do I go about doing this?

Thanks.

Pages: [1]