deathcap / kb-bindings

keybindings for games, with polling and events (based on kb-controls)
http://deathcap.github.io/kb-bindings-ui/
2 stars 1 forks source link

Refactor events into separate module/plugin, compatibility with game-shell #1

Closed deathcap closed 10 years ago

deathcap commented 10 years ago

https://github.com/mikolalysenko/game-shell has its own key input and binding API, partly overlapping with kb-bindings. But the events may still be useful to have, and are frequently used by voxel.js plugins:

voxeljs $ ack game.buttons.down.on voxel-*|perl -pe's/^/    /g'
voxel-artpacks/index.coffee:18:    @game.buttons.down.on 'packs', @onDown = @dialog.open.bind(@dialog)
voxel-artpacks/index.js:34:      return this.game.buttons.down.on('packs', this.onDown = this.dialog.open.bind(this.dialog));
voxel-console/index.coffee:39:      @game.buttons.down.on binding, () =>
voxel-console/index.js:47:          return _this.game.buttons.down.on(binding, function() {
voxel-fly/index.js:29:  this.game.buttons.down.on('jump', this.onJumpDown = function() {
voxel-gamemode/index.coffee:30:    @game.buttons.down.on 'inventory', @onInventory = () =>
voxel-gamemode/index.js:54:      return this.game.buttons.down.on('inventory', this.onInventory = (function(_this) {
voxel-inventory-hotbar/index.coffee:102:        @game.buttons.down.on slotName, @onSlots[key] = () =>
voxel-inventory-hotbar/index.js:148:            return _this.game.buttons.down.on(slotName, _this.onSlots[key] = function() {
voxel-player/index.js:113:      this.game.buttons.down.on('pov', this.onPov = function() { physics.toggle(); });
voxel-player/index.js:114:      this.game.buttons.down.on('home', this.onHome = function() { physics.home(); });
voxel-sprint/index.js:28:  self.game.buttons.down.on('forward', self.onForwardDown = function() {
voxel-zen/index.coffee:42:    @game.buttons.down.on 'zen', @down = () =>
voxel-zen/index.js:86:      return this.game.buttons.down.on('zen', this.down = (function(_this) {

voxeljs $ ack game.buttons.changed.on voxel-*|perl -pe's/^/    /g'
voxel-voila/index.coffee:88:      @game.buttons.changed.on 'crouch', @onChanged = () =>
voxel-voila/index.js:101:        return this.game.buttons.changed.on('crouch', this.onChanged = (function(_this) {

voxeljs $ ack game.buttons.up.on voxel-*|perl -pe's/^/    /g'
voxel-fly/index.js:48:  this.game.buttons.up.on('jump', this.onJumpUp = function() {
voxel-sprint/index.js:50:  self.game.buttons.up.on('forward', self.onForwardUp = function() {

idea: make a new module, specifically for key down/changed/up events, built on top of and compatible with game-shell and kb-bindings/kb-controls, providing a compatible API for plugins to use on both platforms. This could help all the plugins listed above, including https://github.com/deathcap/voxel-artpacks/issues/2

see also https://github.com/maxogden/voxel-engine/pull/96

deathcap commented 10 years ago

https://github.com/deathcap/voxel-keys