PurpleKingdomGames / indigo

An FP game engine for Scala.
https://indigoengine.io/
MIT License
611 stars 56 forks source link

Add Key.isNumeric / Key.asNumber #746

Open davesmith00000 opened 2 weeks ago

davesmith00000 commented 2 weeks ago

Would be handly to be able to say "was the key a number" and "optionally give me the key's number, if it was a number. Currently doing it was something like this:

def keyToNumber(keyCode: Int): Option[Int] =
      if keyCode >= Key.KEY_0.code && keyCode <= Key.KEY_9.code then
        Option(keyCode - Key.KEY_0.code)
      else None

But in the real version they could just be properties of the enum or something.