New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

h-input

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

h-input

Typescript input helpers

latest
npmnpm
Version
1.0.18
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

import {SnInputCmd, SnInputCmds} from "engine/input/SnInputs"; import {SnGame} from "engine/SnGame"; import {SynthButtonCodes} from "m/h-input/gamepad/SynthButtonCodes"; import {InputCls} from "m/h-input/Input"; import {InputBind, InputBinder} from "m/h-input/InputBinder"; import {RenderableTerminal} from "m/h-term/Terminal"; import {KeyCodes} from "m/wip/KeyCodes";

export class SnUserInterface {

game?: SnGame terminal?: RenderableTerminal running: boolean = false input: InputCls = new InputCls() inputBinder: InputBinder = new InputBinder(this.input)

constructor() {}

setGame(game: SnGame) { this.game = game }

setTerminal(terminal: RenderableTerminal): any { this.terminal = terminal }

addInputs() { //TODO: HTML Prevent Default! this.inputBinder.addBinds( InputBinder.createMovementBinds({ U: SnInputCmds.U, D: SnInputCmds.D, L: SnInputCmds.L, R: SnInputCmds.R, }), ) this.inputBinder.addBind( new InputBind( SnInputCmds.EndTurn, InputBinder.key(KeyCodes.Enter), InputBinder.btn(SynthButtonCodes.Start), ), ) this.inputBinder.addBind( new InputBind( SnInputCmds.NextActor, InputBinder.key(KeyCodes.Tab), InputBinder.btn(SynthButtonCodes.RB), ) ) this.inputBinder.addBind( new InputBind( SnInputCmds.PrevActor, InputBinder.key(KeyCodes.Tab,{shift: true}), InputBinder.btn(SynthButtonCodes.LB), ) )

}

startInput() { this.input.start() this.addInputs() }

stopInput() { this.input.stop() }

startLoop() { this.running = true requestAnimationFrame(this.gameLoop) }

singleLoop = (time: number) => { this.input.beginUpdate() this.inputBinder.beginUpdate() if (this.game ) { if (this.inputBinder.getCommands().length > 0) { //Displatch the commands this.game.handleCommands(this.inputBinder.getCommands()) } if (this.terminal) { this.game.render(this.terminal) this.terminal.render()
}

}
this.inputBinder.endUpdate()
this.input.endUpdate()

}

gameLoop = (time: number) => { this.singleLoop(time) if (this.running) { requestAnimationFrame(this.gameLoop) } } }

Keywords

ash9g

FAQs

Package last updated on 12 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts