Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CurrentPlayer(override val game: PewGame, spriteSheet: String) : Player(game, spriteSheet)
- {
- [ConstructorCode]
- {
- this.game.input.Register(this.game.input.CreateKeySet("up", "down", "left", "right"),
- InputManager.ReceiverAction(InputManager.KeyState.Down)
- {
- false
- })
- }
- private fun GetInput()
- {
- var keys: MutableSet<String> = HashSet()
- this.game.input.getKeysDown().forEach { keys.add(this.game.input.TranslateKey(it)) }
- if (keys.contains("left"))
- this.input.x = -1.0f
- else if (keys.contains("right"))
- this.input.x = +1.0f
- else
- this.input.x = 0.0f
- if (keys.contains("up"))
- this.input.y = +1.0f
- else if (keys.contains("down"))
- this.input.y = -1.0f
- else
- this.input.y = 0.0f
- }
- override fun Update(deltaTime: Float)
- {
- this.GetInput()
- // update super
- super<Player>.Update(deltaTime)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement