@benev/tact 0.4.0-5 → 0.4.0-6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -64,38 +64,12 @@ i made tact because i want to make indie web game development easier. user input
64
64
  tact.gamepads("gamepad")
65
65
  tact.registerElements()
66
66
  ```
67
- - 💡 *set `maxPlayers` to 1 for single player.*
68
- - 🍏 **put the `<tact-deck>` in your html page.**
69
- ```html
70
- <tact-deck></tact-deck>
71
- ```
72
- - 💡 *you also have each panel, `<tact-controllers>` and `<tact-customize>`.*
73
- - 💡 *you can customize the colors with css.*
74
- ```html
75
- <style>
76
- html {
77
- --tact-prime: aqua;
78
- --tact-bg: black;
79
- }
80
- </style>
81
- ```
82
- - 🎉 **now users can configure controllers and customize bindings!**
83
-
84
-
85
-
86
- <br/>
87
-
88
- ## 🎮 encoding, decoding, and your game logic.
89
-
90
- - 🍏 **now it's time for the real action!**
67
+ - 💡 *you can set `maxPlayers` to 1 for single player.*
68
+ - 🍏 **encoding, decoding, and your game logic.**
91
69
  ```ts
92
- import {Collector} from "@benev/tact"
93
-
94
- const collector = new Collector(bindings)
95
-
96
70
  setInterval(() => {
97
71
  const buffer = tact.deck.hub.encodeAll()
98
- for (const {playerId, inputs} of collector.decodeAll(buffer)) {
72
+ for (const {playerId, inputs} of tact.collector.decodeAll(buffer)) {
99
73
 
100
74
  // your game logic can read these handy input values.
101
75
  inputs.jump.value // values are numbers 0 to 1.
@@ -107,14 +81,30 @@ i made tact because i want to make indie web game development easier. user input
107
81
  }
108
82
  }, 16.67)
109
83
  ```
110
- - 💡 *you could stream the buffers across the network to a remote collector.*
111
- - 💡 *maybe imagine having the tact deck on the clientside, and the collector on the serverside (or a web worker!).*
84
+ - 💡 *maybe imagine streaming the buffers across the network to a remote collector.*
85
+ - 💡 *maybe imagine the tact deck on the clientside, and the collector on the serverside (or a web worker!).*
86
+ - 🍏 **put the `<tact-deck>` element in your html page.**
87
+ ```html
88
+ <tact-deck></tact-deck>
89
+ ```
90
+ - 💡 *you also have each panel, `<tact-controllers>` and `<tact-customize>`.*
91
+ - 💡 *you can customize the colors with css.*
92
+ ```html
93
+ <style>
94
+ html {
95
+ --tact-prime: aqua;
96
+ --tact-bg: black;
97
+ }
98
+ </style>
99
+ ```
100
+ - 🎉 **you're done! your users can manage controllers and customize bindings!**
112
101
 
113
102
 
114
103
 
115
104
  <br/>
116
105
 
117
106
  ## 🎮 get down to brass tacks.
107
+ > *tact is flexible and composable for alternative use-cases.*
118
108
 
119
109
  - 🍏 **pov: your app isn't a game, no multiplayer, no gamepads.**
120
110
  ```ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@benev/tact",
3
- "version": "0.4.0-5",
3
+ "version": "0.4.0-6",
4
4
  "description": "🎮 from keypress to couch co-op",
5
5
  "license": "MIT",
6
6
  "author": "Chase Moskal <chasemoskal@gmail.com>",
package/s/index.html.ts CHANGED
@@ -4,7 +4,7 @@ import {template, html, dataSvgEmoji, socialCard} from "@e280/scute"
4
4
  const title = "@benev/tact"
5
5
  const domain = "tact.benev.gg"
6
6
  const favicon = "/assets/b.png"
7
- const description = "🎮 keybindings and couch co-op"
7
+ const description = "🎮 from keypress to couch co-op"
8
8
 
9
9
  export default template(import.meta.url, async orb => html`
10
10
  <!doctype html>
@@ -3,6 +3,7 @@ import {register} from "@e280/sly"
3
3
 
4
4
  import {setupDeck} from "./deck.js"
5
5
  import {SetupParams} from "./types.js"
6
+ import {Collector} from "../collector.js"
6
7
  import {Bindings} from "../../../input/types.js"
7
8
  import {autoGamepads} from "../auto-gamepads.js"
8
9
  import {ellipsis} from "../../../utils/ellipsis.js"
@@ -23,6 +24,8 @@ import gameControllerSvg from "../../icons/akar/game-controller.svg.js"
23
24
 
24
25
  export async function setupTact<B extends Bindings>(params: SetupParams<B>) {
25
26
  const deck = await setupDeck(params)
27
+ const first = firstPreset(deck.controls.presets)
28
+ const collector = new Collector(first.profile.bindings)
26
29
  const visualizer = new Visualizer()
27
30
 
28
31
  const elements = {
@@ -40,14 +43,14 @@ export async function setupTact<B extends Bindings>(params: SetupParams<B>) {
40
43
  handle,
41
44
  tooltip: handle,
42
45
  name: ellipsis(handle, 32),
43
- defaultProfileKey: defaultProfileKey ?? firstPreset(deck.controls.presets).key,
46
+ defaultProfileKey: defaultProfileKey ?? first.key,
44
47
  })
45
48
  return () => deck.controls.detach(controller)
46
49
  })
47
50
  }
48
51
 
49
52
  function mouseKeyboard() {
50
- const {key, profile} = firstPreset(deck.controls.presets)
53
+ const {key, profile} = first
51
54
 
52
55
  const controller = new Controller({
53
56
  bindings: profile.bindings,
@@ -76,6 +79,7 @@ export async function setupTact<B extends Bindings>(params: SetupParams<B>) {
76
79
 
77
80
  return {
78
81
  deck,
82
+ collector,
79
83
  gamepads,
80
84
  mouseKeyboard,
81
85
  visualizer,