-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Hopson97/MineCraft-One-We…
- Loading branch information
Showing
16 changed files
with
117 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "Keyboard.h" | ||
|
||
|
||
Keyboard::Keyboard() { | ||
std::fill(m_keys.begin(), m_keys.end(), false); | ||
} | ||
|
||
void Keyboard::update(sf::Event e) { | ||
m_recentlyReleased = sf::Keyboard::KeyCount; | ||
switch (e.type) { | ||
case sf::Event::KeyReleased: | ||
m_keys[e.key.code] = false; | ||
break; | ||
|
||
case sf::Event::KeyPressed: | ||
m_recentlyReleased = e.key.code; | ||
m_keys[e.key.code] = true; | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
bool Keyboard::isKeyDown(sf::Keyboard::Key key) const { | ||
return m_keys[key]; | ||
} | ||
|
||
bool Keyboard::keyReleased(sf::Keyboard::Key key) const { | ||
return m_recentlyReleased == key; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <SFML/Window/Event.hpp> | ||
#include <SFML/Window/Keyboard.hpp> | ||
|
||
#include <array> | ||
|
||
class Keyboard { | ||
public: | ||
Keyboard(); | ||
|
||
void update(sf::Event e); | ||
|
||
bool isKeyDown(sf::Keyboard::Key key) const; | ||
bool keyReleased(sf::Keyboard::Key key) const; | ||
|
||
private: | ||
std::array<bool, sf::Keyboard::KeyCount> m_keys; | ||
sf::Keyboard::Key m_recentlyReleased; | ||
}; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.