Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Need help with first sfml game  (Read 708 times)

0 Members and 1 Guest are viewing this topic.

supcomic1

  • Newbie
  • *
  • Posts: 1
    • View Profile
Need help with first sfml game
« on: October 12, 2013, 10:37:27 pm »
OK so this is my first sfml game i don't understand why it wont the print x's and o's
i'm using sfml 2.1 with visual studio 2012 for windows desktop
here's  handleInput()

void Board::handleInput()
{
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Num1))
{
        if (mTurn)
        {
                cout<<"\nEnted num1 true";
                for (int i = 0; i != 5; i++)
                {
                        cout<<"\nEnted loop true "<<i;
                if (mXArray[i].placed)
                        return;
                cout<<"\nEnted placing "<<i<<" at "<<mLocType.upperLeft.x<<" "<<mLocType.upperLeft.y;
                mXArray[i].placed = true;
                mXArray[i] = X(mLocType.upperLeft);
                }
                mTurn = 0;
        }
        else
        {
                cout<<"\nEnted num1 false";
                for (int i = 0; i != 4; i++)
                {
                if (mOArray[1].placed)
                        return;
                mOArray[1].placed = true;
                mOArray[1] = O(mLocType.upperLeft);
        }
                mTurn = 1;
        }
}
.
.
.
.
 

and heres the draw one
void Board::Draw()
{
          while (mWindow.isOpen())
    {
        sf::Event event;
        while (mWindow.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                mWindow.close();
        }
                handleInput();
        mWindow.clear();
                mWindow.draw(mSprite);
                for (int i = 0; i != 5; ++i)
                {
                        cout<<"\nenterd draw loop "<<i<<" "<<mXArray[i].mSprite.getPosition().x<<" "<<mXArray[i].mSprite.getPosition().y;

                        mWindow.draw(mXArray[i].mSprite);
                }
                                for (int i = 0; i != 4; ++i)
                {
                        if (!(mOArray[i].placed))
                                continue;
                        mWindow.draw(mOArray[i].mSprite);
                }
                                mWindow.draw(mXArray[0].mSprite); //testing to see if it work but it dosent
        mWindow.display();
    }
}

any Ideas?
« Last Edit: October 12, 2013, 10:59:19 pm by supcomic1 »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Need help with first sfml game
« Reply #1 on: October 12, 2013, 10:42:39 pm »
Please read this thread and adjust your question accordingly.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything