16
SFML projects / Open Source top-down game - Warlock's Gauntlet
« on: October 26, 2010, 01:46:04 pm »
Amazing Mainmenu Background!
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.
I use w7 64 bit so you should be good to go.
XSpeed *= -1.0f;
cBall.Move(XSpeed * ElapsedTime, YSpeed * ElapsedTime);
until I click the window and hold for 2-3 secs
But std::list is not, that's for sure.
Why can't you use bool sf::Input::IsKeyDown(sf::Key::Code key)? That function fits exactly your purpose. You don't even have to store an own array.
void Input::refresh() {
m_KeyPresses.clear();
m_KeyReleases.clear();
while (m_Window.GetEvent(Event))
{
switch (Event.Type)
{
case sf::Event::KeyPressed:
m_KeyPresses.push_back(Event.Key.Code);
break;
case sf::Event::KeyReleased:
m_KeyReleases.push_back(Event.Key.Code);
break;
}
}
}
bool Input::isKeyPressed(const sf::Key::Code& _KeyCode)
{
for(std::list<sf::Key::Code>::iterator IT = m_KeyPresses.begin(); IT != m_KeyPresses.end(); IT++) if (*IT == _KeyCode) return true;
return false;
}
bool Input::isKeyReleased(const sf::Key::Code& _KeyCode)
{
for(std::list<sf::Key::Code>::iterator IT = m_KeyReleases.begin(); IT != m_KeyReleases.end(); IT++) if (*IT == _KeyCode) return true;
return false;
}
Have an array of bools that stores the key states from the previous frame
bool[Key::Count] sf::Input Input::getKeys() {
return myKeys;
}