1
General / Re: How to save a display ?
« on: April 22, 2013, 02:59:23 pm »
Ok, I thought that recalculate every time would have use a lot of process, but finally it works perfectly ! =)
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.
sf::VertexArray lines(sf::LinesStrip, 2);
lines[0].position = sf::Vector2f(10, 0);
lines[1].position = sf::Vector2f(20, 0);
window.draw(lines);
eInput LibrarySFML::handleEvent1()
{
while (window.pollEvent(event))
{
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Left)
return (LEFT);
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Right)
return (RIGHT);
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Up)
return (UP);
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Down)
return (DOWN);
}
}
void LibrarySFML::handleEvent2()
{
while (window.pollEvent(event))
{
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Q)
input2 = LEFT;
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard:)
input2 = RIGHT;
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Z)
input2 = UP;
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::S)
input2 = DOWN;
}
}
Do you want that the play can walk left and up and the same time?No.
void LibrarySFML::handleEvent(eInput& input1, eInput& input2)
{
while (window.pollEvent(event))
{
if ((event.type == sf::Event::Closed) || (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape))
input1 = QUIT;
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Left)
input1 = LEFT;
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Right)
input1 = RIGHT;
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Up)
input1 = UP;
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Down)
input1 = DOWN;
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Q)
input2 = LEFT;
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard:: D)
input2 = RIGHT;
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Z)
input2 = UP;
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::S)
input2 = DOWN;
}
}
void LibrarySFML::handleEvent()
{
while (window.pollEvent(event))
{
if ((event.type == sf::Event::Closed) || (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape))
return (QUIT);
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Left)
return (LEFT);
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Right)
return (RIGHT);
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Up)
return (UP);
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Down)
return (DOWN);
}
}
{
while (event.type == sf::Event::KeyPressed); // I'm waiting the user to release the space key
while (window.waitEvent(event) && event.key.code != sf::Keyboard::Space); // then waiting him to press space again
}
I don't understand why people seem to think, that setting something specifically will remove it?window.create(sf::VideoMode(x, y), "SFML window", sf::Style::Resize, 0);
You're not the first one asking this, but it might be interesting to hear why you thought it would prevent resizing by setting the resize property?
Maybe Laurent can make it clearer in the documentation/tutorial (or haven't you taken a look those?).
Btw. for posting code, don't use the quote tag, but use the code=cpp tag.
window.create(sf::VideoMode(x, y), "SFML window", sf::Style::Resize, 0);