@benev/tact 0.1.0-3 → 0.1.0-4
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 +111 -103
- package/package.json +7 -7
- package/s/core/bindings/action.ts +14 -4
- package/s/core/bindings/parts/defaults.ts +3 -1
- package/s/core/bindings/parts/lens-algo.ts +17 -13
- package/s/core/bindings/resolver.ts +12 -12
- package/s/core/bindings/sample-map.ts +25 -0
- package/s/core/bindings/types.ts +3 -1
- package/s/core/core.test.ts +46 -34
- package/s/core/devices/auto-gamepads.ts +8 -0
- package/s/core/devices/device.ts +12 -0
- package/s/core/devices/infra/group.ts +24 -0
- package/s/core/devices/infra/sampler.ts +22 -0
- package/s/core/devices/standard/gamepad.ts +83 -0
- package/s/core/{controllers → devices}/standard/index.ts +2 -1
- package/s/core/devices/standard/keyboard.ts +31 -0
- package/s/core/{controllers → devices}/standard/pointer.ts +15 -11
- package/s/core/devices/standard/primary.ts +20 -0
- package/s/core/devices/standard/stick.ts +27 -0
- package/s/core/{controllers/standard/virtual-gamepad.ts → devices/standard/vpad.ts} +9 -9
- package/s/core/{controllers → devices}/types.ts +0 -1
- package/s/core/hub/hub.ts +78 -62
- package/s/core/hub/meta-bindings.ts +23 -0
- package/s/core/hub/parts/connected.ts +15 -0
- package/s/core/hub/port.ts +26 -0
- package/s/core/hub/types.ts +5 -6
- package/s/core/index.ts +12 -14
- package/s/core/testing/testing.ts +19 -14
- package/s/deck/deck.ts +77 -0
- package/s/deck/index.ts +14 -0
- package/s/deck/parts/catalog.ts +58 -0
- package/s/deck/parts/db.ts +66 -0
- package/s/deck/parts/device-skins/device-icons.ts +38 -0
- package/s/deck/parts/device-skins/device-skin.ts +29 -0
- package/s/deck/parts/local-storage-kv.ts +8 -0
- package/s/deck/parts/merge-bindings.ts +21 -0
- package/s/deck/parts/overlay-visibility.ts +49 -0
- package/s/deck/views/deck-overlay/component.ts +48 -0
- package/s/deck/views/deck-overlay/style.css.ts +112 -0
- package/s/deck/views/framework.ts +14 -0
- package/s/demo/game/game.ts +85 -0
- package/s/demo/game/parts/agent.ts +10 -0
- package/s/demo/game/parts/game-bindings.ts +20 -0
- package/s/demo/game/parts/logic.ts +24 -0
- package/s/demo/game/parts/player.ts +32 -0
- package/s/demo/game/parts/renderer.ts +113 -0
- package/s/demo/game/parts/state.ts +24 -0
- package/s/demo/game/parts/virtual-device.ts +13 -0
- package/s/demo/main.bundle.ts +6 -12
- package/s/demo/main.css +30 -2
- package/s/demo/ui/tact-demo/component.ts +13 -0
- package/s/demo/ui/tact-demo/style.css.ts +4 -0
- package/s/demo/ui/theater/styles.css.ts +57 -0
- package/s/demo/ui/theater/view.ts +53 -0
- package/s/demo/ui/theater/virtual/style.css.ts +43 -0
- package/s/demo/ui/theater/virtual/view.ts +31 -0
- package/s/demo/ui/utils/loader.ts +5 -0
- package/s/index.html.ts +16 -6
- package/s/index.ts +3 -1
- package/s/nubs/components.ts +14 -0
- package/s/nubs/index.ts +6 -0
- package/s/nubs/lookpad/component.ts +45 -0
- package/s/nubs/stick/component.ts +115 -0
- package/s/nubs/stick/style.css.ts +70 -0
- package/s/nubs/{virtual-gamepad/view.ts → vpad/component.ts} +21 -11
- package/s/nubs/{virtual-gamepad → vpad}/styles.css.ts +1 -0
- package/s/utils/circular-clamp.ts +15 -0
- package/s/utils/dispensers.ts +20 -0
- package/s/utils/split-axis.ts +10 -2
- package/x/core/bindings/action.d.ts +3 -1
- package/x/core/bindings/action.js +12 -4
- package/x/core/bindings/action.js.map +1 -1
- package/x/core/bindings/parts/defaults.js +3 -1
- package/x/core/bindings/parts/defaults.js.map +1 -1
- package/x/core/bindings/parts/lens-algo.js +14 -7
- package/x/core/bindings/parts/lens-algo.js.map +1 -1
- package/x/core/bindings/resolver.d.ts +5 -4
- package/x/core/bindings/resolver.js +12 -10
- package/x/core/bindings/resolver.js.map +1 -1
- package/x/core/bindings/sample-map.d.ts +7 -0
- package/x/core/bindings/sample-map.js +22 -0
- package/x/core/bindings/sample-map.js.map +1 -0
- package/x/core/bindings/types.d.ts +3 -1
- package/x/core/core.test.d.ts +5 -4
- package/x/core/core.test.js +45 -34
- package/x/core/core.test.js.map +1 -1
- package/x/core/devices/auto-gamepads.d.ts +2 -0
- package/x/core/devices/auto-gamepads.js +6 -0
- package/x/core/devices/auto-gamepads.js.map +1 -0
- package/x/core/devices/device.d.ts +5 -0
- package/x/core/devices/device.js +7 -0
- package/x/core/devices/device.js.map +1 -0
- package/x/core/devices/infra/group.d.ts +8 -0
- package/x/core/devices/infra/group.js +21 -0
- package/x/core/devices/infra/group.js.map +1 -0
- package/x/core/devices/infra/sampler.d.ts +9 -0
- package/x/core/devices/infra/sampler.js +18 -0
- package/x/core/devices/infra/sampler.js.map +1 -0
- package/x/core/devices/standard/gamepad.d.ts +11 -0
- package/x/core/devices/standard/gamepad.js +65 -0
- package/x/core/devices/standard/gamepad.js.map +1 -0
- package/x/core/{controllers → devices}/standard/index.d.ts +2 -1
- package/x/core/{controllers → devices}/standard/index.js +2 -1
- package/x/core/devices/standard/index.js.map +1 -0
- package/x/core/devices/standard/keyboard.d.ts +9 -0
- package/x/core/devices/standard/keyboard.js +28 -0
- package/x/core/devices/standard/keyboard.js.map +1 -0
- package/x/core/devices/standard/pointer.d.ts +15 -0
- package/x/core/{controllers → devices}/standard/pointer.js +14 -11
- package/x/core/devices/standard/pointer.js.map +1 -0
- package/x/core/devices/standard/primary.d.ts +10 -0
- package/x/core/devices/standard/primary.js +17 -0
- package/x/core/devices/standard/primary.js.map +1 -0
- package/x/core/devices/standard/stick.d.ts +15 -0
- package/x/core/devices/standard/stick.js +24 -0
- package/x/core/devices/standard/stick.js.map +1 -0
- package/x/core/devices/standard/vpad.d.ts +7 -0
- package/x/core/{controllers/standard/virtual-gamepad.js → devices/standard/vpad.js} +10 -10
- package/x/core/devices/standard/vpad.js.map +1 -0
- package/x/core/{controllers → devices}/types.d.ts +0 -1
- package/x/core/{controllers → devices}/types.js.map +1 -1
- package/x/core/hub/hub.d.ts +27 -23
- package/x/core/hub/hub.js +71 -61
- package/x/core/hub/hub.js.map +1 -1
- package/x/core/hub/meta-bindings.d.ts +2 -0
- package/x/core/hub/meta-bindings.js +21 -0
- package/x/core/hub/meta-bindings.js.map +1 -0
- package/x/core/hub/parts/connected.d.ts +14 -0
- package/x/core/hub/parts/connected.js +12 -0
- package/x/core/hub/parts/connected.js.map +1 -0
- package/x/core/hub/port.d.ts +10 -0
- package/x/core/hub/port.js +19 -0
- package/x/core/hub/port.js.map +1 -0
- package/x/core/hub/types.d.ts +5 -5
- package/x/core/hub/types.js +1 -1
- package/x/core/hub/types.js.map +1 -1
- package/x/core/index.d.ts +12 -12
- package/x/core/index.js +12 -12
- package/x/core/index.js.map +1 -1
- package/x/core/testing/testing.d.ts +13 -11
- package/x/core/testing/testing.js +14 -13
- package/x/core/testing/testing.js.map +1 -1
- package/x/deck/deck.d.ts +35 -0
- package/x/deck/deck.js +50 -0
- package/x/deck/deck.js.map +1 -0
- package/x/deck/index.d.ts +10 -0
- package/x/deck/index.js +11 -0
- package/x/deck/index.js.map +1 -0
- package/x/deck/parts/catalog.d.ts +23 -0
- package/x/deck/parts/catalog.js +35 -0
- package/x/deck/parts/catalog.js.map +1 -0
- package/x/deck/parts/db.d.ts +20 -0
- package/x/deck/parts/db.js +52 -0
- package/x/deck/parts/db.js.map +1 -0
- package/x/deck/parts/device-skins/device-icons.d.ts +12 -0
- package/x/deck/parts/device-skins/device-icons.js +27 -0
- package/x/deck/parts/device-skins/device-icons.js.map +1 -0
- package/x/deck/parts/device-skins/device-skin.d.ts +14 -0
- package/x/deck/parts/device-skins/device-skin.js +22 -0
- package/x/deck/parts/device-skins/device-skin.js.map +1 -0
- package/x/deck/parts/local-storage-kv.js +6 -0
- package/x/deck/parts/local-storage-kv.js.map +1 -0
- package/x/deck/parts/merge-bindings.d.ts +2 -0
- package/x/deck/parts/merge-bindings.js +15 -0
- package/x/deck/parts/merge-bindings.js.map +1 -0
- package/x/deck/parts/overlay-visibility.d.ts +21 -0
- package/x/deck/parts/overlay-visibility.js +35 -0
- package/x/deck/parts/overlay-visibility.js.map +1 -0
- package/x/deck/views/deck-overlay/component.d.ts +2 -0
- package/x/deck/views/deck-overlay/component.js +40 -0
- package/x/deck/views/deck-overlay/component.js.map +1 -0
- package/x/deck/views/deck-overlay/style.css.js +109 -0
- package/x/deck/views/deck-overlay/style.css.js.map +1 -0
- package/x/deck/views/framework.d.ts +3 -0
- package/x/deck/views/framework.js +8 -0
- package/x/deck/views/framework.js.map +1 -0
- package/x/demo/game/game.d.ts +20 -0
- package/x/demo/game/game.js +63 -0
- package/x/demo/game/game.js.map +1 -0
- package/x/demo/game/parts/agent.d.ts +7 -0
- package/x/demo/game/parts/agent.js +8 -0
- package/x/demo/game/parts/agent.js.map +1 -0
- package/x/demo/game/parts/game-bindings.d.ts +15 -0
- package/x/demo/game/parts/game-bindings.js +10 -0
- package/x/demo/game/parts/game-bindings.js.map +1 -0
- package/x/demo/game/parts/logic.d.ts +8 -0
- package/x/demo/game/parts/logic.js +21 -0
- package/x/demo/game/parts/logic.js.map +1 -0
- package/x/demo/game/parts/player.d.ts +14 -0
- package/x/demo/game/parts/player.js +26 -0
- package/x/demo/game/parts/player.js.map +1 -0
- package/x/demo/game/parts/renderer.d.ts +13 -0
- package/x/demo/game/parts/renderer.js +91 -0
- package/x/demo/game/parts/renderer.js.map +1 -0
- package/x/demo/game/parts/state.d.ts +8 -0
- package/x/demo/game/parts/state.js +20 -0
- package/x/demo/game/parts/state.js.map +1 -0
- package/x/demo/game/parts/virtual-device.d.ts +8 -0
- package/x/demo/game/parts/virtual-device.js +11 -0
- package/x/demo/game/parts/virtual-device.js.map +1 -0
- package/x/demo/main.bundle.js +4 -10
- package/x/demo/main.bundle.js.map +1 -1
- package/x/demo/main.bundle.min.js +315 -54
- package/x/demo/main.bundle.min.js.map +4 -4
- package/x/demo/main.css +30 -2
- package/x/demo/ui/tact-demo/component.d.ts +4 -0
- package/x/demo/ui/tact-demo/component.js +12 -0
- package/x/demo/ui/tact-demo/component.js.map +1 -0
- package/x/demo/ui/tact-demo/style.css.d.ts +2 -0
- package/x/demo/ui/tact-demo/style.css.js +3 -0
- package/x/demo/ui/tact-demo/style.css.js.map +1 -0
- package/x/demo/ui/theater/styles.css.js +56 -0
- package/x/demo/ui/theater/styles.css.js.map +1 -0
- package/x/demo/ui/theater/view.d.ts +2 -0
- package/x/demo/ui/theater/view.js +42 -0
- package/x/demo/ui/theater/view.js.map +1 -0
- package/x/demo/ui/theater/virtual/style.css.d.ts +2 -0
- package/x/demo/ui/theater/virtual/style.css.js +42 -0
- package/x/demo/ui/theater/virtual/style.css.js.map +1 -0
- package/x/demo/ui/theater/virtual/view.d.ts +4 -0
- package/x/demo/ui/theater/virtual/view.js +19 -0
- package/x/demo/ui/theater/virtual/view.js.map +1 -0
- package/x/demo/ui/utils/loader.d.ts +1 -0
- package/x/demo/ui/utils/loader.js +3 -0
- package/x/demo/ui/utils/loader.js.map +1 -0
- package/x/index.d.ts +3 -1
- package/x/index.html +47 -8
- package/x/index.html.js +16 -6
- package/x/index.html.js.map +1 -1
- package/x/index.js +3 -1
- package/x/index.js.map +1 -1
- package/x/nubs/components.d.ts +9 -0
- package/x/nubs/components.js +11 -0
- package/x/nubs/components.js.map +1 -0
- package/x/nubs/index.d.ts +4 -0
- package/x/nubs/index.js +5 -0
- package/x/nubs/index.js.map +1 -0
- package/x/nubs/lookpad/component.d.ts +4 -0
- package/x/nubs/lookpad/component.js +36 -0
- package/x/nubs/lookpad/component.js.map +1 -0
- package/x/nubs/stick/component.d.ts +368 -0
- package/x/nubs/stick/component.js +101 -0
- package/x/nubs/stick/component.js.map +1 -0
- package/x/nubs/stick/style.css.d.ts +2 -0
- package/x/nubs/stick/style.css.js +69 -0
- package/x/nubs/stick/style.css.js.map +1 -0
- package/x/nubs/vpad/component.d.ts +368 -0
- package/x/nubs/{virtual-gamepad/view.js → vpad/component.js} +20 -11
- package/x/nubs/vpad/component.js.map +1 -0
- package/x/nubs/vpad/styles.css.d.ts +2 -0
- package/x/nubs/vpad/styles.css.js.map +1 -0
- package/x/nubs/vpad/utils/gamepad-inputs.js.map +1 -0
- package/x/nubs/vpad/utils/prevent-default-touch-shenanigans.js.map +1 -0
- package/x/nubs/vpad/utils/touch-tracking.js.map +1 -0
- package/x/utils/circular-clamp.d.ts +2 -0
- package/x/utils/circular-clamp.js +8 -0
- package/x/utils/circular-clamp.js.map +1 -0
- package/x/utils/dispensers.d.ts +7 -0
- package/x/utils/dispensers.js +16 -0
- package/x/utils/dispensers.js.map +1 -0
- package/x/utils/split-axis.d.ts +7 -0
- package/x/utils/split-axis.js +7 -2
- package/x/utils/split-axis.js.map +1 -1
- package/s/core/controllers/controller.ts +0 -7
- package/s/core/controllers/infra/group.ts +0 -17
- package/s/core/controllers/infra/sampler.ts +0 -22
- package/s/core/controllers/standard/gamepad.ts +0 -77
- package/s/core/controllers/standard/keyboard.ts +0 -50
- package/s/core/controllers/standard/stick.ts +0 -30
- package/s/core/deck/deck.ts +0 -40
- package/s/core/deck/parts/bindings-depot.ts +0 -24
- package/s/core/deck/parts/local-storage-kv.ts +0 -7
- package/s/core/hub/auto-gamepads.ts +0 -8
- package/s/core/hub/bindings.ts +0 -18
- package/s/core/port/port.ts +0 -34
- package/s/core/port/utils/aggregate_samples_into_map.ts +0 -20
- package/s/core/port/utils/wipe_samples_map.ts +0 -8
- package/s/nubs/lookpad/utils/listeners.ts +0 -53
- package/s/nubs/lookpad/view.ts +0 -32
- package/s/nubs/stick/styles.ts +0 -22
- package/s/nubs/stick/utils/calculate_new_vector_from_pointer_position.ts +0 -27
- package/s/nubs/stick/utils/find_closest_point_on_circle.ts +0 -15
- package/s/nubs/stick/utils/make_pointer_listeners.ts +0 -50
- package/s/nubs/stick/utils/within_radius.ts +0 -6
- package/s/nubs/stick/view.ts +0 -50
- package/s/nubs/stick-graphic/styles.ts +0 -38
- package/s/nubs/stick-graphic/types/basis.ts +0 -5
- package/s/nubs/stick-graphic/utils/calculate_basis.ts +0 -19
- package/s/nubs/stick-graphic/utils/stick_vector_to_pixels.ts +0 -13
- package/s/nubs/stick-graphic/utils/transform.ts +0 -10
- package/s/nubs/stick-graphic/view.ts +0 -43
- package/x/core/controllers/controller.d.ts +0 -4
- package/x/core/controllers/controller.js +0 -3
- package/x/core/controllers/controller.js.map +0 -1
- package/x/core/controllers/infra/group.d.ts +0 -7
- package/x/core/controllers/infra/group.js +0 -13
- package/x/core/controllers/infra/group.js.map +0 -1
- package/x/core/controllers/infra/sampler.d.ts +0 -8
- package/x/core/controllers/infra/sampler.js +0 -17
- package/x/core/controllers/infra/sampler.js.map +0 -1
- package/x/core/controllers/standard/gamepad.d.ts +0 -9
- package/x/core/controllers/standard/gamepad.js +0 -66
- package/x/core/controllers/standard/gamepad.js.map +0 -1
- package/x/core/controllers/standard/index.js.map +0 -1
- package/x/core/controllers/standard/keyboard.d.ts +0 -9
- package/x/core/controllers/standard/keyboard.js +0 -39
- package/x/core/controllers/standard/keyboard.js.map +0 -1
- package/x/core/controllers/standard/pointer.d.ts +0 -11
- package/x/core/controllers/standard/pointer.js.map +0 -1
- package/x/core/controllers/standard/stick.d.ts +0 -15
- package/x/core/controllers/standard/stick.js +0 -27
- package/x/core/controllers/standard/stick.js.map +0 -1
- package/x/core/controllers/standard/virtual-gamepad.d.ts +0 -7
- package/x/core/controllers/standard/virtual-gamepad.js.map +0 -1
- package/x/core/deck/deck.d.ts +0 -16
- package/x/core/deck/deck.js +0 -31
- package/x/core/deck/deck.js.map +0 -1
- package/x/core/deck/parts/bindings-depot.d.ts +0 -9
- package/x/core/deck/parts/bindings-depot.js +0 -19
- package/x/core/deck/parts/bindings-depot.js.map +0 -1
- package/x/core/deck/parts/local-storage-kv.js +0 -5
- package/x/core/deck/parts/local-storage-kv.js.map +0 -1
- package/x/core/hub/auto-gamepads.d.ts +0 -2
- package/x/core/hub/auto-gamepads.js +0 -6
- package/x/core/hub/auto-gamepads.js.map +0 -1
- package/x/core/hub/bindings.d.ts +0 -2
- package/x/core/hub/bindings.js +0 -16
- package/x/core/hub/bindings.js.map +0 -1
- package/x/core/port/port.d.ts +0 -12
- package/x/core/port/port.js +0 -25
- package/x/core/port/port.js.map +0 -1
- package/x/core/port/utils/aggregate_samples_into_map.d.ts +0 -3
- package/x/core/port/utils/aggregate_samples_into_map.js +0 -11
- package/x/core/port/utils/aggregate_samples_into_map.js.map +0 -1
- package/x/core/port/utils/wipe_samples_map.d.ts +0 -2
- package/x/core/port/utils/wipe_samples_map.js +0 -5
- package/x/core/port/utils/wipe_samples_map.js.map +0 -1
- package/x/nubs/lookpad/utils/listeners.d.ts +0 -19
- package/x/nubs/lookpad/utils/listeners.js +0 -37
- package/x/nubs/lookpad/utils/listeners.js.map +0 -1
- package/x/nubs/lookpad/view.d.ts +0 -1
- package/x/nubs/lookpad/view.js +0 -24
- package/x/nubs/lookpad/view.js.map +0 -1
- package/x/nubs/stick/styles.d.ts +0 -1
- package/x/nubs/stick/styles.js +0 -22
- package/x/nubs/stick/styles.js.map +0 -1
- package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.d.ts +0 -3
- package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.js +0 -16
- package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.js.map +0 -1
- package/x/nubs/stick/utils/find_closest_point_on_circle.d.ts +0 -2
- package/x/nubs/stick/utils/find_closest_point_on_circle.js +0 -6
- package/x/nubs/stick/utils/find_closest_point_on_circle.js.map +0 -1
- package/x/nubs/stick/utils/make_pointer_listeners.d.ts +0 -16
- package/x/nubs/stick/utils/make_pointer_listeners.js +0 -34
- package/x/nubs/stick/utils/make_pointer_listeners.js.map +0 -1
- package/x/nubs/stick/utils/within_radius.d.ts +0 -2
- package/x/nubs/stick/utils/within_radius.js +0 -4
- package/x/nubs/stick/utils/within_radius.js.map +0 -1
- package/x/nubs/stick/view.d.ts +0 -2
- package/x/nubs/stick/view.js +0 -38
- package/x/nubs/stick/view.js.map +0 -1
- package/x/nubs/stick-graphic/styles.js +0 -38
- package/x/nubs/stick-graphic/styles.js.map +0 -1
- package/x/nubs/stick-graphic/types/basis.d.ts +0 -4
- package/x/nubs/stick-graphic/types/basis.js +0 -2
- package/x/nubs/stick-graphic/types/basis.js.map +0 -1
- package/x/nubs/stick-graphic/utils/calculate_basis.d.ts +0 -2
- package/x/nubs/stick-graphic/utils/calculate_basis.js +0 -10
- package/x/nubs/stick-graphic/utils/calculate_basis.js.map +0 -1
- package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.d.ts +0 -2
- package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.js +0 -7
- package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.js.map +0 -1
- package/x/nubs/stick-graphic/utils/transform.d.ts +0 -2
- package/x/nubs/stick-graphic/utils/transform.js +0 -7
- package/x/nubs/stick-graphic/utils/transform.js.map +0 -1
- package/x/nubs/stick-graphic/view.d.ts +0 -3
- package/x/nubs/stick-graphic/view.js +0 -30
- package/x/nubs/stick-graphic/view.js.map +0 -1
- package/x/nubs/virtual-gamepad/styles.css.js.map +0 -1
- package/x/nubs/virtual-gamepad/utils/gamepad-inputs.js.map +0 -1
- package/x/nubs/virtual-gamepad/utils/prevent-default-touch-shenanigans.js.map +0 -1
- package/x/nubs/virtual-gamepad/utils/touch-tracking.js.map +0 -1
- package/x/nubs/virtual-gamepad/view.d.ts +0 -2
- package/x/nubs/virtual-gamepad/view.js.map +0 -1
- /package/s/nubs/{virtual-gamepad → vpad}/utils/gamepad-inputs.ts +0 -0
- /package/s/nubs/{virtual-gamepad → vpad}/utils/prevent-default-touch-shenanigans.ts +0 -0
- /package/s/nubs/{virtual-gamepad → vpad}/utils/touch-tracking.ts +0 -0
- /package/x/core/{controllers → devices}/types.js +0 -0
- /package/x/{core/deck → deck}/parts/local-storage-kv.d.ts +0 -0
- /package/x/{nubs/virtual-gamepad/styles.css.d.ts → deck/views/deck-overlay/style.css.d.ts} +0 -0
- /package/x/{nubs/stick-graphic/styles.d.ts → demo/ui/theater/styles.css.d.ts} +0 -0
- /package/x/nubs/{virtual-gamepad → vpad}/styles.css.js +0 -0
- /package/x/nubs/{virtual-gamepad → vpad}/utils/gamepad-inputs.d.ts +0 -0
- /package/x/nubs/{virtual-gamepad → vpad}/utils/gamepad-inputs.js +0 -0
- /package/x/nubs/{virtual-gamepad → vpad}/utils/prevent-default-touch-shenanigans.d.ts +0 -0
- /package/x/nubs/{virtual-gamepad → vpad}/utils/prevent-default-touch-shenanigans.js +0 -0
- /package/x/nubs/{virtual-gamepad → vpad}/utils/touch-tracking.d.ts +0 -0
- /package/x/nubs/{virtual-gamepad → vpad}/utils/touch-tracking.js +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
|
|
2
|
+
import {css} from "lit"
|
|
3
|
+
export default css`
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
--gap: 0.3em;
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
cursor: default;
|
|
9
|
+
user-select: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.portlist {
|
|
13
|
+
pointer-events: none;
|
|
14
|
+
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: start;
|
|
17
|
+
|
|
18
|
+
width: max-content;
|
|
19
|
+
gap: var(--gap);
|
|
20
|
+
padding: 0.5em;
|
|
21
|
+
|
|
22
|
+
color: #fff8;
|
|
23
|
+
background: #222a;
|
|
24
|
+
border-radius: 1em;
|
|
25
|
+
|
|
26
|
+
opacity: 0;
|
|
27
|
+
transition: opacity 300ms linear;
|
|
28
|
+
|
|
29
|
+
&[data-active] {
|
|
30
|
+
opacity: 1;
|
|
31
|
+
pointer-events: all;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.port {
|
|
35
|
+
flex: 1 0 0;
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
|
|
39
|
+
min-width: 6em;
|
|
40
|
+
gap: var(--gap);
|
|
41
|
+
|
|
42
|
+
> * {
|
|
43
|
+
color: white;
|
|
44
|
+
font-weight: bold;
|
|
45
|
+
text-shadow: 0.05em 0.05em 0.1em #0008;
|
|
46
|
+
text-transform: uppercase;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
header {
|
|
50
|
+
text-align: center;
|
|
51
|
+
color: #fff8;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.device {
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
gap: var(--gap);
|
|
58
|
+
|
|
59
|
+
box-shadow: 0.1em 0.2em 0.7em #0004;
|
|
60
|
+
background: color-mix(in srgb, #fffa, var(--color) 50%);
|
|
61
|
+
border-top: 2px solid #fff8;
|
|
62
|
+
border-bottom: 2px solid #0004;
|
|
63
|
+
border-radius: 0.5em;
|
|
64
|
+
|
|
65
|
+
.row {
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
|
|
69
|
+
&.primary {
|
|
70
|
+
justify-content: space-between;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&.secondary {
|
|
74
|
+
justify-content: center;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.icon {
|
|
79
|
+
font-size: 1.5em;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.label {
|
|
83
|
+
font-family: monospace;
|
|
84
|
+
font-size: 0.8em;
|
|
85
|
+
opacity: 0.5;
|
|
86
|
+
line-height: 0.9em;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
button {
|
|
90
|
+
opacity: 0.2;
|
|
91
|
+
cursor: pointer;
|
|
92
|
+
padding: 0 0.2em;
|
|
93
|
+
font-family: monospace;
|
|
94
|
+
font-size: 1.5em;
|
|
95
|
+
font-weight: bold;
|
|
96
|
+
|
|
97
|
+
background: transparent;
|
|
98
|
+
border: 1px solid transparent;
|
|
99
|
+
text-shadow: inherit;
|
|
100
|
+
|
|
101
|
+
&:is(:hover, :focus-visible) {
|
|
102
|
+
opacity: 1;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
`
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
import {Content, Use, view} from "@e280/sly"
|
|
3
|
+
import {Deck} from "../deck.js"
|
|
4
|
+
|
|
5
|
+
export function deckView(
|
|
6
|
+
fn: (deck: Deck<any>) => (use: Use) => Content
|
|
7
|
+
) {
|
|
8
|
+
|
|
9
|
+
return (deck: Deck<any>) => {
|
|
10
|
+
const fn2 = fn(deck)
|
|
11
|
+
return view(use => () => fn2(use))
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
|
|
2
|
+
import {disposer, nap, repeat} from "@e280/stz"
|
|
3
|
+
import {Logic} from "./parts/logic.js"
|
|
4
|
+
import {State} from "./parts/state.js"
|
|
5
|
+
import {Deck} from "../../deck/deck.js"
|
|
6
|
+
import {Players} from "./parts/player.js"
|
|
7
|
+
import {Renderer} from "./parts/renderer.js"
|
|
8
|
+
import {Device} from "../../core/devices/device.js"
|
|
9
|
+
import {VirtualDevice} from "./parts/virtual-device.js"
|
|
10
|
+
import {gameBindings, GameDeck} from "./parts/game-bindings.js"
|
|
11
|
+
import {autoGamepads} from "../../core/devices/auto-gamepads.js"
|
|
12
|
+
import {localStorageKv} from "../../deck/parts/local-storage-kv.js"
|
|
13
|
+
import {PrimaryDevice} from "../../core/devices/standard/primary.js"
|
|
14
|
+
|
|
15
|
+
export class Game {
|
|
16
|
+
static async load() {
|
|
17
|
+
return new this(
|
|
18
|
+
await Deck.load({
|
|
19
|
+
portCount: 4,
|
|
20
|
+
kv: localStorageKv(),
|
|
21
|
+
bindings: gameBindings,
|
|
22
|
+
})
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
logic: Logic
|
|
27
|
+
dispose = disposer()
|
|
28
|
+
state = new State()
|
|
29
|
+
renderer = new Renderer(this.state)
|
|
30
|
+
|
|
31
|
+
constructor(public deck: GameDeck) {
|
|
32
|
+
|
|
33
|
+
// add an icon for our demo virtual device
|
|
34
|
+
this.deck.deviceSkins.icons.add(
|
|
35
|
+
[VirtualDevice, "🔘"],
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
// establish game logic
|
|
39
|
+
this.logic = new Logic(
|
|
40
|
+
this.state,
|
|
41
|
+
new Players(deck.hub, this.state),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
// on hub update, set agent.alive based on port status
|
|
45
|
+
this.dispose.schedule(
|
|
46
|
+
this.deck.hub.on(() => {
|
|
47
|
+
for (const player of this.logic.players) {
|
|
48
|
+
player.agent.alive = player.port.devices.size > 0
|
|
49
|
+
const [firstDevice] = player.port.devices
|
|
50
|
+
player.agent.color = firstDevice
|
|
51
|
+
? this.deck.deviceSkins.get(firstDevice).color
|
|
52
|
+
: "#444"
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
// plug in initial devices
|
|
58
|
+
this.plug(new PrimaryDevice())
|
|
59
|
+
this.plug(new VirtualDevice(deck.hub))
|
|
60
|
+
|
|
61
|
+
// dynamically plug in detected gamepads
|
|
62
|
+
this.dispose.schedule(
|
|
63
|
+
autoGamepads(deck.hub.plug)
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
plug(device: Device) {
|
|
68
|
+
this.deck.hub.plug(device)
|
|
69
|
+
return () => this.unplug(device)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
unplug(device: Device) {
|
|
73
|
+
this.deck.hub.unplug(device)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
loop(hz: number) {
|
|
77
|
+
return repeat(async() => {
|
|
78
|
+
await nap(1000 / hz)
|
|
79
|
+
this.deck.hub.poll()
|
|
80
|
+
this.logic.tick()
|
|
81
|
+
this.renderer.render()
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import {Deck} from "../../../deck/deck.js"
|
|
3
|
+
import {Hub} from "../../../core/hub/hub.js"
|
|
4
|
+
import {Port} from "../../../core/hub/port.js"
|
|
5
|
+
import {asBindings} from "../../../core/bindings/types.js"
|
|
6
|
+
|
|
7
|
+
export type GameBindings = typeof gameBindings
|
|
8
|
+
export type GamePort = Port<GameBindings>
|
|
9
|
+
export type GameDeck = Deck<GameBindings>
|
|
10
|
+
export type GameHub = Hub<GameBindings>
|
|
11
|
+
|
|
12
|
+
export const gameBindings = asBindings({
|
|
13
|
+
gameplay: {
|
|
14
|
+
up: ["or", "KeyW", "ArrowUp", "stick.up", "gamepad.stick.left.up", "gamepad.stick.right.up"],
|
|
15
|
+
down: ["or", "KeyS", "ArrowDown", "stick.down", "gamepad.stick.left.down", "gamepad.stick.right.down"],
|
|
16
|
+
left: ["or", "KeyA", "ArrowLeft", "stick.left", "gamepad.stick.left.left", "gamepad.stick.right.left"],
|
|
17
|
+
right: ["or", "KeyD", "ArrowRight", "stick.right", "gamepad.stick.left.right", "gamepad.stick.right.right"],
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
import {Vec2} from "@benev/math"
|
|
3
|
+
import {State} from "./state.js"
|
|
4
|
+
import {Players} from "./player.js"
|
|
5
|
+
|
|
6
|
+
export class Logic {
|
|
7
|
+
constructor(
|
|
8
|
+
public state: State,
|
|
9
|
+
public players: Players,
|
|
10
|
+
) {}
|
|
11
|
+
|
|
12
|
+
tick() {
|
|
13
|
+
for (const player of this.players) {
|
|
14
|
+
const {agent, port: {actions}} = player
|
|
15
|
+
const speed = 1
|
|
16
|
+
agent.position.y += speed * actions.gameplay.up.value
|
|
17
|
+
agent.position.y -= speed * actions.gameplay.down.value
|
|
18
|
+
agent.position.x -= speed * actions.gameplay.left.value
|
|
19
|
+
agent.position.x += speed * actions.gameplay.right.value
|
|
20
|
+
agent.position.clamp(Vec2.zero(), this.state.arenaSize)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
import {MapG} from "@e280/stz"
|
|
3
|
+
import {Agent} from "./agent.js"
|
|
4
|
+
import {State} from "./state.js"
|
|
5
|
+
import {GameHub, GamePort} from "./game-bindings.js"
|
|
6
|
+
|
|
7
|
+
export class Player {
|
|
8
|
+
constructor(
|
|
9
|
+
public port: GamePort,
|
|
10
|
+
public agent: Agent,
|
|
11
|
+
) {}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class Players {
|
|
15
|
+
#map = new MapG<GamePort, Player>()
|
|
16
|
+
|
|
17
|
+
constructor(hub: GameHub, state: State) {
|
|
18
|
+
for (const [index, port] of hub.ports.entries()) {
|
|
19
|
+
const label = (index + 1).toString()
|
|
20
|
+
this.#map.set(port, new Player(port, state.makeAgent(label)))
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
;[Symbol.iterator]() {
|
|
25
|
+
return this.#map.values()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
require(port: GamePort) {
|
|
29
|
+
return this.#map.require(port)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
|
|
2
|
+
import {Vec2} from "@benev/math"
|
|
3
|
+
import {Agent} from "./agent.js"
|
|
4
|
+
import {State} from "./state.js"
|
|
5
|
+
|
|
6
|
+
export class Renderer {
|
|
7
|
+
canvas = (() => {
|
|
8
|
+
const canvas = document.createElement("canvas")
|
|
9
|
+
canvas.width = 200
|
|
10
|
+
canvas.height = 100
|
|
11
|
+
return canvas
|
|
12
|
+
})()
|
|
13
|
+
|
|
14
|
+
ctx = this.canvas.getContext("2d")!
|
|
15
|
+
|
|
16
|
+
constructor(public state: State) {}
|
|
17
|
+
|
|
18
|
+
percent(n: number) {
|
|
19
|
+
const shorty = Math.min(this.canvas.width, this.canvas.height)
|
|
20
|
+
return Math.ceil(shorty * (n / 100))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** take a game-state position and resolve it into canvas coordinates */
|
|
24
|
+
resolve(position: Vec2) {
|
|
25
|
+
return position.clone()
|
|
26
|
+
|
|
27
|
+
// 0-1 relative to arena scale
|
|
28
|
+
.divide(this.state.arenaSize)
|
|
29
|
+
|
|
30
|
+
// flip y axis
|
|
31
|
+
.morph(v => {v.y = 1 - v.y})
|
|
32
|
+
|
|
33
|
+
// stretch to the size of the canvas
|
|
34
|
+
.multiply_(this.canvas.width, this.canvas.height)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
render() {
|
|
38
|
+
const {state} = this
|
|
39
|
+
this.#renderBackground()
|
|
40
|
+
const agents = [...state.agents].reverse()
|
|
41
|
+
const dead = agents.filter(a => !a.alive)
|
|
42
|
+
const alive = agents.filter(a => a.alive)
|
|
43
|
+
|
|
44
|
+
for (const agent of dead)
|
|
45
|
+
this.#renderDeadAgent(agent)
|
|
46
|
+
|
|
47
|
+
for (const agent of alive)
|
|
48
|
+
this.#renderAliveAgent(agent)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#getCleanCtx() {
|
|
52
|
+
const {ctx} = this
|
|
53
|
+
ctx.imageSmoothingEnabled = false
|
|
54
|
+
ctx.fillStyle = "#000"
|
|
55
|
+
ctx.strokeStyle = "#000"
|
|
56
|
+
ctx.lineWidth = 1
|
|
57
|
+
ctx.font = `10px sans-serif`
|
|
58
|
+
ctx.textAlign = "center"
|
|
59
|
+
ctx.textBaseline = "middle"
|
|
60
|
+
return ctx
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#renderBackground() {
|
|
64
|
+
const {canvas} = this
|
|
65
|
+
const ctx = this.#getCleanCtx()
|
|
66
|
+
ctx.fillStyle = "#000"
|
|
67
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#renderDeadAgent(agent: Agent) {
|
|
71
|
+
const ctx = this.#getCleanCtx()
|
|
72
|
+
|
|
73
|
+
const radius = this.percent(10)
|
|
74
|
+
const {position} = agent
|
|
75
|
+
const [x, y] = this.resolve(position)
|
|
76
|
+
|
|
77
|
+
// draw label
|
|
78
|
+
ctx.font = `${radius * 1.3}px sans-serif`
|
|
79
|
+
ctx.textAlign = "center"
|
|
80
|
+
ctx.textBaseline = "middle"
|
|
81
|
+
ctx.fillStyle = "#fff4"
|
|
82
|
+
ctx.fillText(agent.label, x, y)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
#renderAliveAgent(agent: Agent) {
|
|
86
|
+
const ctx = this.#getCleanCtx()
|
|
87
|
+
|
|
88
|
+
const radius = this.percent(10)
|
|
89
|
+
const {color, position} = agent
|
|
90
|
+
const [x, y] = this.resolve(position)
|
|
91
|
+
|
|
92
|
+
// circle
|
|
93
|
+
ctx.beginPath()
|
|
94
|
+
ctx.arc(x, y, radius, 0, Math.PI * 2)
|
|
95
|
+
ctx.fillStyle = color
|
|
96
|
+
ctx.fill()
|
|
97
|
+
|
|
98
|
+
// outline
|
|
99
|
+
ctx.lineWidth = this.percent(2)
|
|
100
|
+
ctx.strokeStyle = "#fff"
|
|
101
|
+
ctx.stroke()
|
|
102
|
+
|
|
103
|
+
// draw label
|
|
104
|
+
ctx.font = `${radius * 1.3}px sans-serif`
|
|
105
|
+
ctx.textAlign = "center"
|
|
106
|
+
ctx.textBaseline = "middle"
|
|
107
|
+
ctx.strokeStyle = "#0004"
|
|
108
|
+
ctx.strokeText(agent.label, x, y)
|
|
109
|
+
ctx.fillStyle = "#fff"
|
|
110
|
+
ctx.fillText(agent.label, x, y)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
import {Vec2} from "@benev/math"
|
|
3
|
+
import {Agent} from "./agent.js"
|
|
4
|
+
|
|
5
|
+
export class State {
|
|
6
|
+
arenaSize = new Vec2(200, 100)
|
|
7
|
+
agents = new Set<Agent>()
|
|
8
|
+
|
|
9
|
+
makeAgent(label: string) {
|
|
10
|
+
const agent = new Agent()
|
|
11
|
+
agent.label = label
|
|
12
|
+
agent.position
|
|
13
|
+
.set_(0.5, 0.5)
|
|
14
|
+
.multiply(this.arenaSize)
|
|
15
|
+
this.agents.add(agent)
|
|
16
|
+
return agent
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
deleteAgent(agent: Agent) {
|
|
20
|
+
this.agents.delete(agent)
|
|
21
|
+
return this
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import {Hub} from "../../../core/hub/hub.js"
|
|
3
|
+
import {StickDevice} from "../../../core/devices/standard/stick.js"
|
|
4
|
+
|
|
5
|
+
export class VirtualDevice extends StickDevice {
|
|
6
|
+
constructor(private hub: Hub<any>) {
|
|
7
|
+
super()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
shimmyNext = () => this.hub.shimmy(this, 1)
|
|
11
|
+
shimmyPrevious = () => this.hub.shimmy(this, -1)
|
|
12
|
+
}
|
|
13
|
+
|
package/s/demo/main.bundle.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const stick = use.once(() => new StickController())
|
|
9
|
-
return NubStick(stick)
|
|
10
|
-
}),
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
console.log("tact")
|
|
2
|
+
import {dom} from "@e280/sly"
|
|
3
|
+
import {TactDemo} from "./ui/tact-demo/component.js"
|
|
4
|
+
|
|
5
|
+
dom.register({TactDemo})
|
|
6
|
+
|
|
7
|
+
console.log("🎮 tact")
|
|
14
8
|
|
package/s/demo/main.css
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
:root {
|
|
6
6
|
color-scheme: dark;
|
|
7
7
|
--link: cyan;
|
|
8
|
+
--prime: #ccc;
|
|
8
9
|
--bg: #181818;
|
|
9
|
-
--
|
|
10
|
+
--bg2: #111111;
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
|
|
@@ -46,12 +47,39 @@
|
|
|
46
47
|
body { min-height: 100%; }
|
|
47
48
|
|
|
48
49
|
html, body {
|
|
49
|
-
font-
|
|
50
|
+
font-family: sans-serif;
|
|
51
|
+
font-size: 12px;
|
|
50
52
|
color: var(--prime);
|
|
51
53
|
background: var(--bg);
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
@layer page {
|
|
58
|
+
body {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: column;
|
|
61
|
+
align-items: center;
|
|
62
|
+
|
|
63
|
+
gap: 1em;
|
|
64
|
+
padding: 2em;
|
|
65
|
+
|
|
66
|
+
> * {
|
|
67
|
+
width: 100%;
|
|
68
|
+
max-width: 42em;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
> header {
|
|
72
|
+
padding: 0 2em;
|
|
73
|
+
h1 small { font-size: 0.6em; font-weight: normal; }
|
|
74
|
+
* + * { margin-top: 0.5em; }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
> section {
|
|
78
|
+
padding: 0 2em;
|
|
79
|
+
ul {
|
|
80
|
+
padding-left: 1em;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
56
84
|
}
|
|
57
85
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import {cssReset, view} from "@e280/sly"
|
|
3
|
+
import styleCss from "./style.css.js"
|
|
4
|
+
import {Game} from "../../game/game.js"
|
|
5
|
+
import {loader} from "../utils/loader.js"
|
|
6
|
+
import {Theater} from "../theater/view.js"
|
|
7
|
+
|
|
8
|
+
export class TactDemo extends view.component(use => {
|
|
9
|
+
use.css(cssReset, styleCss)
|
|
10
|
+
const opGame = use.op.load(async() => Game.load())
|
|
11
|
+
return loader(opGame, game => Theater(game))
|
|
12
|
+
}) {}
|
|
13
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
import {css} from "lit"
|
|
3
|
+
export const styles = css`
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
align-items: center;
|
|
9
|
+
|
|
10
|
+
gap: 1em;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.surface {
|
|
14
|
+
position: relative;
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: auto;
|
|
17
|
+
aspect-ratio: 2 / 1;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
|
|
20
|
+
background: #000;
|
|
21
|
+
border: 0.5em solid #fff4;
|
|
22
|
+
border-radius: 2em;
|
|
23
|
+
|
|
24
|
+
canvas {
|
|
25
|
+
display: block;
|
|
26
|
+
position: absolute;
|
|
27
|
+
inset: 0;
|
|
28
|
+
|
|
29
|
+
width: 100%;
|
|
30
|
+
height: 100%;
|
|
31
|
+
|
|
32
|
+
image-rendering: pixelated;
|
|
33
|
+
outline: 1px solid red;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
[deck="overlay"] {
|
|
37
|
+
position: absolute;
|
|
38
|
+
top: 10%;
|
|
39
|
+
left: 0;
|
|
40
|
+
right: 0;
|
|
41
|
+
|
|
42
|
+
display: flex;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
align-items: center;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.dlist {
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-wrap: wrap;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
align-items: center;
|
|
53
|
+
gap: 0.5em;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
`
|
|
57
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
import {html} from "lit"
|
|
3
|
+
import {cssReset, view} from "@e280/sly"
|
|
4
|
+
import {repeat} from "lit/directives/repeat.js"
|
|
5
|
+
|
|
6
|
+
import {styles} from "./styles.css.js"
|
|
7
|
+
import {Game} from "../../game/game.js"
|
|
8
|
+
import {VirtualDeviceView} from "./virtual/view.js"
|
|
9
|
+
import {VirtualDevice} from "../../game/parts/virtual-device.js"
|
|
10
|
+
|
|
11
|
+
export const Theater = view(use => (game: Game) => {
|
|
12
|
+
use.css(cssReset, styles)
|
|
13
|
+
use.mount(() => game.loop(60))
|
|
14
|
+
use.mount(() => game.deck.hub.on(use.render))
|
|
15
|
+
|
|
16
|
+
const addVirtual = () => game.plug(new VirtualDevice(game.deck.hub))
|
|
17
|
+
const revealOverlay = () => game.deck.overlayVisibility.bump()
|
|
18
|
+
|
|
19
|
+
const virtualDevices = game.deck.hub.ports
|
|
20
|
+
.flatMap(port => port.devices.array())
|
|
21
|
+
.filter(device => device instanceof VirtualDevice)
|
|
22
|
+
.map(device => ({device, skin: game.deck.deviceSkins.get(device)}))
|
|
23
|
+
.sort((a, b) => a.skin.label < b.skin.label ? -1 : 1)
|
|
24
|
+
|
|
25
|
+
return html`
|
|
26
|
+
<div class=surface>
|
|
27
|
+
${game.renderer.canvas}
|
|
28
|
+
${game.deck.views.DeckOverlay()}
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div class=dlist>
|
|
32
|
+
${repeat(
|
|
33
|
+
virtualDevices,
|
|
34
|
+
d => d.skin.label,
|
|
35
|
+
({device, skin}) => {
|
|
36
|
+
return VirtualDeviceView
|
|
37
|
+
.props(game.deck.hub, device, skin)
|
|
38
|
+
.attr("style", `--color: ${skin.color};`)
|
|
39
|
+
.render()
|
|
40
|
+
},
|
|
41
|
+
)}
|
|
42
|
+
|
|
43
|
+
<button @click="${addVirtual}">
|
|
44
|
+
✨
|
|
45
|
+
</button>
|
|
46
|
+
|
|
47
|
+
<button @click="${revealOverlay}">
|
|
48
|
+
👁️
|
|
49
|
+
</button>
|
|
50
|
+
</div>
|
|
51
|
+
`
|
|
52
|
+
})
|
|
53
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
import {css} from "lit"
|
|
3
|
+
export default css`
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
--color: #aaa;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.box {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
|
|
14
|
+
gap: 0.2em;
|
|
15
|
+
padding: 0.2em;
|
|
16
|
+
padding-right: 0.5em;
|
|
17
|
+
|
|
18
|
+
border-radius: 2em;
|
|
19
|
+
background: color-mix(in srgb, #fff4, var(--color));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[view="nub-stick"] {
|
|
23
|
+
width: 2em;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.label {
|
|
27
|
+
font-size: 1.2em;
|
|
28
|
+
font-weight: bold;
|
|
29
|
+
|
|
30
|
+
padding: 0 0.5em;
|
|
31
|
+
text-align: center;
|
|
32
|
+
|
|
33
|
+
color: white;
|
|
34
|
+
text-shadow: 0.1em 0.1em 0.1em #0004;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
button {
|
|
38
|
+
font-size: 0.8em;
|
|
39
|
+
padding: 0.2em;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
`
|
|
43
|
+
|