1
General / 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()
and heres the draw one
any Ideas?
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;
}
}
.
.
.
.
{
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();
}
}
{
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?