Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1.  
  2. public class CurrentPlayer(override val game: PewGame, spriteSheet: String) : Player(game, spriteSheet)
  3. {
  4. [ConstructorCode]
  5. {
  6. this.game.input.Register(this.game.input.CreateKeySet("up", "down", "left", "right"),
  7. InputManager.ReceiverAction(InputManager.KeyState.Down)
  8. {
  9. false
  10. })
  11. }
  12.  
  13. private fun GetInput()
  14. {
  15. var keys: MutableSet<String> = HashSet()
  16. this.game.input.getKeysDown().forEach { keys.add(this.game.input.TranslateKey(it)) }
  17.  
  18. if (keys.contains("left"))
  19. this.input.x = -1.0f
  20. else if (keys.contains("right"))
  21. this.input.x = +1.0f
  22. else
  23. this.input.x = 0.0f
  24.  
  25. if (keys.contains("up"))
  26. this.input.y = +1.0f
  27. else if (keys.contains("down"))
  28. this.input.y = -1.0f
  29. else
  30. this.input.y = 0.0f
  31. }
  32.  
  33. override fun Update(deltaTime: Float)
  34. {
  35. this.GetInput()
  36.  
  37. // update super
  38. super<Player>.Update(deltaTime)
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement