1
General / Re: Battleship (Need help and idea with some codes)
« on: September 06, 2013, 09:20:32 am »
This in another problem that I just encountered, variable changing value in event space key pressed wont execute and I dont know why.
//VARIABLES
bool ship1Position;
bool ship2Position;
bool dragShip1 = false;
bool dragShip2 = false;
bool ship1Position;
bool ship2Position;
bool dragShip1 = false;
bool dragShip2 = false;
case sf::Event::KeyPressed:
{
switch(event.key.code)
{
case sf::Keyboard::Space:
if(dragShip1)
ship2Position = true;
dragShip1 = false;
break;
}
break;
}
case sf::Event::KeyReleased:
{
switch(event.key.code)
{
case sf::Keyboard::Space:
break;
}
}
}
}
window.clear();
ship1Position = true;
while(ship1Position)
{
window.draw(ship1);
dragShip1 = true;
ship1Position = false;
}
while(ship2Position)
{
window.draw(ship2);
dragShip2 = true;
ship2Position = false;
}
{
switch(event.key.code)
{
case sf::Keyboard::Space:
if(dragShip1)
ship2Position = true;
dragShip1 = false;
break;
}
break;
}
case sf::Event::KeyReleased:
{
switch(event.key.code)
{
case sf::Keyboard::Space:
break;
}
}
}
}
window.clear();
ship1Position = true;
while(ship1Position)
{
window.draw(ship1);
dragShip1 = true;
ship1Position = false;
}
while(ship2Position)
{
window.draw(ship2);
dragShip2 = true;
ship2Position = false;
}