TheCherno / Cherno

The Cherno engine, for Ludum Dare.
GNU General Public License v3.0
76 stars 35 forks source link

Got rid of the huge boolean array #17

Closed SebastienGllmt closed 5 years ago

SebastienGllmt commented 10 years ago

The functionality of this class remains exactly the same. However, now we're instead using an array list of Key classes (defined inside the Keyboard class as private static). The performance of operations on this class doesn't really change since now you're creating Key objects and comparing them instead of creating Integer objects and comparing them. The difference that got rid of the boolean array is the fact that every key has a boolean field called "pressed" which is set to true once the method keyTyped has been called on that key. This allows us to only have as many booleans as are keys being pressed at any given moment (which on most keyboards is a very small number).