PurpleKingdomGames / indigo

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

Add Key.isNumeric / Key.asNumber #746

Closed davesmith00000 closed 3 weeks ago

davesmith00000 commented 5 months 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.