add copyrights to new files
[Tsunagari.git] / src / bitrecord.cpp
blob80a65e2ca1f6f80871d7a59a90ae42a2fa15fd93
1 /****************************
2 ** Tsunagari Tile Engine **
3 ** bitrecord.cpp **
4 ** Copyright 2012 OmegaSDG **
5 ****************************/
7 #include <Gosu/Input.hpp>
9 #include "bitrecord.h"
10 #include "window.h"
12 BitRecord BitRecord::fromGosuInput()
14 size_t cnt = Gosu::numButtons;
15 Gosu::Input& in = GameWindow::instance().input();
17 BitRecord rec(cnt);
18 for (size_t i = 0; i < cnt; i++)
19 rec.states[i] = in.down(Gosu::Button((unsigned)i));
21 return rec;
24 bool BitRecord::operator[] (size_t idx)
26 return states[idx];
29 std::vector<size_t> BitRecord::diff(const BitRecord& other)
31 std::vector<size_t> changes;
33 for (size_t i = 0; i < states.size(); i++)
34 if (states[i] != other.states[i])
35 changes.push_back(i);
36 return changes;
39 BitRecord::BitRecord(size_t length)
40 : states(length)