@benev/tact 0.4.0-3 → 0.4.0-5
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 +31 -11
- package/package.json +1 -1
- package/x/gamepad/index.html +1 -1
- package/x/index.html +1 -1
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ i made tact because i want to make indie web game development easier. user input
|
|
|
70
70
|
<tact-deck></tact-deck>
|
|
71
71
|
```
|
|
72
72
|
- 💡 *you also have each panel, `<tact-controllers>` and `<tact-customize>`.*
|
|
73
|
-
- 💡 *you can customize the colors with css
|
|
73
|
+
- 💡 *you can customize the colors with css.*
|
|
74
74
|
```html
|
|
75
75
|
<style>
|
|
76
76
|
html {
|
|
@@ -107,8 +107,8 @@ i made tact because i want to make indie web game development easier. user input
|
|
|
107
107
|
}
|
|
108
108
|
}, 16.67)
|
|
109
109
|
```
|
|
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!).*
|
|
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!).*
|
|
112
112
|
|
|
113
113
|
|
|
114
114
|
|
|
@@ -116,19 +116,39 @@ i made tact because i want to make indie web game development easier. user input
|
|
|
116
116
|
|
|
117
117
|
## 🎮 get down to brass tacks.
|
|
118
118
|
|
|
119
|
-
- 🍏 **
|
|
119
|
+
- 🍏 **pov: your app isn't a game, no multiplayer, no gamepads.**
|
|
120
120
|
```ts
|
|
121
|
-
import {
|
|
121
|
+
import {setupTact, InputDecoder} from "@benev/tact"
|
|
122
122
|
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
const tact = await setupTact({presets, maxPlayers: 1})
|
|
124
|
+
const controller = tact.mouseKeyboard()
|
|
125
|
+
const decoder = new InputDecoder(bindings)
|
|
126
|
+
tact.registerElements()
|
|
127
|
+
|
|
128
|
+
setInterval(() => {
|
|
129
|
+
const inputs = decoder.decode(controller.encode())
|
|
130
|
+
|
|
131
|
+
// 🧙♂️ handle your inputs.
|
|
132
|
+
inputs.jump.value
|
|
133
|
+
|
|
134
|
+
}, 16.67)
|
|
135
|
+
```
|
|
136
|
+
- 💡 *then the only ui you need is the `<tact-customize>` panel (also available as a sly view `CustomizeView`).*
|
|
137
|
+
- 🍏 **pov: your app doesn't even want any ui, or persistence.**
|
|
138
|
+
```ts
|
|
139
|
+
import {Controller, InputDecoder, KeyboardSource, PointerSource, Sources} from "@benev/tact"
|
|
127
140
|
|
|
141
|
+
const source = new Sources(new KeyboardSource(), new PointerSource())
|
|
142
|
+
const controller = new Controller({bindings, source})
|
|
128
143
|
const decoder = new InputDecoder(bindings)
|
|
129
144
|
|
|
130
|
-
|
|
131
|
-
|
|
145
|
+
setInterval(() => {
|
|
146
|
+
const inputs = decoder.decode(controller.encode())
|
|
147
|
+
|
|
148
|
+
// 🧙♂️ handle your inputs.
|
|
149
|
+
inputs.jump.value
|
|
150
|
+
|
|
151
|
+
}, 16.67)
|
|
132
152
|
```
|
|
133
153
|
|
|
134
154
|
|
package/package.json
CHANGED
package/x/gamepad/index.html
CHANGED