@egret/engine 0.0.0-stage → 7.0.2
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/LICENSE +201 -0
- package/NOTICE +21 -0
- package/README.md +101 -2
- package/README.zh-CN.md +102 -0
- package/dist/Engine.d.ts +77 -0
- package/dist/Engine.js +469 -0
- package/dist/animation/index.d.ts +6 -0
- package/dist/animation/index.js +5 -0
- package/dist/animation/sequenceController.d.ts +22 -0
- package/dist/animation/sequenceController.js +618 -0
- package/dist/animation/sequenceCoordinator.d.ts +26 -0
- package/dist/animation/sequenceCoordinator.js +161 -0
- package/dist/animation/sequenceInput.d.ts +25 -0
- package/dist/animation/sequenceInput.js +108 -0
- package/dist/animation/sequenceMath.d.ts +35 -0
- package/dist/animation/sequenceMath.js +164 -0
- package/dist/animation/sequenceResetSlot.d.ts +7 -0
- package/dist/animation/sequenceResetSlot.js +367 -0
- package/dist/animation/sequenceResetTypes.d.ts +48 -0
- package/dist/animation/sequenceResetTypes.js +2 -0
- package/dist/animation/types.d.ts +75 -0
- package/dist/animation/types.js +2 -0
- package/dist/assetBundle.d.ts +54 -0
- package/dist/assetBundle.js +173 -0
- package/dist/assetGroup.d.ts +17 -0
- package/dist/assetGroup.js +332 -0
- package/dist/assetGroupTypes.d.ts +17 -0
- package/dist/assetGroupTypes.js +2 -0
- package/dist/audio.d.ts +4 -0
- package/dist/audio.js +4 -0
- package/dist/audioCues.d.ts +47 -0
- package/dist/audioCues.js +127 -0
- package/dist/audioMixer.d.ts +7 -0
- package/dist/audioMixer.js +785 -0
- package/dist/audioTypes.d.ts +246 -0
- package/dist/audioTypes.js +3 -0
- package/dist/bitmapBindingTicket.d.ts +24 -0
- package/dist/bitmapBindingTicket.js +215 -0
- package/dist/bitmapButton.d.ts +4 -0
- package/dist/bitmapButton.js +407 -0
- package/dist/bitmapButtonTypes.d.ts +31 -0
- package/dist/bitmapButtonTypes.js +2 -0
- package/dist/bitmapFontParse.d.ts +10 -0
- package/dist/bitmapFontParse.js +246 -0
- package/dist/bitmapFontTypes.d.ts +112 -0
- package/dist/bitmapFontTypes.js +2 -0
- package/dist/bitmapResourceSlot.d.ts +26 -0
- package/dist/bitmapResourceSlot.js +340 -0
- package/dist/bitmapText.d.ts +6 -0
- package/dist/bitmapText.js +320 -0
- package/dist/bitmapfont.d.ts +5 -0
- package/dist/bitmapfont.js +5 -0
- package/dist/camera.d.ts +4 -0
- package/dist/camera.js +4 -0
- package/dist/camera2d.d.ts +7 -0
- package/dist/camera2d.js +419 -0
- package/dist/cameraTypes.d.ts +126 -0
- package/dist/cameraTypes.js +2 -0
- package/dist/closeHost.d.ts +4 -0
- package/dist/closeHost.js +66 -0
- package/dist/contentArtifacts.d.ts +12 -0
- package/dist/contentArtifacts.js +153 -0
- package/dist/contentAtlasPages.d.ts +13 -0
- package/dist/contentAtlasPages.js +117 -0
- package/dist/contentLoader.d.ts +6 -0
- package/dist/contentLoader.js +327 -0
- package/dist/contentTypes.d.ts +35 -0
- package/dist/contentTypes.js +2 -0
- package/dist/createEngine.d.ts +7 -0
- package/dist/createEngine.js +25 -0
- package/dist/createEngineForProfile.d.ts +5 -0
- package/dist/createEngineForProfile.js +45 -0
- package/dist/displaySubtreeTicket.d.ts +25 -0
- package/dist/displaySubtreeTicket.js +76 -0
- package/dist/fontContentLoader.d.ts +6 -0
- package/dist/fontContentLoader.js +298 -0
- package/dist/fontContentTypes.d.ts +39 -0
- package/dist/fontContentTypes.js +2 -0
- package/dist/gameClock.d.ts +24 -0
- package/dist/gameClock.js +246 -0
- package/dist/gameClockTypes.d.ts +37 -0
- package/dist/gameClockTypes.js +2 -0
- package/dist/gameRun.d.ts +53 -0
- package/dist/gameRun.js +97 -0
- package/dist/gamepad.d.ts +5 -0
- package/dist/gamepad.js +5 -0
- package/dist/gamepadInput.d.ts +4 -0
- package/dist/gamepadInput.js +281 -0
- package/dist/gamepadKeys.d.ts +4 -0
- package/dist/gamepadKeys.js +205 -0
- package/dist/gamepadTypes.d.ts +142 -0
- package/dist/gamepadTypes.js +3 -0
- package/dist/hover.d.ts +4 -0
- package/dist/hover.js +4 -0
- package/dist/hoverInput.d.ts +8 -0
- package/dist/hoverInput.js +503 -0
- package/dist/hoverInputTypes.d.ts +129 -0
- package/dist/hoverInputTypes.js +2 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +21 -0
- package/dist/input.d.ts +6 -0
- package/dist/input.js +5 -0
- package/dist/inputActions.d.ts +86 -0
- package/dist/inputActions.js +330 -0
- package/dist/internal/contentFactoryState.d.ts +19 -0
- package/dist/internal/contentFactoryState.js +42 -0
- package/dist/internal/mouseInputFactoryState.d.ts +57 -0
- package/dist/internal/mouseInputFactoryState.js +125 -0
- package/dist/internal/sequenceControllerFactoryState.d.ts +42 -0
- package/dist/internal/sequenceControllerFactoryState.js +98 -0
- package/dist/internal/textFieldFactoryState.d.ts +11 -0
- package/dist/internal/textFieldFactoryState.js +32 -0
- package/dist/internal/texturedFrameState.d.ts +4 -0
- package/dist/internal/texturedFrameState.js +12 -0
- package/dist/internal/uiFactoryState.d.ts +68 -0
- package/dist/internal/uiFactoryState.js +173 -0
- package/dist/internal/uiRootState.d.ts +67 -0
- package/dist/internal/uiRootState.js +103 -0
- package/dist/keyboardInput.d.ts +13 -0
- package/dist/keyboardInput.js +579 -0
- package/dist/keyboardInputTypes.d.ts +93 -0
- package/dist/keyboardInputTypes.js +2 -0
- package/dist/kit.d.ts +16 -0
- package/dist/kit.js +10 -0
- package/dist/layout.d.ts +5 -0
- package/dist/layout.js +132 -0
- package/dist/layoutTypes.d.ts +28 -0
- package/dist/layoutTypes.js +2 -0
- package/dist/manifestAssetGroup.d.ts +10 -0
- package/dist/manifestAssetGroup.js +477 -0
- package/dist/manifestResourceState.d.ts +17 -0
- package/dist/manifestResourceState.js +58 -0
- package/dist/manifestResourceTypes.d.ts +26 -0
- package/dist/manifestResourceTypes.js +2 -0
- package/dist/motion.d.ts +35 -0
- package/dist/motion.js +206 -0
- package/dist/mouseInput.d.ts +102 -0
- package/dist/mouseInput.js +562 -0
- package/dist/mouseInputTypes.d.ts +41 -0
- package/dist/mouseInputTypes.js +2 -0
- package/dist/paragraph.d.ts +8 -0
- package/dist/paragraph.js +7 -0
- package/dist/particleEmitter.d.ts +4 -0
- package/dist/particleEmitter.js +300 -0
- package/dist/particleTypes.d.ts +115 -0
- package/dist/particleTypes.js +2 -0
- package/dist/particles.d.ts +4 -0
- package/dist/particles.js +4 -0
- package/dist/physics2d.d.ts +4 -0
- package/dist/physics2d.js +4 -0
- package/dist/physics2dGeometry.d.ts +39 -0
- package/dist/physics2dGeometry.js +230 -0
- package/dist/physics2dTypes.d.ts +221 -0
- package/dist/physics2dTypes.js +2 -0
- package/dist/physics2dWorld.d.ts +4 -0
- package/dist/physics2dWorld.js +823 -0
- package/dist/pointerInput.d.ts +12 -0
- package/dist/pointerInput.js +300 -0
- package/dist/pointerInputTypes.d.ts +41 -0
- package/dist/pointerInputTypes.js +2 -0
- package/dist/random.d.ts +30 -0
- package/dist/random.js +131 -0
- package/dist/rendering/ownedPreparationFailure2D.d.ts +5 -0
- package/dist/rendering/ownedPreparationFailure2D.js +33 -0
- package/dist/rendering/packSharedDraws2D.d.ts +50 -0
- package/dist/rendering/packSharedDraws2D.js +379 -0
- package/dist/rendering/packedOrientation.d.ts +4 -0
- package/dist/rendering/packedOrientation.js +7 -0
- package/dist/rendering/prepareRectangles2D.d.ts +92 -0
- package/dist/rendering/prepareRectangles2D.js +481 -0
- package/dist/rendering/prepareSharedDraws2D.d.ts +90 -0
- package/dist/rendering/prepareSharedDraws2D.js +663 -0
- package/dist/rendering/preparedBatches2D.d.ts +17 -0
- package/dist/rendering/preparedBatches2D.js +30 -0
- package/dist/rendering/preparedSharedBatches2D.d.ts +44 -0
- package/dist/rendering/preparedSharedBatches2D.js +247 -0
- package/dist/rendering/sharedColor2D.d.ts +52 -0
- package/dist/rendering/sharedColor2D.js +191 -0
- package/dist/rendering/sharedEffects2D.d.ts +23 -0
- package/dist/rendering/sharedEffects2D.js +126 -0
- package/dist/rendering/sharedPreparationRetention2D.d.ts +120 -0
- package/dist/rendering/sharedPreparationRetention2D.js +357 -0
- package/dist/rendering/srgbBytes.d.ts +3 -0
- package/dist/rendering/srgbBytes.js +64 -0
- package/dist/rendering/texturedPreparationBudget2D.d.ts +31 -0
- package/dist/rendering/texturedPreparationBudget2D.js +81 -0
- package/dist/rendering/world3d/Animation3D.d.ts +104 -0
- package/dist/rendering/world3d/Animation3D.js +384 -0
- package/dist/rendering/world3d/AnimationTexture3D.d.ts +163 -0
- package/dist/rendering/world3d/AnimationTexture3D.js +603 -0
- package/dist/rendering/world3d/Batch3D.d.ts +75 -0
- package/dist/rendering/world3d/Batch3D.js +332 -0
- package/dist/rendering/world3d/Camera3D.d.ts +62 -0
- package/dist/rendering/world3d/Camera3D.js +132 -0
- package/dist/rendering/world3d/Character3D.d.ts +127 -0
- package/dist/rendering/world3d/Character3D.js +305 -0
- package/dist/rendering/world3d/Cloth3D.d.ts +130 -0
- package/dist/rendering/world3d/Cloth3D.js +503 -0
- package/dist/rendering/world3d/Compression3D.d.ts +22 -0
- package/dist/rendering/world3d/Compression3D.js +703 -0
- package/dist/rendering/world3d/Curves3D.d.ts +119 -0
- package/dist/rendering/world3d/Curves3D.js +460 -0
- package/dist/rendering/world3d/Decal3D.d.ts +43 -0
- package/dist/rendering/world3d/Decal3D.js +242 -0
- package/dist/rendering/world3d/Export3D.d.ts +13 -0
- package/dist/rendering/world3d/Export3D.js +263 -0
- package/dist/rendering/world3d/Geometry3D.d.ts +95 -0
- package/dist/rendering/world3d/Geometry3D.js +335 -0
- package/dist/rendering/world3d/GeometryBuilder3D.d.ts +53 -0
- package/dist/rendering/world3d/GeometryBuilder3D.js +196 -0
- package/dist/rendering/world3d/Gizmo3D.d.ts +80 -0
- package/dist/rendering/world3d/Gizmo3D.js +514 -0
- package/dist/rendering/world3d/Gltf3D.d.ts +73 -0
- package/dist/rendering/world3d/Gltf3D.js +996 -0
- package/dist/rendering/world3d/GpuParticles3D.d.ts +109 -0
- package/dist/rendering/world3d/GpuParticles3D.js +401 -0
- package/dist/rendering/world3d/Hdr3D.d.ts +35 -0
- package/dist/rendering/world3d/Hdr3D.js +191 -0
- package/dist/rendering/world3d/Jelly3D.d.ts +77 -0
- package/dist/rendering/world3d/Jelly3D.js +267 -0
- package/dist/rendering/world3d/Ktx23D.d.ts +30 -0
- package/dist/rendering/world3d/Ktx23D.js +112 -0
- package/dist/rendering/world3d/Light3D.d.ts +84 -0
- package/dist/rendering/world3d/Light3D.js +97 -0
- package/dist/rendering/world3d/Material3D.d.ts +253 -0
- package/dist/rendering/world3d/Material3D.js +269 -0
- package/dist/rendering/world3d/Mesh3D.d.ts +112 -0
- package/dist/rendering/world3d/Mesh3D.js +337 -0
- package/dist/rendering/world3d/Meshopt3D.d.ts +15 -0
- package/dist/rendering/world3d/Meshopt3D.js +276 -0
- package/dist/rendering/world3d/Navigation3D.d.ts +213 -0
- package/dist/rendering/world3d/Navigation3D.js +1043 -0
- package/dist/rendering/world3d/Object3D.d.ts +118 -0
- package/dist/rendering/world3d/Object3D.js +315 -0
- package/dist/rendering/world3d/Particles3D.d.ts +90 -0
- package/dist/rendering/world3d/Particles3D.js +277 -0
- package/dist/rendering/world3d/Physics3D.d.ts +430 -0
- package/dist/rendering/world3d/Physics3D.js +2840 -0
- package/dist/rendering/world3d/PhysicsHull3D.d.ts +37 -0
- package/dist/rendering/world3d/PhysicsHull3D.js +229 -0
- package/dist/rendering/world3d/PhysicsMesh3D.d.ts +41 -0
- package/dist/rendering/world3d/PhysicsMesh3D.js +340 -0
- package/dist/rendering/world3d/PhysicsQueries3D.d.ts +24 -0
- package/dist/rendering/world3d/PhysicsQueries3D.js +323 -0
- package/dist/rendering/world3d/PhysicsRemote3D.d.ts +179 -0
- package/dist/rendering/world3d/PhysicsRemote3D.js +536 -0
- package/dist/rendering/world3d/Ragdoll3D.d.ts +74 -0
- package/dist/rendering/world3d/Ragdoll3D.js +202 -0
- package/dist/rendering/world3d/Raycast3D.d.ts +40 -0
- package/dist/rendering/world3d/Raycast3D.js +247 -0
- package/dist/rendering/world3d/RenderList3D.d.ts +91 -0
- package/dist/rendering/world3d/RenderList3D.js +502 -0
- package/dist/rendering/world3d/Retarget3D.d.ts +21 -0
- package/dist/rendering/world3d/Retarget3D.js +185 -0
- package/dist/rendering/world3d/Rig3D.d.ts +57 -0
- package/dist/rendering/world3d/Rig3D.js +219 -0
- package/dist/rendering/world3d/Sdf3D.d.ts +181 -0
- package/dist/rendering/world3d/Sdf3D.js +1136 -0
- package/dist/rendering/world3d/SdfLod3D.d.ts +17 -0
- package/dist/rendering/world3d/SdfLod3D.js +56 -0
- package/dist/rendering/world3d/Serialize3D.d.ts +66 -0
- package/dist/rendering/world3d/Serialize3D.js +629 -0
- package/dist/rendering/world3d/Simplify3D.d.ts +29 -0
- package/dist/rendering/world3d/Simplify3D.js +426 -0
- package/dist/rendering/world3d/StateMachine3D.d.ts +87 -0
- package/dist/rendering/world3d/StateMachine3D.js +280 -0
- package/dist/rendering/world3d/SurfaceMaterial3D.d.ts +26 -0
- package/dist/rendering/world3d/SurfaceMaterial3D.js +138 -0
- package/dist/rendering/world3d/Terrain3D.d.ts +248 -0
- package/dist/rendering/world3d/Terrain3D.js +827 -0
- package/dist/rendering/world3d/Text3D.d.ts +95 -0
- package/dist/rendering/world3d/Text3D.js +560 -0
- package/dist/rendering/world3d/Texture3D.d.ts +148 -0
- package/dist/rendering/world3d/Texture3D.js +270 -0
- package/dist/rendering/world3d/Trail3D.d.ts +62 -0
- package/dist/rendering/world3d/Trail3D.js +195 -0
- package/dist/rendering/world3d/Vehicle3D.d.ts +102 -0
- package/dist/rendering/world3d/Vehicle3D.js +228 -0
- package/dist/rendering/world3d/VolumetricFog3D.d.ts +57 -0
- package/dist/rendering/world3d/VolumetricFog3D.js +230 -0
- package/dist/rendering/world3d/Water3D.d.ts +165 -0
- package/dist/rendering/world3d/Water3D.js +607 -0
- package/dist/rendering/world3d/core3D.d.ts +36 -0
- package/dist/rendering/world3d/core3D.js +99 -0
- package/dist/rendering/world3d/debug3D.d.ts +69 -0
- package/dist/rendering/world3d/debug3D.js +262 -0
- package/dist/rendering/world3d/decoders3D.d.ts +42 -0
- package/dist/rendering/world3d/decoders3D.js +133 -0
- package/dist/rendering/world3d/geometries3D.d.ts +111 -0
- package/dist/rendering/world3d/geometries3D.js +610 -0
- package/dist/rendering/world3d/helpers3D.d.ts +67 -0
- package/dist/rendering/world3d/helpers3D.js +178 -0
- package/dist/rendering/world3d/index.d.ts +103 -0
- package/dist/rendering/world3d/index.js +62 -0
- package/dist/rendering/world3d/math3D.d.ts +114 -0
- package/dist/rendering/world3d/math3D.js +675 -0
- package/dist/rendering/world3d/primitives3D.d.ts +67 -0
- package/dist/rendering/world3d/primitives3D.js +197 -0
- package/dist/resources.d.ts +8 -0
- package/dist/resources.js +6 -0
- package/dist/saveStore.d.ts +71 -0
- package/dist/saveStore.js +182 -0
- package/dist/semanticList.d.ts +126 -0
- package/dist/semanticList.js +175 -0
- package/dist/semanticTree.d.ts +10 -0
- package/dist/semanticTree.js +539 -0
- package/dist/semanticTypes.d.ts +175 -0
- package/dist/semanticTypes.js +2 -0
- package/dist/semantics.d.ts +6 -0
- package/dist/semantics.js +5 -0
- package/dist/sequencePlayback.d.ts +19 -0
- package/dist/sequencePlayback.js +391 -0
- package/dist/sequencePlaybackTypes.d.ts +24 -0
- package/dist/sequencePlaybackTypes.js +2 -0
- package/dist/sequenceTargetClaims.d.ts +10 -0
- package/dist/sequenceTargetClaims.js +31 -0
- package/dist/srgbBytes.d.ts +3 -0
- package/dist/srgbBytes.js +64 -0
- package/dist/startEngine.d.ts +5 -0
- package/dist/startEngine.js +31 -0
- package/dist/surfaceOwnership.d.ts +3 -0
- package/dist/surfaceOwnership.js +15 -0
- package/dist/text.d.ts +24 -0
- package/dist/text.js +4 -0
- package/dist/textField.d.ts +6 -0
- package/dist/textField.js +6 -0
- package/dist/textTable.d.ts +41 -0
- package/dist/textTable.js +114 -0
- package/dist/tileMapDraw.d.ts +7 -0
- package/dist/tileMapDraw.js +310 -0
- package/dist/tiledImport.d.ts +9 -0
- package/dist/tiledImport.js +357 -0
- package/dist/tilemap.d.ts +5 -0
- package/dist/tilemap.js +5 -0
- package/dist/tilemapTypes.d.ts +182 -0
- package/dist/tilemapTypes.js +2 -0
- package/dist/timer.d.ts +34 -0
- package/dist/timer.js +119 -0
- package/dist/tween.d.ts +15 -0
- package/dist/tween.js +329 -0
- package/dist/tweenTypes.d.ts +31 -0
- package/dist/tweenTypes.js +2 -0
- package/dist/ui/controlKeys.d.ts +113 -0
- package/dist/ui/controlKeys.js +250 -0
- package/dist/ui/controls.d.ts +58 -0
- package/dist/ui/controls.js +290 -0
- package/dist/ui/editing.d.ts +3 -0
- package/dist/ui/editing.js +3 -0
- package/dist/ui/index.d.ts +19 -0
- package/dist/ui/index.js +11 -0
- package/dist/ui/keyboardFocus.d.ts +32 -0
- package/dist/ui/keyboardFocus.js +146 -0
- package/dist/ui/layerTypes.d.ts +98 -0
- package/dist/ui/layerTypes.js +2 -0
- package/dist/ui/layers.d.ts +4 -0
- package/dist/ui/layers.js +586 -0
- package/dist/ui/leafContent.d.ts +21 -0
- package/dist/ui/leafContent.js +136 -0
- package/dist/ui/rangeControl.d.ts +53 -0
- package/dist/ui/rangeControl.js +168 -0
- package/dist/ui/scrollControl.d.ts +84 -0
- package/dist/ui/scrollControl.js +222 -0
- package/dist/ui/stateControls.d.ts +90 -0
- package/dist/ui/stateControls.js +331 -0
- package/dist/ui/textEditor.d.ts +54 -0
- package/dist/ui/textEditor.js +371 -0
- package/dist/ui/textEditorTypes.d.ts +85 -0
- package/dist/ui/textEditorTypes.js +2 -0
- package/dist/ui/textFieldControl.d.ts +100 -0
- package/dist/ui/textFieldControl.js +260 -0
- package/dist/ui/theme.d.ts +64 -0
- package/dist/ui/theme.js +166 -0
- package/dist/ui/types.d.ts +285 -0
- package/dist/ui/types.js +2 -0
- package/dist/ui/uiRoot.d.ts +4 -0
- package/dist/ui/uiRoot.js +1526 -0
- package/dist/ui/uiRootDisplay.d.ts +46 -0
- package/dist/ui/uiRootDisplay.js +148 -0
- package/dist/ui/uiRootModel.d.ts +114 -0
- package/dist/ui/uiRootModel.js +66 -0
- package/dist/ui/virtualList.d.ts +20 -0
- package/dist/ui/virtualList.js +105 -0
- package/dist/video.d.ts +4 -0
- package/dist/video.js +4 -0
- package/dist/videoPlayer.d.ts +4 -0
- package/dist/videoPlayer.js +215 -0
- package/dist/videoTypes.d.ts +77 -0
- package/dist/videoTypes.js +2 -0
- package/dist/web/BrowserAssetBundle.d.ts +41 -0
- package/dist/web/BrowserAssetBundle.js +136 -0
- package/dist/web/BrowserAudio.d.ts +74 -0
- package/dist/web/BrowserAudio.js +503 -0
- package/dist/web/BrowserFrameLoop.d.ts +69 -0
- package/dist/web/BrowserFrameLoop.js +125 -0
- package/dist/web/BrowserGame.d.ts +174 -0
- package/dist/web/BrowserGame.js +473 -0
- package/dist/web/BrowserGamepadInput.d.ts +38 -0
- package/dist/web/BrowserGamepadInput.js +134 -0
- package/dist/web/BrowserHoverInput.d.ts +25 -0
- package/dist/web/BrowserHoverInput.js +266 -0
- package/dist/web/BrowserImageTextures.d.ts +72 -0
- package/dist/web/BrowserImageTextures.js +169 -0
- package/dist/web/BrowserInputActions.d.ts +63 -0
- package/dist/web/BrowserInputActions.js +345 -0
- package/dist/web/BrowserKeyboardInput.d.ts +4 -0
- package/dist/web/BrowserKeyboardInput.js +223 -0
- package/dist/web/BrowserPlay.d.ts +417 -0
- package/dist/web/BrowserPlay.js +1648 -0
- package/dist/web/BrowserPointerInput.d.ts +4 -0
- package/dist/web/BrowserPointerInput.js +511 -0
- package/dist/web/BrowserPreferences.d.ts +10 -0
- package/dist/web/BrowserPreferences.js +39 -0
- package/dist/web/BrowserSemantics.d.ts +36 -0
- package/dist/web/BrowserSemantics.js +418 -0
- package/dist/web/BrowserStatsPanel.d.ts +56 -0
- package/dist/web/BrowserStatsPanel.js +143 -0
- package/dist/web/BrowserStorage.d.ts +35 -0
- package/dist/web/BrowserStorage.js +132 -0
- package/dist/web/BrowserTextEditor.d.ts +52 -0
- package/dist/web/BrowserTextEditor.js +839 -0
- package/dist/web/BrowserTextInput.d.ts +89 -0
- package/dist/web/BrowserTextInput.js +524 -0
- package/dist/web/BrowserTextureProvider.d.ts +58 -0
- package/dist/web/BrowserTextureProvider.js +935 -0
- package/dist/web/BrowserVideo.d.ts +40 -0
- package/dist/web/BrowserVideo.js +237 -0
- package/dist/web/CanvasKitFontSetProvider.d.ts +32 -0
- package/dist/web/CanvasKitFontSetProvider.js +215 -0
- package/dist/web/CanvasKitParagraphProvider.d.ts +173 -0
- package/dist/web/CanvasKitParagraphProvider.js +692 -0
- package/dist/web/CanvasTextRasterProvider.d.ts +4 -0
- package/dist/web/CanvasTextRasterProvider.js +312 -0
- package/dist/web/ManifestByteSource.d.ts +151 -0
- package/dist/web/ManifestByteSource.js +975 -0
- package/dist/web/ManifestFontContentLoader.d.ts +13 -0
- package/dist/web/ManifestFontContentLoader.js +30 -0
- package/dist/web/MouseInput.d.ts +4 -0
- package/dist/web/MouseInput.js +218 -0
- package/dist/web/WebGL2Host.d.ts +5 -0
- package/dist/web/WebGL2Host.js +2711 -0
- package/dist/web/WebGPUHost.d.ts +100 -0
- package/dist/web/WebGPUHost.js +3430 -0
- package/dist/web/audio.d.ts +3 -0
- package/dist/web/audio.js +4 -0
- package/dist/web/canvasKitParagraphGeometry.d.ts +27 -0
- package/dist/web/canvasKitParagraphGeometry.js +83 -0
- package/dist/web/editing.d.ts +5 -0
- package/dist/web/editing.js +4 -0
- package/dist/web/editorFonts.d.ts +54 -0
- package/dist/web/editorFonts.js +297 -0
- package/dist/web/game.d.ts +5 -0
- package/dist/web/game.js +6 -0
- package/dist/web/gamepad.d.ts +3 -0
- package/dist/web/gamepad.js +4 -0
- package/dist/web/hover.d.ts +3 -0
- package/dist/web/hover.js +4 -0
- package/dist/web/image.d.ts +4 -0
- package/dist/web/image.js +4 -0
- package/dist/web/imageProjections2D.d.ts +16 -0
- package/dist/web/imageProjections2D.js +2 -0
- package/dist/web/input.d.ts +6 -0
- package/dist/web/input.js +4 -0
- package/dist/web/keyboard.d.ts +3 -0
- package/dist/web/keyboard.js +3 -0
- package/dist/web/kit.d.ts +11 -0
- package/dist/web/kit.js +8 -0
- package/dist/web/loop.d.ts +3 -0
- package/dist/web/loop.js +4 -0
- package/dist/web/paragraph.d.ts +6 -0
- package/dist/web/paragraph.js +4 -0
- package/dist/web/play.d.ts +10 -0
- package/dist/web/play.js +9 -0
- package/dist/web/playMusic.d.ts +33 -0
- package/dist/web/playMusic.js +194 -0
- package/dist/web/playSfx.d.ts +36 -0
- package/dist/web/playSfx.js +112 -0
- package/dist/web/playTouch.d.ts +45 -0
- package/dist/web/playTouch.js +141 -0
- package/dist/web/playWidgets.d.ts +71 -0
- package/dist/web/playWidgets.js +431 -0
- package/dist/web/pointer.d.ts +3 -0
- package/dist/web/pointer.js +3 -0
- package/dist/web/prepareSharedSubmission2D.d.ts +27 -0
- package/dist/web/prepareSharedSubmission2D.js +63 -0
- package/dist/web/resources.d.ts +29 -0
- package/dist/web/resources.js +96 -0
- package/dist/web/semantics.d.ts +3 -0
- package/dist/web/semantics.js +4 -0
- package/dist/web/sharedDeviceSession.d.ts +64 -0
- package/dist/web/sharedDeviceSession.js +2 -0
- package/dist/web/sharedEffectShaders.d.ts +13 -0
- package/dist/web/sharedEffectShaders.js +181 -0
- package/dist/web/sharedFrameUpload.d.ts +25 -0
- package/dist/web/sharedFrameUpload.js +2 -0
- package/dist/web/sharedHostDeferred.d.ts +7 -0
- package/dist/web/sharedHostDeferred.js +12 -0
- package/dist/web/sharedRetentionLedger.d.ts +85 -0
- package/dist/web/sharedRetentionLedger.js +391 -0
- package/dist/web/sharedSubmissionStorage2D.d.ts +56 -0
- package/dist/web/sharedSubmissionStorage2D.js +73 -0
- package/dist/web/sharedWebGL2Arena.d.ts +40 -0
- package/dist/web/sharedWebGL2Arena.js +77 -0
- package/dist/web/sharedWebGL2Options.d.ts +33 -0
- package/dist/web/sharedWebGL2Options.js +102 -0
- package/dist/web/sharedWebGL2Shaders.d.ts +33 -0
- package/dist/web/sharedWebGL2Shaders.js +408 -0
- package/dist/web/sharedWebGPUOptions.d.ts +41 -0
- package/dist/web/sharedWebGPUOptions.js +130 -0
- package/dist/web/text.d.ts +3 -0
- package/dist/web/text.js +3 -0
- package/dist/web/textInput.d.ts +3 -0
- package/dist/web/textInput.js +3 -0
- package/dist/web/video.d.ts +3 -0
- package/dist/web/video.js +4 -0
- package/dist/web/webgl2.d.ts +7 -0
- package/dist/web/webgl2.js +4 -0
- package/dist/web/webgl2LayerState.d.ts +50 -0
- package/dist/web/webgl2LayerState.js +102 -0
- package/dist/web/webgl2Native.d.ts +72 -0
- package/dist/web/webgl2Native.js +572 -0
- package/dist/web/webgl2Types.d.ts +150 -0
- package/dist/web/webgl2Types.js +2 -0
- package/dist/web/webgpu.d.ts +6 -0
- package/dist/web/webgpu.js +2 -0
- package/dist/web/webgpuBindingCache.d.ts +26 -0
- package/dist/web/webgpuBindingCache.js +223 -0
- package/dist/web/webgpuBufferPool.d.ts +51 -0
- package/dist/web/webgpuBufferPool.js +58 -0
- package/dist/web/webgpuImageResidency.d.ts +56 -0
- package/dist/web/webgpuImageResidency.js +65 -0
- package/dist/web/webgpuLifetime.d.ts +45 -0
- package/dist/web/webgpuLifetime.js +64 -0
- package/dist/web/webgpuRetentionPool.d.ts +66 -0
- package/dist/web/webgpuRetentionPool.js +85 -0
- package/dist/web/webgpuSharedPass.d.ts +7 -0
- package/dist/web/webgpuSharedPass.js +293 -0
- package/dist/web/webgpuSharedResolvePass.d.ts +3 -0
- package/dist/web/webgpuSharedResolvePass.js +34 -0
- package/dist/web/world3d/Audio3D.d.ts +85 -0
- package/dist/web/world3d/Audio3D.js +271 -0
- package/dist/web/world3d/BrowserPlay3D.d.ts +295 -0
- package/dist/web/world3d/BrowserPlay3D.js +1256 -0
- package/dist/web/world3d/FlyControls3D.d.ts +59 -0
- package/dist/web/world3d/FlyControls3D.js +162 -0
- package/dist/web/world3d/FollowControls3D.d.ts +31 -0
- package/dist/web/world3d/FollowControls3D.js +119 -0
- package/dist/web/world3d/OrbitControls3D.d.ts +58 -0
- package/dist/web/world3d/OrbitControls3D.js +189 -0
- package/dist/web/world3d/TransformControls3D.d.ts +37 -0
- package/dist/web/world3d/TransformControls3D.js +128 -0
- package/dist/web/world3d/WebGL2Renderer3D.d.ts +136 -0
- package/dist/web/world3d/WebGL2Renderer3D.js +1175 -0
- package/dist/web/world3d/WebGPURenderer3D.d.ts +112 -0
- package/dist/web/world3d/WebGPURenderer3D.js +1916 -0
- package/dist/web/world3d/World3DView.d.ts +54 -0
- package/dist/web/world3d/World3DView.js +79 -0
- package/dist/web/world3d/app3D.d.ts +143 -0
- package/dist/web/world3d/app3D.js +305 -0
- package/dist/web/world3d/assets3D.d.ts +39 -0
- package/dist/web/world3d/assets3D.js +112 -0
- package/dist/web/world3d/atmosphere3D.d.ts +56 -0
- package/dist/web/world3d/atmosphere3D.js +193 -0
- package/dist/web/world3d/canvasFont3D.d.ts +21 -0
- package/dist/web/world3d/canvasFont3D.js +165 -0
- package/dist/web/world3d/frame3D.d.ts +144 -0
- package/dist/web/world3d/frame3D.js +388 -0
- package/dist/web/world3d/gpuResources3D.d.ts +98 -0
- package/dist/web/world3d/gpuResources3D.js +901 -0
- package/dist/web/world3d/host3D.d.ts +24 -0
- package/dist/web/world3d/host3D.js +61 -0
- package/dist/web/world3d/index.d.ts +40 -0
- package/dist/web/world3d/index.js +24 -0
- package/dist/web/world3d/loaders3D.d.ts +27 -0
- package/dist/web/world3d/loaders3D.js +138 -0
- package/dist/web/world3d/markers3D.d.ts +53 -0
- package/dist/web/world3d/markers3D.js +130 -0
- package/dist/web/world3d/materialWebGL23D.d.ts +34 -0
- package/dist/web/world3d/materialWebGL23D.js +218 -0
- package/dist/web/world3d/overlay3D.d.ts +47 -0
- package/dist/web/world3d/overlay3D.js +187 -0
- package/dist/web/world3d/post3D.d.ts +116 -0
- package/dist/web/world3d/post3D.js +462 -0
- package/dist/web/world3d/postWebGL23D.d.ts +24 -0
- package/dist/web/world3d/postWebGL23D.js +237 -0
- package/dist/web/world3d/postWebGPU3D.d.ts +23 -0
- package/dist/web/world3d/postWebGPU3D.js +255 -0
- package/dist/web/world3d/probe3D.d.ts +15 -0
- package/dist/web/world3d/probe3D.js +66 -0
- package/dist/web/world3d/shaders3D.d.ts +43 -0
- package/dist/web/world3d/shaders3D.js +851 -0
- package/dist/web/world3d/stats3D.d.ts +34 -0
- package/dist/web/world3d/stats3D.js +81 -0
- package/dist/web/world3d/webGL2FrameMetrics3D.d.ts +71 -0
- package/dist/web/world3d/webGL2FrameMetrics3D.js +185 -0
- package/dist/web/world3d/webgpu.d.ts +37 -0
- package/dist/web/world3d/webgpu.js +23 -0
- package/dist/web/world3d/webgpuPacking3D.d.ts +13 -0
- package/dist/web/world3d/webgpuPacking3D.js +85 -0
- package/dist/web/world3d/wgsl3D.d.ts +68 -0
- package/dist/web/world3d/wgsl3D.js +781 -0
- package/package.json +220 -4
package/dist/web/play.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Optional entry for a whole small game from one call: the canvas, the loop, keys and a pointer to ask each frame,
|
|
3
|
+
// sound effects made in code, overlap tests, timers, text, tweens, the small effects of a hit, and bars, notices,
|
|
4
|
+
// boxes of words and menus.
|
|
5
|
+
export { play, PlayText } from './BrowserPlay.js';
|
|
6
|
+
export { PlayBar, wrapPlayWords } from './playWidgets.js';
|
|
7
|
+
export { SFX_PRESETS, isSfxRecipe, synthesizeSfx } from './playSfx.js';
|
|
8
|
+
export { MUSIC_MOODS, MUSIC_PARTS, composeMusic, musicMix } from './playMusic.js';
|
|
9
|
+
//# sourceMappingURL=play.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** The moods there are. Each has its own key, harmony, tempo and parts. */
|
|
2
|
+
export type MusicMood = 'calm' | 'mystery' | 'tense' | 'battle' | 'triumph';
|
|
3
|
+
/** The moods play music can be made in. */
|
|
4
|
+
export declare const MUSIC_MOODS: readonly MusicMood[];
|
|
5
|
+
/** The parts of a piece, from the quietest moment to the most intense. */
|
|
6
|
+
export declare const MUSIC_PARTS: readonly ["pad", "bass", "drums", "tune"];
|
|
7
|
+
/** One part of a piece of play music. */
|
|
8
|
+
export type MusicPart = (typeof MUSIC_PARTS)[number];
|
|
9
|
+
/** Music to make: its mood, seed, tempo and length in bars. */
|
|
10
|
+
export interface MusicOptions {
|
|
11
|
+
readonly mood?: MusicMood;
|
|
12
|
+
/** The same seed writes the same piece. */
|
|
13
|
+
readonly seed?: number | string;
|
|
14
|
+
/** Beats a minute; the mood's own unless given, from 50 to 200. */
|
|
15
|
+
readonly tempo?: number;
|
|
16
|
+
/** Bars of four beats before the piece repeats: 4 or 8; 8 unless given. */
|
|
17
|
+
readonly bars?: 4 | 8;
|
|
18
|
+
}
|
|
19
|
+
/** A piece of music made from a seed: its mood, tempo, length and parts. */
|
|
20
|
+
export interface MusicPiece {
|
|
21
|
+
readonly mood: MusicMood;
|
|
22
|
+
readonly tempo: number;
|
|
23
|
+
readonly bars: number;
|
|
24
|
+
readonly rate: number;
|
|
25
|
+
readonly seconds: number;
|
|
26
|
+
/** Each part as samples from -1 to 1, all of one length, each joining itself where it repeats. */
|
|
27
|
+
readonly parts: Readonly<Record<MusicPart, Float32Array>>;
|
|
28
|
+
}
|
|
29
|
+
/** Writes a piece. Every call with the same options gives the same samples. */
|
|
30
|
+
export declare function composeMusic(options?: MusicOptions, rate?: number): MusicPiece;
|
|
31
|
+
/** How loud each part is at an intensity from 0 to 1: the pad always, then the bass, the drums and the tune. */
|
|
32
|
+
export declare function musicMix(intensity: number): Record<MusicPart, number>;
|
|
33
|
+
//# sourceMappingURL=playMusic.d.ts.map
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Music made in code, for a game that has no music files. A piece is a few bars in a mood, written once from a seed
|
|
3
|
+
// as four parts of the same length: a pad of held chords, a bass, drums and a tune. Played together and looped, the
|
|
4
|
+
// parts stay in time; a game brings them in and out by how intense the moment is. Nothing here needs a page.
|
|
5
|
+
/** The moods play music can be made in. */
|
|
6
|
+
export const MUSIC_MOODS = Object.freeze(['calm', 'mystery', 'tense', 'battle', 'triumph']);
|
|
7
|
+
/** The parts of a piece, from the quietest moment to the most intense. */
|
|
8
|
+
export const MUSIC_PARTS = Object.freeze(['pad', 'bass', 'drums', 'tune']);
|
|
9
|
+
const MINOR = [0, 2, 3, 5, 7, 8, 10], MAJOR = [0, 2, 4, 5, 7, 9, 11], DORIAN = [0, 2, 3, 5, 7, 9, 10];
|
|
10
|
+
const MOODS = Object.freeze({
|
|
11
|
+
calm: {
|
|
12
|
+
tempo: 84,
|
|
13
|
+
root: 41,
|
|
14
|
+
scale: MAJOR,
|
|
15
|
+
chords: [0, 5, 3, 4, 0, 5, 3, 4],
|
|
16
|
+
pad: 'triangle',
|
|
17
|
+
drums: 'h.......h.......',
|
|
18
|
+
tune: { notes: 4, leap: 2, wave: 'triangle' },
|
|
19
|
+
bass: 'whole'
|
|
20
|
+
},
|
|
21
|
+
mystery: {
|
|
22
|
+
tempo: 72,
|
|
23
|
+
root: 38,
|
|
24
|
+
scale: DORIAN,
|
|
25
|
+
chords: [0, 6, 0, 3, 0, 6, 5, 4],
|
|
26
|
+
pad: 'sine',
|
|
27
|
+
drums: '....h.......h...',
|
|
28
|
+
tune: { notes: 3, leap: 3, wave: 'sine' },
|
|
29
|
+
bass: 'pulse'
|
|
30
|
+
},
|
|
31
|
+
tense: {
|
|
32
|
+
tempo: 108,
|
|
33
|
+
root: 40,
|
|
34
|
+
scale: MINOR,
|
|
35
|
+
chords: [0, 0, 5, 4, 0, 0, 5, 6],
|
|
36
|
+
pad: 'saw',
|
|
37
|
+
drums: 'k...h...k.k.h...',
|
|
38
|
+
tune: { notes: 4, leap: 2, wave: 'square' },
|
|
39
|
+
bass: 'pulse'
|
|
40
|
+
},
|
|
41
|
+
battle: {
|
|
42
|
+
tempo: 140,
|
|
43
|
+
root: 38,
|
|
44
|
+
scale: MINOR,
|
|
45
|
+
chords: [0, 5, 6, 4, 0, 5, 3, 4],
|
|
46
|
+
pad: 'saw',
|
|
47
|
+
drums: 'k.h.s.h.k.k.s.hh',
|
|
48
|
+
tune: { notes: 8, leap: 3, wave: 'square' },
|
|
49
|
+
bass: 'eighths'
|
|
50
|
+
},
|
|
51
|
+
triumph: {
|
|
52
|
+
tempo: 120,
|
|
53
|
+
root: 43,
|
|
54
|
+
scale: MAJOR,
|
|
55
|
+
chords: [0, 3, 4, 0, 5, 3, 4, 4],
|
|
56
|
+
pad: 'saw',
|
|
57
|
+
drums: 'k...s...k.k.s...',
|
|
58
|
+
tune: { notes: 4, leap: 2, wave: 'square' },
|
|
59
|
+
bass: 'eighths'
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const hertz = (midi) => 440 * 2 ** ((midi - 69) / 12);
|
|
63
|
+
/** A small seeded generator, so a seed writes the same piece in every engine. */
|
|
64
|
+
function generator(seed) {
|
|
65
|
+
let h = 2166136261 >>> 0;
|
|
66
|
+
for (const character of String(seed ?? 'egret'))
|
|
67
|
+
h = Math.imul(h ^ character.charCodeAt(0), 16777619) >>> 0;
|
|
68
|
+
return () => {
|
|
69
|
+
h = (h + 0x6d2b79f5) >>> 0;
|
|
70
|
+
let t = h;
|
|
71
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
72
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
73
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const waveAt = (wave, phase) => {
|
|
77
|
+
const p = phase - Math.floor(phase);
|
|
78
|
+
if (wave === 'sine')
|
|
79
|
+
return Math.sin(2 * Math.PI * p);
|
|
80
|
+
if (wave === 'square')
|
|
81
|
+
return p < 0.5 ? 1 : -1;
|
|
82
|
+
if (wave === 'saw')
|
|
83
|
+
return 2 * p - 1;
|
|
84
|
+
return 1 - 4 * Math.abs(p - 0.5);
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Adds one note to a part. A note that runs past the end of the piece continues at its start, so the part joins
|
|
88
|
+
* itself. `attack` and `release` are in seconds; `bright` softens a bright wave with a simple low pass.
|
|
89
|
+
*/
|
|
90
|
+
function note(out, rate, start, seconds, midi, wave, volume, attack, release, bright = 1) {
|
|
91
|
+
const frequency = hertz(midi), length = Math.round((seconds + release) * rate), first = Math.round(start * rate), held = seconds * rate, smoothing = Math.min(1, bright);
|
|
92
|
+
let filtered = 0;
|
|
93
|
+
for (let i = 0; i < length; i++) {
|
|
94
|
+
const t = i / rate;
|
|
95
|
+
let envelope = Math.min(1, t / Math.max(attack, 1e-3));
|
|
96
|
+
if (i > held)
|
|
97
|
+
envelope *= Math.max(0, 1 - (i - held) / Math.max(release * rate, 1));
|
|
98
|
+
const raw = waveAt(wave, frequency * t);
|
|
99
|
+
filtered += (raw - filtered) * smoothing;
|
|
100
|
+
out[(first + i) % out.length] += filtered * envelope * volume;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function noiseHit(out, rate, start, seconds, volume, random, tone = 0) {
|
|
104
|
+
const length = Math.round(seconds * rate), first = Math.round(start * rate);
|
|
105
|
+
for (let i = 0; i < length; i++) {
|
|
106
|
+
const t = i / rate, envelope = Math.exp((-t / seconds) * 5), body = tone > 0 ? Math.sin(2 * Math.PI * tone * t * (1 - t / (seconds * 2))) : 0;
|
|
107
|
+
out[(first + i) % out.length] += ((random() * 2 - 1) * (tone > 0 ? 0.35 : 1) + body) * envelope * volume;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/** Brings a part to a peak of `peak`, so parts of different density are heard alike. */
|
|
111
|
+
function level(part, peak) {
|
|
112
|
+
let most = 0;
|
|
113
|
+
for (let i = 0; i < part.length; i++)
|
|
114
|
+
most = Math.max(most, Math.abs(part[i]));
|
|
115
|
+
if (most > 0)
|
|
116
|
+
for (let i = 0; i < part.length; i++)
|
|
117
|
+
part[i] *= peak / most;
|
|
118
|
+
return part;
|
|
119
|
+
}
|
|
120
|
+
/** Writes a piece. Every call with the same options gives the same samples. */
|
|
121
|
+
export function composeMusic(options = {}, rate = 22050) {
|
|
122
|
+
const mood = options.mood ?? 'calm';
|
|
123
|
+
const shape = MOODS[mood];
|
|
124
|
+
if (shape === undefined)
|
|
125
|
+
throw new TypeError('the mood of music is one of: ' + MUSIC_MOODS.join(', '));
|
|
126
|
+
const tempo = typeof options.tempo === 'number' && Number.isFinite(options.tempo)
|
|
127
|
+
? Math.max(50, Math.min(200, options.tempo))
|
|
128
|
+
: shape.tempo;
|
|
129
|
+
const bars = options.bars === 4 ? 4 : 8;
|
|
130
|
+
if (!Number.isSafeInteger(rate) || rate < 8000 || rate > 96000)
|
|
131
|
+
throw new RangeError('a rate of 8000 to 96000');
|
|
132
|
+
const random = generator(options.seed), beat = 60 / tempo, bar = 4 * beat, seconds = bars * bar, length = Math.round(seconds * rate);
|
|
133
|
+
const parts = {
|
|
134
|
+
pad: new Float32Array(length),
|
|
135
|
+
bass: new Float32Array(length),
|
|
136
|
+
drums: new Float32Array(length),
|
|
137
|
+
tune: new Float32Array(length)
|
|
138
|
+
};
|
|
139
|
+
const degree = (index) => {
|
|
140
|
+
const octave = Math.floor(index / shape.scale.length), step = ((index % shape.scale.length) + shape.scale.length) % shape.scale.length;
|
|
141
|
+
return shape.root + 12 * octave + shape.scale[step];
|
|
142
|
+
};
|
|
143
|
+
// A tune walks the scale over the chord of each bar, starting on a note of the chord.
|
|
144
|
+
let walk = 14;
|
|
145
|
+
for (let b = 0; b < bars; b++) {
|
|
146
|
+
const chord = shape.chords[b % shape.chords.length], at = b * bar;
|
|
147
|
+
// Pad: the three notes of the chord an octave and more above the bass, held the whole bar.
|
|
148
|
+
for (const third of [0, 2, 4])
|
|
149
|
+
note(parts.pad, rate, at, bar * 0.98, degree(chord + third) + 12, shape.pad, 0.3, 0.25, 0.4, 0.08);
|
|
150
|
+
// Bass: the root of the chord.
|
|
151
|
+
const low = degree(chord);
|
|
152
|
+
if (shape.bass === 'whole')
|
|
153
|
+
note(parts.bass, rate, at, bar * 0.9, low, 'triangle', 0.8, 0.02, 0.2, 0.5);
|
|
154
|
+
else
|
|
155
|
+
for (let step = 0; step < (shape.bass === 'eighths' ? 8 : 4); step++) {
|
|
156
|
+
const each = shape.bass === 'eighths' ? beat / 2 : beat;
|
|
157
|
+
note(parts.bass, rate, at + step * each, each * 0.7, low + (step % 4 === 3 ? 7 : 0), 'saw', 0.7, 0.005, 0.05, 0.2);
|
|
158
|
+
}
|
|
159
|
+
// Drums.
|
|
160
|
+
for (let step = 0; step < 16; step++) {
|
|
161
|
+
const when = at + (step * beat) / 4, hit = shape.drums[step];
|
|
162
|
+
if (hit === 'k')
|
|
163
|
+
noiseHit(parts.drums, rate, when, 0.18, 0.9, random, 55);
|
|
164
|
+
else if (hit === 's')
|
|
165
|
+
noiseHit(parts.drums, rate, when, 0.14, 0.6, random, 180);
|
|
166
|
+
else if (hit === 'h')
|
|
167
|
+
noiseHit(parts.drums, rate, when, 0.04, 0.25, random);
|
|
168
|
+
}
|
|
169
|
+
// Tune.
|
|
170
|
+
const notes = shape.tune.notes, each = bar / notes;
|
|
171
|
+
walk = chord + 14 + Math.round(random() * 2) * 2 - 2 + (walk > chord + 18 ? -2 : 0);
|
|
172
|
+
for (let n = 0; n < notes; n++) {
|
|
173
|
+
if (n > 0)
|
|
174
|
+
walk += Math.round((random() * 2 - 1) * shape.tune.leap);
|
|
175
|
+
walk = Math.max(chord + 9, Math.min(chord + 21, walk));
|
|
176
|
+
// A rest now and then lets the tune breathe.
|
|
177
|
+
if (n > 0 && random() < 0.18)
|
|
178
|
+
continue;
|
|
179
|
+
note(parts.tune, rate, at + n * each, each * 0.8, degree(walk), shape.tune.wave, 0.5, 0.01, each * 0.3, 0.25);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
level(parts.pad, 0.5);
|
|
183
|
+
level(parts.bass, 0.6);
|
|
184
|
+
level(parts.drums, 0.6);
|
|
185
|
+
level(parts.tune, 0.45);
|
|
186
|
+
return Object.freeze({ mood, tempo, bars, rate, seconds: length / rate, parts: Object.freeze(parts) });
|
|
187
|
+
}
|
|
188
|
+
/** How loud each part is at an intensity from 0 to 1: the pad always, then the bass, the drums and the tune. */
|
|
189
|
+
export function musicMix(intensity) {
|
|
190
|
+
const x = Math.max(0, Math.min(1, Number.isFinite(intensity) ? intensity : 0));
|
|
191
|
+
const ramp = (from) => Math.max(0, Math.min(1, (x - from) / 0.2));
|
|
192
|
+
return { pad: 1, bass: ramp(0.15), drums: ramp(0.45), tune: ramp(0.7) };
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=playMusic.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** The wave of a tone. `noise` is a new random level `from`..`to` times a second, which gives it a pitch. */
|
|
2
|
+
export type SfxWave = 'sine' | 'square' | 'saw' | 'triangle' | 'noise';
|
|
3
|
+
/** One tone of an effect. */
|
|
4
|
+
export interface SfxTone {
|
|
5
|
+
/** `square` unless given. */
|
|
6
|
+
readonly wave?: SfxWave;
|
|
7
|
+
/** The pitch it starts at, in hertz, from 20 to 12000. */
|
|
8
|
+
readonly from: number;
|
|
9
|
+
/** The pitch it slides to. The same as `from` unless given. */
|
|
10
|
+
readonly to?: number;
|
|
11
|
+
/** How long it sounds, from 0.01 to 3 seconds. */
|
|
12
|
+
readonly seconds: number;
|
|
13
|
+
/** 0 to 1; 0.5 unless given. */
|
|
14
|
+
readonly volume?: number;
|
|
15
|
+
/** How fast it dies away: 0 holds its loudness to the end, 4 (the default) is a pluck, 10 a tick. */
|
|
16
|
+
readonly decay?: number;
|
|
17
|
+
/** White noise mixed into the wave, 0 to 1; 0 unless given. */
|
|
18
|
+
readonly noise?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Made to be looped: its ends are not eased, so a tone of whole waves joins itself without a click. Give it a
|
|
21
|
+
* `decay` of 0 and a length of whole waves, as `hum` has: 110 hertz for 1 second is 110 waves.
|
|
22
|
+
*/
|
|
23
|
+
readonly seamless?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** An effect: one tone, or several played one after another. */
|
|
26
|
+
export type SfxRecipe = SfxTone | readonly SfxTone[];
|
|
27
|
+
/** The effects every game is given, by name. */
|
|
28
|
+
export declare const SFX_PRESETS: Readonly<Record<string, SfxRecipe>>;
|
|
29
|
+
/** Whether a value is a recipe `synthesizeSfx` takes. */
|
|
30
|
+
export declare function isSfxRecipe(recipe: unknown): recipe is SfxRecipe;
|
|
31
|
+
/**
|
|
32
|
+
* The samples of an effect, one channel, from -1 to 1. The same recipe and seed give the same samples, so an
|
|
33
|
+
* effect can be checked without a sound card.
|
|
34
|
+
*/
|
|
35
|
+
export declare function synthesizeSfx(recipe: SfxRecipe, sampleRate?: number, seed?: number): Float32Array;
|
|
36
|
+
//# sourceMappingURL=playSfx.d.ts.map
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Sound effects made in code, for a game that has no sound files: a few tones one after another, each a wave whose
|
|
3
|
+
// pitch slides and whose loudness dies away. `play` turns them into sounds of the mixer; nothing here needs a page.
|
|
4
|
+
/** The effects every game is given, by name. */
|
|
5
|
+
export const SFX_PRESETS = Object.freeze({
|
|
6
|
+
jump: { wave: 'square', from: 300, to: 620, seconds: 0.16, volume: 0.4, decay: 3 },
|
|
7
|
+
coin: [
|
|
8
|
+
{ wave: 'square', from: 988, seconds: 0.06, volume: 0.35, decay: 1 },
|
|
9
|
+
{ wave: 'square', from: 1319, seconds: 0.22, volume: 0.35, decay: 5 }
|
|
10
|
+
],
|
|
11
|
+
hit: { wave: 'square', from: 220, to: 90, seconds: 0.12, volume: 0.5, decay: 5, noise: 0.6 },
|
|
12
|
+
hurt: { wave: 'saw', from: 320, to: 80, seconds: 0.28, volume: 0.5, decay: 3, noise: 0.25 },
|
|
13
|
+
explosion: { wave: 'noise', from: 1400, to: 60, seconds: 0.55, volume: 0.7, decay: 3.5 },
|
|
14
|
+
shoot: { wave: 'saw', from: 900, to: 180, seconds: 0.13, volume: 0.35, decay: 4 },
|
|
15
|
+
powerup: [
|
|
16
|
+
{ wave: 'triangle', from: 523, seconds: 0.07, volume: 0.5, decay: 1 },
|
|
17
|
+
{ wave: 'triangle', from: 659, seconds: 0.07, volume: 0.5, decay: 1 },
|
|
18
|
+
{ wave: 'triangle', from: 784, seconds: 0.07, volume: 0.5, decay: 1 },
|
|
19
|
+
{ wave: 'triangle', from: 1047, seconds: 0.2, volume: 0.5, decay: 4 }
|
|
20
|
+
],
|
|
21
|
+
bounce: { wave: 'sine', from: 420, to: 250, seconds: 0.09, volume: 0.6, decay: 4 },
|
|
22
|
+
pop: { wave: 'sine', from: 650, to: 1150, seconds: 0.07, volume: 0.5, decay: 5 },
|
|
23
|
+
click: { wave: 'square', from: 800, seconds: 0.04, volume: 0.5, decay: 5 },
|
|
24
|
+
// Made for sfx.loop: an engine or a machine, whose pitch a game raises with its speed, and the wind.
|
|
25
|
+
hum: [{ wave: 'saw', from: 55, seconds: 1, volume: 0.35, decay: 0, noise: 0.08, seamless: true }],
|
|
26
|
+
wind: { wave: 'noise', from: 600, seconds: 2, volume: 0.3, decay: 0, seamless: true },
|
|
27
|
+
win: [
|
|
28
|
+
{ wave: 'square', from: 523, seconds: 0.1, volume: 0.35, decay: 1 },
|
|
29
|
+
{ wave: 'square', from: 659, seconds: 0.1, volume: 0.35, decay: 1 },
|
|
30
|
+
{ wave: 'square', from: 784, seconds: 0.1, volume: 0.35, decay: 1 },
|
|
31
|
+
{ wave: 'square', from: 1047, seconds: 0.1, volume: 0.35, decay: 1 },
|
|
32
|
+
{ wave: 'square', from: 1319, seconds: 0.32, volume: 0.35, decay: 3 }
|
|
33
|
+
],
|
|
34
|
+
lose: [
|
|
35
|
+
{ wave: 'saw', from: 392, seconds: 0.16, volume: 0.4, decay: 1.5 },
|
|
36
|
+
{ wave: 'saw', from: 330, seconds: 0.16, volume: 0.4, decay: 1.5 },
|
|
37
|
+
{ wave: 'saw', from: 262, seconds: 0.16, volume: 0.4, decay: 1.5 },
|
|
38
|
+
{ wave: 'saw', from: 196, to: 150, seconds: 0.4, volume: 0.4, decay: 2.5 }
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
const finite = (value) => typeof value === 'number' && Number.isFinite(value);
|
|
42
|
+
const WAVES = ['sine', 'square', 'saw', 'triangle', 'noise'];
|
|
43
|
+
/** Whether a value is a recipe `synthesizeSfx` takes. */
|
|
44
|
+
export function isSfxRecipe(recipe) {
|
|
45
|
+
const tones = Array.isArray(recipe) ? recipe : [recipe];
|
|
46
|
+
return (tones.length > 0 &&
|
|
47
|
+
tones.length <= 32 &&
|
|
48
|
+
tones.every(tone => tone !== null &&
|
|
49
|
+
typeof tone === 'object' &&
|
|
50
|
+
(tone.wave === undefined || WAVES.includes(tone.wave)) &&
|
|
51
|
+
finite(tone.from) &&
|
|
52
|
+
tone.from >= 20 &&
|
|
53
|
+
tone.from <= 12000 &&
|
|
54
|
+
(tone.to === undefined || (finite(tone.to) && tone.to >= 20 && tone.to <= 12000)) &&
|
|
55
|
+
finite(tone.seconds) &&
|
|
56
|
+
tone.seconds >= 0.01 &&
|
|
57
|
+
tone.seconds <= 3 &&
|
|
58
|
+
(tone.volume === undefined || (finite(tone.volume) && tone.volume >= 0 && tone.volume <= 1)) &&
|
|
59
|
+
(tone.decay === undefined || (finite(tone.decay) && tone.decay >= 0 && tone.decay <= 40)) &&
|
|
60
|
+
(tone.noise === undefined || (finite(tone.noise) && tone.noise >= 0 && tone.noise <= 1)) &&
|
|
61
|
+
(tone.seamless === undefined || typeof tone.seamless === 'boolean')));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The samples of an effect, one channel, from -1 to 1. The same recipe and seed give the same samples, so an
|
|
65
|
+
* effect can be checked without a sound card.
|
|
66
|
+
*/
|
|
67
|
+
export function synthesizeSfx(recipe, sampleRate = 22050, seed = 1) {
|
|
68
|
+
const tones = Array.isArray(recipe) ? recipe : [recipe];
|
|
69
|
+
const lengths = tones.map(tone => Math.max(1, Math.round(tone.seconds * sampleRate)));
|
|
70
|
+
const samples = new Float32Array(lengths.reduce((sum, length) => sum + length, 0));
|
|
71
|
+
// A small generator of its own: the effect does not depend on Math.random or on the game's dice.
|
|
72
|
+
let state = seed >>> 0 || 1;
|
|
73
|
+
const random = () => {
|
|
74
|
+
state ^= state << 13;
|
|
75
|
+
state ^= state >>> 17;
|
|
76
|
+
state ^= state << 5;
|
|
77
|
+
return ((state >>> 0) / 4294967296) * 2 - 1;
|
|
78
|
+
};
|
|
79
|
+
let at = 0;
|
|
80
|
+
tones.forEach((tone, index) => {
|
|
81
|
+
const length = lengths[index], wave = tone.wave ?? 'square', to = tone.to ?? tone.from, volume = tone.volume ?? 0.5, decay = tone.decay ?? 4, mixed = tone.noise ?? 0;
|
|
82
|
+
// The ends are eased over a few milliseconds, so a tone neither starts nor stops with a click.
|
|
83
|
+
const edge = tone.seamless === true ? 0 : Math.min(Math.round(sampleRate * 0.004), length >> 1);
|
|
84
|
+
let phase = 0, held = random();
|
|
85
|
+
for (let i = 0; i < length; i++) {
|
|
86
|
+
const u = i / length, frequency = tone.from + (to - tone.from) * u, before = phase;
|
|
87
|
+
phase += frequency / sampleRate;
|
|
88
|
+
const turn = phase % 1;
|
|
89
|
+
let value;
|
|
90
|
+
if (wave === 'sine')
|
|
91
|
+
value = Math.sin(phase * 2 * Math.PI);
|
|
92
|
+
else if (wave === 'square')
|
|
93
|
+
value = turn < 0.5 ? 0.7 : -0.7;
|
|
94
|
+
else if (wave === 'saw')
|
|
95
|
+
value = (turn * 2 - 1) * 0.8;
|
|
96
|
+
else if (wave === 'triangle')
|
|
97
|
+
value = Math.abs(turn * 4 - 2) - 1;
|
|
98
|
+
else {
|
|
99
|
+
if (Math.floor(phase) !== Math.floor(before))
|
|
100
|
+
held = random();
|
|
101
|
+
value = held;
|
|
102
|
+
}
|
|
103
|
+
if (mixed > 0)
|
|
104
|
+
value = value * (1 - mixed) + random() * mixed;
|
|
105
|
+
const fade = edge === 0 ? 1 : Math.min(1, i / edge, (length - 1 - i) / edge);
|
|
106
|
+
samples[at + i] = Math.max(-1, Math.min(1, value * volume * Math.exp(-decay * u) * fade));
|
|
107
|
+
}
|
|
108
|
+
at += length;
|
|
109
|
+
});
|
|
110
|
+
return samples;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=playSfx.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Sprite } from '@egret/engine';
|
|
2
|
+
import type { PlayGame } from './BrowserPlay.js';
|
|
3
|
+
/** A touch stick to show: where, how large, and whether it shows without touch. */
|
|
4
|
+
export interface PlayStickOptions {
|
|
5
|
+
/** The middle of the stick. Near the bottom left of the stage unless given. */
|
|
6
|
+
readonly x?: number;
|
|
7
|
+
readonly y?: number;
|
|
8
|
+
/** How far the knob moves; 48 unless given. */
|
|
9
|
+
readonly radius?: number;
|
|
10
|
+
/** Shown before any finger has touched the stage. */
|
|
11
|
+
readonly always?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** A touch button to show: where, the key it presses, how large, its color, and whether it shows without touch. */
|
|
14
|
+
export interface PlayTouchButtonOptions {
|
|
15
|
+
readonly x: number;
|
|
16
|
+
readonly y: number;
|
|
17
|
+
/** The key it holds while a finger is on it: `'space'` unless given. Any name `keys.down` takes. */
|
|
18
|
+
readonly key?: string;
|
|
19
|
+
readonly radius?: number;
|
|
20
|
+
readonly color?: number;
|
|
21
|
+
readonly always?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** What the controls tell the game: keys held and let go, and where the stick is. */
|
|
24
|
+
export interface PlayTouchPort {
|
|
25
|
+
hold(key: string): void;
|
|
26
|
+
letGo(key: string): void;
|
|
27
|
+
stick(x: number, y: number): void;
|
|
28
|
+
/** A stage place for a place of the page. */
|
|
29
|
+
toStage(clientX: number, clientY: number): {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
33
|
+
/** The layer the controls are drawn on: over the ui, so a box of words does not hide them. */
|
|
34
|
+
readonly layer: Sprite;
|
|
35
|
+
}
|
|
36
|
+
/** The controls of one game. `claim` is asked first for each press: a press it takes is not the game's pointer. */
|
|
37
|
+
export declare function createPlayTouch(game: PlayGame, port: PlayTouchPort): {
|
|
38
|
+
stick(options?: PlayStickOptions): Sprite;
|
|
39
|
+
button(words: string, options: PlayTouchButtonOptions): Sprite;
|
|
40
|
+
claim(event: PointerEvent): boolean;
|
|
41
|
+
move(event: PointerEvent): void;
|
|
42
|
+
end(event: PointerEvent): boolean;
|
|
43
|
+
reset(): void;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=playTouch.d.ts.map
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Controls on the glass for a game played by keys: a stick that counts in `keys.axis()`, and buttons that hold keys.
|
|
3
|
+
// A game written for the keyboard is played on a phone by adding them. They are drawn over the ui layer once a finger
|
|
4
|
+
// has touched the stage, or at once with `always`. Each finger keeps the control it started on until it lifts.
|
|
5
|
+
import { Sprite } from '@egret/engine';
|
|
6
|
+
/** The controls of one game. `claim` is asked first for each press: a press it takes is not the game's pointer. */
|
|
7
|
+
export function createPlayTouch(game, port) {
|
|
8
|
+
let controls = [];
|
|
9
|
+
let seen = false;
|
|
10
|
+
const finite = (value) => typeof value === 'number' && Number.isFinite(value);
|
|
11
|
+
const show = () => {
|
|
12
|
+
for (const control of controls)
|
|
13
|
+
control.node.visible = seen || control.always;
|
|
14
|
+
};
|
|
15
|
+
const touch = {
|
|
16
|
+
stick(o = {}) {
|
|
17
|
+
const reach = finite(o?.radius) && o.radius > 0 ? o.radius : 48, x = finite(o?.x) ? o.x : reach + 28, y = finite(o?.y) ? o.y : game.height - reach - 28;
|
|
18
|
+
const node = game.sprite(g => {
|
|
19
|
+
g.beginFill(0xffffff, 0.12).drawCircle(0, 0, reach).endFill();
|
|
20
|
+
g.lineStyle(2, 0xffffff, 0.3).drawCircle(0, 0, reach);
|
|
21
|
+
}, port.layer);
|
|
22
|
+
node.x = x;
|
|
23
|
+
node.y = y;
|
|
24
|
+
const knob = game.sprite(g => g
|
|
25
|
+
.beginFill(0xffffff, 0.45)
|
|
26
|
+
.drawCircle(0, 0, reach * 0.42)
|
|
27
|
+
.endFill(), node);
|
|
28
|
+
const place = (px, py) => {
|
|
29
|
+
let dx = px - x, dy = py - y;
|
|
30
|
+
const length = Math.hypot(dx, dy);
|
|
31
|
+
if (length > reach) {
|
|
32
|
+
dx = (dx / length) * reach;
|
|
33
|
+
dy = (dy / length) * reach;
|
|
34
|
+
}
|
|
35
|
+
knob.x = dx;
|
|
36
|
+
knob.y = dy;
|
|
37
|
+
port.stick(dx / reach, dy / reach);
|
|
38
|
+
};
|
|
39
|
+
controls.push({
|
|
40
|
+
node,
|
|
41
|
+
always: o?.always === true,
|
|
42
|
+
x,
|
|
43
|
+
y,
|
|
44
|
+
// A finger a little outside the ring still takes the stick.
|
|
45
|
+
reach: reach * 1.4,
|
|
46
|
+
owner: undefined,
|
|
47
|
+
press: place,
|
|
48
|
+
drag: place,
|
|
49
|
+
release() {
|
|
50
|
+
knob.x = knob.y = 0;
|
|
51
|
+
port.stick(0, 0);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
show();
|
|
55
|
+
return node;
|
|
56
|
+
},
|
|
57
|
+
button(words, o) {
|
|
58
|
+
if (o === null || typeof o !== 'object' || !finite(o.x) || !finite(o.y))
|
|
59
|
+
throw new TypeError('a touch button takes its words and { x, y }');
|
|
60
|
+
const r = finite(o.radius) && o.radius > 0 ? o.radius : 32, key = typeof o.key === 'string' && o.key !== '' ? o.key : 'space', color = Number.isInteger(o.color) && o.color >= 0 && o.color <= 0xffffff ? o.color : 0xffffff;
|
|
61
|
+
const draw = (down) => {
|
|
62
|
+
node.graphics
|
|
63
|
+
.clear()
|
|
64
|
+
.beginFill(color, down ? 0.5 : 0.2)
|
|
65
|
+
.drawCircle(0, 0, r)
|
|
66
|
+
.endFill()
|
|
67
|
+
.lineStyle(2, color, 0.5)
|
|
68
|
+
.drawCircle(0, 0, r);
|
|
69
|
+
};
|
|
70
|
+
const node = game.sprite(undefined, port.layer);
|
|
71
|
+
node.x = o.x;
|
|
72
|
+
node.y = o.y;
|
|
73
|
+
draw(false);
|
|
74
|
+
game.text(String(words), { size: Math.round(r * 0.6), align: 'center', baseline: 'middle', layer: node });
|
|
75
|
+
controls.push({
|
|
76
|
+
node,
|
|
77
|
+
always: o.always === true,
|
|
78
|
+
x: o.x,
|
|
79
|
+
y: o.y,
|
|
80
|
+
reach: r * 1.2,
|
|
81
|
+
owner: undefined,
|
|
82
|
+
press() {
|
|
83
|
+
draw(true);
|
|
84
|
+
port.hold(key);
|
|
85
|
+
},
|
|
86
|
+
drag() { },
|
|
87
|
+
release() {
|
|
88
|
+
draw(false);
|
|
89
|
+
port.letGo(key);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
show();
|
|
93
|
+
return node;
|
|
94
|
+
},
|
|
95
|
+
claim(event) {
|
|
96
|
+
if (event.pointerType !== 'touch')
|
|
97
|
+
return false;
|
|
98
|
+
if (!seen) {
|
|
99
|
+
seen = true;
|
|
100
|
+
show();
|
|
101
|
+
}
|
|
102
|
+
const at = port.toStage(event.clientX, event.clientY);
|
|
103
|
+
controls = controls.filter(control => !control.node.isDisposed);
|
|
104
|
+
for (const control of controls) {
|
|
105
|
+
if (control.owner !== undefined || !control.node.visible)
|
|
106
|
+
continue;
|
|
107
|
+
if (Math.hypot(at.x - control.x, at.y - control.y) > control.reach)
|
|
108
|
+
continue;
|
|
109
|
+
control.owner = event.pointerId;
|
|
110
|
+
control.press(at.x, at.y);
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
},
|
|
115
|
+
move(event) {
|
|
116
|
+
for (const control of controls)
|
|
117
|
+
if (control.owner === event.pointerId) {
|
|
118
|
+
const at = port.toStage(event.clientX, event.clientY);
|
|
119
|
+
control.drag(at.x, at.y);
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
end(event) {
|
|
123
|
+
let owned = false;
|
|
124
|
+
for (const control of controls)
|
|
125
|
+
if (control.owner === event.pointerId) {
|
|
126
|
+
control.owner = undefined;
|
|
127
|
+
control.release();
|
|
128
|
+
owned = true;
|
|
129
|
+
}
|
|
130
|
+
return owned;
|
|
131
|
+
},
|
|
132
|
+
reset() {
|
|
133
|
+
for (const control of controls)
|
|
134
|
+
if (control.owner !== undefined && !control.node.isDisposed)
|
|
135
|
+
control.release();
|
|
136
|
+
controls = [];
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
return touch;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=playTouch.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Sprite } from '@egret/engine';
|
|
2
|
+
import type { PlayGame } from './BrowserPlay.js';
|
|
3
|
+
/** A bar to show, as for health: where and how large, its value and maximum, its colors and layer. */
|
|
4
|
+
export interface PlayBarOptions {
|
|
5
|
+
readonly x: number;
|
|
6
|
+
readonly y: number;
|
|
7
|
+
/** 120 by 12 unless given. `x` and `y` are its left and its top. */
|
|
8
|
+
readonly width?: number;
|
|
9
|
+
readonly height?: number;
|
|
10
|
+
/** How full it is: `value` out of `max`. 1 of 1 unless given. */
|
|
11
|
+
readonly value?: number;
|
|
12
|
+
readonly max?: number;
|
|
13
|
+
readonly color?: number;
|
|
14
|
+
/** The colour of the empty part. */
|
|
15
|
+
readonly back?: number;
|
|
16
|
+
readonly layer?: Sprite;
|
|
17
|
+
}
|
|
18
|
+
/** A bar of health, time or power. Setting `value` slides it there; a fall leaves a pale trail that catches up. */
|
|
19
|
+
export declare class PlayBar extends Sprite {
|
|
20
|
+
#private;
|
|
21
|
+
constructor(width: number, height: number, value: number, max: number, color: number, back: number);
|
|
22
|
+
get value(): number;
|
|
23
|
+
set value(next: number);
|
|
24
|
+
get max(): number;
|
|
25
|
+
set max(next: number);
|
|
26
|
+
get color(): number;
|
|
27
|
+
set color(next: number);
|
|
28
|
+
/** Moves what is shown towards the value, by the seconds since the last step. */
|
|
29
|
+
step(seconds: number): void;
|
|
30
|
+
draw(): void;
|
|
31
|
+
}
|
|
32
|
+
/** A line of dialogue: who says it, the choices offered, its color and how fast it types. */
|
|
33
|
+
export interface PlaySayOptions {
|
|
34
|
+
/** The name shown above the words. */
|
|
35
|
+
readonly who?: string;
|
|
36
|
+
/** Answers to choose from. `say` then gives the index of the one chosen. */
|
|
37
|
+
readonly choices?: readonly string[];
|
|
38
|
+
/** The colour of the name and of the chosen answer. */
|
|
39
|
+
readonly color?: number;
|
|
40
|
+
/** Letters a second as the words appear; 0 shows them at once. 40 unless given. */
|
|
41
|
+
readonly speed?: number;
|
|
42
|
+
}
|
|
43
|
+
/** A menu to show: its title, where it goes, how wide and its color. */
|
|
44
|
+
export interface PlayMenuOptions {
|
|
45
|
+
readonly title?: string;
|
|
46
|
+
/** The middle of the menu. The middle of the stage unless given. */
|
|
47
|
+
readonly x?: number;
|
|
48
|
+
readonly y?: number;
|
|
49
|
+
readonly width?: number;
|
|
50
|
+
/** The colour of the chosen item. */
|
|
51
|
+
readonly color?: number;
|
|
52
|
+
}
|
|
53
|
+
/** A toast to show: how long and in what color. */
|
|
54
|
+
export interface PlayToastOptions {
|
|
55
|
+
readonly seconds?: number;
|
|
56
|
+
readonly color?: number;
|
|
57
|
+
}
|
|
58
|
+
/** Breaks words into lines no wider than `units`: at a space where there is one, between any two wide characters. */
|
|
59
|
+
export declare function wrapPlayWords(words: string, units: number): string[];
|
|
60
|
+
/** The widgets of one game. `tick` is called once a step, also while the game is paused, with seconds of the wall. */
|
|
61
|
+
export declare function createPlayWidgets(game: PlayGame, wake?: () => void): {
|
|
62
|
+
bar(options: PlayBarOptions): PlayBar;
|
|
63
|
+
toast(words: string, options?: PlayToastOptions): void;
|
|
64
|
+
say(words: string, options?: PlaySayOptions): Promise<number | undefined>;
|
|
65
|
+
sayPage(words: string, options?: PlaySayOptions): Promise<number | undefined>;
|
|
66
|
+
menu(items: readonly string[], options?: PlayMenuOptions): Promise<number>;
|
|
67
|
+
readonly asking: boolean;
|
|
68
|
+
tick(seconds: number): void;
|
|
69
|
+
reset(): void;
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=playWidgets.d.ts.map
|