From 39584c3bb9510c2d8c1308928f9ee74d99ac8c2a Mon Sep 17 00:00:00 2001 From: straker Date: Fri, 27 Dec 2019 23:25:16 -0700 Subject: [PATCH] feat(scene): accessible scene --- .gitignore | 1 + CONTRIBUTING.md | 8 +- docs/api/animation.html | 15 +- docs/api/assets.html | 7 +- docs/api/button.html | 99 ++++- docs/api/collision.html | 1 + docs/api/core.html | 1 + docs/api/events.html | 1 + docs/api/gameLoop.html | 3 +- docs/api/gameobject.html | 47 +- docs/api/keyboard.html | 3 +- docs/api/plugin.html | 1 + docs/api/pointer.html | 3 +- docs/api/pool.html | 7 +- docs/api/quadtree.html | 7 +- docs/api/scene.html | 443 +++++++++++++++++++ docs/api/sprite.html | 13 +- docs/api/spriteSheet.html | 7 +- docs/api/store.html | 1 + docs/api/text.html | 9 +- docs/api/tileEngine.html | 23 +- docs/api/vector.html | 5 +- docs/assets/js/kontra.js | 2 +- docs/custom-builds.html | 1 + docs/download.html | 1 + docs/getting-started.html | 1 + docs/index.html | 1 + docs/made-with-kontra.html | 1 + docs/tutorials.html | 1 + examples/scene/gameScene.js | 68 +++ examples/scene/globals.js | 9 + examples/scene/index.html | 72 +++ examples/scene/menuScene.js | 42 ++ examples/scene/snake.js | 85 ++++ kontra.d.ts | 28 +- kontra.js | 241 +++++++++- kontra.min.js | 2 +- kontra.min.mjs | 2 +- kontra.mjs | 377 ++++++++++++---- src/button.js | 54 ++- src/kontra.defaults.js | 2 + src/kontra.js | 2 + src/scene.js | 187 ++++++++ tasks/docs.js | 3 + test/permutations/index.js | 2 +- test/typings/scene.ts | 34 ++ test/unit/button.spec.js | 102 +++-- test/unit/gameObject.spec.js | 68 +-- test/unit/{keys.spec.js => keyboard.spec.js} | 0 test/unit/kontra.defaults.spec.js | 30 +- test/unit/kontra.spec.js | 26 +- test/unit/scene.spec.js | 308 +++++++++++++ test/unit/text.spec.js | 18 + test/unit/tileEngine.spec.js | 2 +- 54 files changed, 2195 insertions(+), 282 deletions(-) create mode 100644 docs/api/scene.html create mode 100644 examples/scene/gameScene.js create mode 100644 examples/scene/globals.js create mode 100644 examples/scene/index.html create mode 100644 examples/scene/menuScene.js create mode 100644 examples/scene/snake.js create mode 100644 src/scene.js create mode 100644 test/typings/scene.ts rename test/unit/{keys.spec.js => keyboard.spec.js} (100%) create mode 100644 test/unit/scene.spec.js diff --git a/.gitignore b/.gitignore index 2903bb3f..e891e2e3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,6 @@ coverage test/permutations/*.js test/permutations/*.spec.js test/typings/*.js +test/playground.html !test/permutations/index.js \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c6ad7c20..9a3ef19f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,7 +28,13 @@ To build the development code, run `npm run build`. To build the distribution ve ## Testing -Please add unit and/or integration tests for all new changes. To run the tests, run `npm test`. +Please add unit and/or integration tests for all new changes, as well as TypeScript tests found in [test/typings](test/typings). To run the tests, run `npm test`. + +The TypeScript tests just ensure that the TypesCript declaration file is correct and doesn't miss any obvious use cases with the various APIs. + +## Exports + +Please update the export files for all new changes (if need be). [kontra.defaults.js](src/kontra.defaults.js) imports all functionality and then adds it to the `kontra` object. [kontra.js](src/kontra.js) exports all functionality directly. You will also need to tests to their respected spec files that ensures the functionality is exported. ## Documentation and TypeScript Declaration File diff --git a/docs/api/animation.html b/docs/api/animation.html index 047739d4..ac1592ce 100644 --- a/docs/api/animation.html +++ b/docs/api/animation.html @@ -53,6 +53,7 @@
  • Pointer
  • Pool
  • Quadtree
  • +
  • Scene
  • Sprite
  • SpriteSheet
  • Store
  • @@ -276,7 +277,7 @@

    -

    Number of frames to display per second. Adjusting this value will change the speed of the animation.

    +

    Number. Number of frames to display per second. Adjusting this value will change the speed of the animation.

    @@ -287,7 +288,7 @@

    -

    Sequence of frames to use from the sprite sheet.

    +

    An Array of Numbers. Sequence of frames to use from the sprite sheet.

    @@ -298,7 +299,7 @@

    -

    The height of an individual frame. Taken from the property of the same name in the spriteSheet.

    +

    Number. The height of an individual frame. Taken from the property of the same name in the spriteSheet.

    @@ -309,7 +310,7 @@

    -

    If the animation should loop back to the beginning once completed.

    +

    Boolean. If the animation should loop back to the beginning once completed.

    @@ -320,7 +321,7 @@

    -

    The space between each frame. Taken from the property of the same name in the spriteSheet.

    +

    Number. The space between each frame. Taken from the property of the same name in the spriteSheet.

    @@ -392,7 +393,7 @@

    -

    The sprite sheet to use for the animation.

    +

    SpriteSheet. The sprite sheet to use for the animation.

    @@ -423,7 +424,7 @@

    -

    The width of an individual frame. Taken from the property of the same name in the spriteSheet.

    +

    Number. The width of an individual frame. Taken from the property of the same name in the spriteSheet.

    diff --git a/docs/api/assets.html b/docs/api/assets.html index 7aa17b9a..be3b68c4 100644 --- a/docs/api/assets.html +++ b/docs/api/assets.html @@ -53,6 +53,7 @@
  • Pointer
  • Pool
  • Quadtree
  • +
  • Scene
  • Sprite
  • SpriteSheet
  • Store
  • @@ -224,7 +225,7 @@

    -

    Object of all loaded audio assets by both file name and path. If the base audio path was set before the audio was loaded, the file name and path will not include the base audio path.

    +

    Object. Object of all loaded audio assets by both file name and path. If the base audio path was set before the audio was loaded, the file name and path will not include the base audio path.