# HG changeset patch
# User drewp@bigasterisk.com
# Date 1668374680 28800
# Node ID 6d2e2a8ac6f0b8dfc2a99969314ad9e6122257a4
start from https://github.com/supertorpe/vite-ts-phaser-starter
diff -r 000000000000 -r 6d2e2a8ac6f0 .hgignore
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore Sun Nov 13 13:24:40 2022 -0800
@@ -0,0 +1,3 @@
+node_modules
+dist
+dist-ssr
diff -r 000000000000 -r 6d2e2a8ac6f0 LICENSE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LICENSE Sun Nov 13 13:24:40 2022 -0800
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2021 supertorpe
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff -r 000000000000 -r 6d2e2a8ac6f0 README.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md Sun Nov 13 13:24:40 2022 -0800
@@ -0,0 +1,23 @@
+# vite-ts-phaser-starter
+
+This repo contains a typescript phaser project template using vite.
+
+## Getting started
+
+Clone this repository and install its dependencies:
+
+```bash
+git clone https://github.com/supertorpe/vite-ts-phaser-starter.git
+cd vite-ts-phaser-starter
+npm install
+```
+
+`npm run dev` launches a server with hot reloading. Navigate to [localhost:3000](http://localhost:3000).
+
+`npm run build` builds the application to `dist`, generating two bundles for differential serving.
+
+`npm run serve` launches a server over the previous build.
+
+## License
+
+[MIT](LICENSE).
diff -r 000000000000 -r 6d2e2a8ac6f0 index.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/index.html Sun Nov 13 13:24:40 2022 -0800
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ Phaser 3 Starter
+
+
+
+
+
+
diff -r 000000000000 -r 6d2e2a8ac6f0 package.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/package.json Sun Nov 13 13:24:40 2022 -0800
@@ -0,0 +1,15 @@
+{
+ "version": "0.0.0",
+ "scripts": {
+ "dev": "vite",
+ "build": "tsc && vite build",
+ "serve": "vite preview"
+ },
+ "dependencies": {
+ "phaser": "3.55.2"
+ },
+ "devDependencies": {
+ "typescript": "^4.6.2",
+ "vite": "^2.8.6"
+ }
+}
\ No newline at end of file
diff -r 000000000000 -r 6d2e2a8ac6f0 pnpm-lock.yaml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pnpm-lock.yaml Sun Nov 13 13:24:40 2022 -0800
@@ -0,0 +1,371 @@
+lockfileVersion: 5.3
+
+specifiers:
+ phaser: 3.55.2
+ typescript: ^4.6.2
+ vite: ^2.8.6
+
+dependencies:
+ phaser: 3.55.2
+
+devDependencies:
+ typescript: 4.8.4
+ vite: 2.9.15
+
+packages:
+
+ /@esbuild/linux-loong64/0.14.54:
+ resolution: {integrity: sha512-bZBrLAIX1kpWelV0XemxBZllyRmM6vgFQQG2GdNb+r3Fkp0FOh1NJSvekXDs7jq70k4euu1cryLMfU+mTXlEpw==}
+ engines: {node: '>=12'}
+ cpu: [loong64]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-android-64/0.14.54:
+ resolution: {integrity: sha512-Tz2++Aqqz0rJ7kYBfz+iqyE3QMycD4vk7LBRyWaAVFgFtQ/O8EJOnVmTOiDWYZ/uYzB4kvP+bqejYdVKzE5lAQ==}
+ engines: {node: '>=12'}
+ cpu: [x64]
+ os: [android]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-android-arm64/0.14.54:
+ resolution: {integrity: sha512-F9E+/QDi9sSkLaClO8SOV6etqPd+5DgJje1F9lOWoNncDdOBL2YF59IhsWATSt0TLZbYCf3pNlTHvVV5VfHdvg==}
+ engines: {node: '>=12'}
+ cpu: [arm64]
+ os: [android]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-darwin-64/0.14.54:
+ resolution: {integrity: sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug==}
+ engines: {node: '>=12'}
+ cpu: [x64]
+ os: [darwin]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-darwin-arm64/0.14.54:
+ resolution: {integrity: sha512-OPafJHD2oUPyvJMrsCvDGkRrVCar5aVyHfWGQzY1dWnzErjrDuSETxwA2HSsyg2jORLY8yBfzc1MIpUkXlctmw==}
+ engines: {node: '>=12'}
+ cpu: [arm64]
+ os: [darwin]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-freebsd-64/0.14.54:
+ resolution: {integrity: sha512-OKwd4gmwHqOTp4mOGZKe/XUlbDJ4Q9TjX0hMPIDBUWWu/kwhBAudJdBoxnjNf9ocIB6GN6CPowYpR/hRCbSYAg==}
+ engines: {node: '>=12'}
+ cpu: [x64]
+ os: [freebsd]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-freebsd-arm64/0.14.54:
+ resolution: {integrity: sha512-sFwueGr7OvIFiQT6WeG0jRLjkjdqWWSrfbVwZp8iMP+8UHEHRBvlaxL6IuKNDwAozNUmbb8nIMXa7oAOARGs1Q==}
+ engines: {node: '>=12'}
+ cpu: [arm64]
+ os: [freebsd]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-linux-32/0.14.54:
+ resolution: {integrity: sha512-1ZuY+JDI//WmklKlBgJnglpUL1owm2OX+8E1syCD6UAxcMM/XoWd76OHSjl/0MR0LisSAXDqgjT3uJqT67O3qw==}
+ engines: {node: '>=12'}
+ cpu: [ia32]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-linux-64/0.14.54:
+ resolution: {integrity: sha512-EgjAgH5HwTbtNsTqQOXWApBaPVdDn7XcK+/PtJwZLT1UmpLoznPd8c5CxqsH2dQK3j05YsB3L17T8vE7cp4cCg==}
+ engines: {node: '>=12'}
+ cpu: [x64]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-linux-arm/0.14.54:
+ resolution: {integrity: sha512-qqz/SjemQhVMTnvcLGoLOdFpCYbz4v4fUo+TfsWG+1aOu70/80RV6bgNpR2JCrppV2moUQkww+6bWxXRL9YMGw==}
+ engines: {node: '>=12'}
+ cpu: [arm]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-linux-arm64/0.14.54:
+ resolution: {integrity: sha512-WL71L+0Rwv+Gv/HTmxTEmpv0UgmxYa5ftZILVi2QmZBgX3q7+tDeOQNqGtdXSdsL8TQi1vIaVFHUPDe0O0kdig==}
+ engines: {node: '>=12'}
+ cpu: [arm64]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-linux-mips64le/0.14.54:
+ resolution: {integrity: sha512-qTHGQB8D1etd0u1+sB6p0ikLKRVuCWhYQhAHRPkO+OF3I/iSlTKNNS0Lh2Oc0g0UFGguaFZZiPJdJey3AGpAlw==}
+ engines: {node: '>=12'}
+ cpu: [mips64el]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-linux-ppc64le/0.14.54:
+ resolution: {integrity: sha512-j3OMlzHiqwZBDPRCDFKcx595XVfOfOnv68Ax3U4UKZ3MTYQB5Yz3X1mn5GnodEVYzhtZgxEBidLWeIs8FDSfrQ==}
+ engines: {node: '>=12'}
+ cpu: [ppc64]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-linux-riscv64/0.14.54:
+ resolution: {integrity: sha512-y7Vt7Wl9dkOGZjxQZnDAqqn+XOqFD7IMWiewY5SPlNlzMX39ocPQlOaoxvT4FllA5viyV26/QzHtvTjVNOxHZg==}
+ engines: {node: '>=12'}
+ cpu: [riscv64]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-linux-s390x/0.14.54:
+ resolution: {integrity: sha512-zaHpW9dziAsi7lRcyV4r8dhfG1qBidQWUXweUjnw+lliChJqQr+6XD71K41oEIC3Mx1KStovEmlzm+MkGZHnHA==}
+ engines: {node: '>=12'}
+ cpu: [s390x]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-netbsd-64/0.14.54:
+ resolution: {integrity: sha512-PR01lmIMnfJTgeU9VJTDY9ZerDWVFIUzAtJuDHwwceppW7cQWjBBqP48NdeRtoP04/AtO9a7w3viI+PIDr6d+w==}
+ engines: {node: '>=12'}
+ cpu: [x64]
+ os: [netbsd]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-openbsd-64/0.14.54:
+ resolution: {integrity: sha512-Qyk7ikT2o7Wu76UsvvDS5q0amJvmRzDyVlL0qf5VLsLchjCa1+IAvd8kTBgUxD7VBUUVgItLkk609ZHUc1oCaw==}
+ engines: {node: '>=12'}
+ cpu: [x64]
+ os: [openbsd]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-sunos-64/0.14.54:
+ resolution: {integrity: sha512-28GZ24KmMSeKi5ueWzMcco6EBHStL3B6ubM7M51RmPwXQGLe0teBGJocmWhgwccA1GeFXqxzILIxXpHbl9Q/Kw==}
+ engines: {node: '>=12'}
+ cpu: [x64]
+ os: [sunos]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-windows-32/0.14.54:
+ resolution: {integrity: sha512-T+rdZW19ql9MjS7pixmZYVObd9G7kcaZo+sETqNH4RCkuuYSuv9AGHUVnPoP9hhuE1WM1ZimHz1CIBHBboLU7w==}
+ engines: {node: '>=12'}
+ cpu: [ia32]
+ os: [win32]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-windows-64/0.14.54:
+ resolution: {integrity: sha512-AoHTRBUuYwXtZhjXZbA1pGfTo8cJo3vZIcWGLiUcTNgHpJJMC1rVA44ZereBHMJtotyN71S8Qw0npiCIkW96cQ==}
+ engines: {node: '>=12'}
+ cpu: [x64]
+ os: [win32]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild-windows-arm64/0.14.54:
+ resolution: {integrity: sha512-M0kuUvXhot1zOISQGXwWn6YtS+Y/1RT9WrVIOywZnJHo3jCDyewAc79aKNQWFCQm+xNHVTq9h8dZKvygoXQQRg==}
+ engines: {node: '>=12'}
+ cpu: [arm64]
+ os: [win32]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /esbuild/0.14.54:
+ resolution: {integrity: sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA==}
+ engines: {node: '>=12'}
+ hasBin: true
+ requiresBuild: true
+ optionalDependencies:
+ '@esbuild/linux-loong64': 0.14.54
+ esbuild-android-64: 0.14.54
+ esbuild-android-arm64: 0.14.54
+ esbuild-darwin-64: 0.14.54
+ esbuild-darwin-arm64: 0.14.54
+ esbuild-freebsd-64: 0.14.54
+ esbuild-freebsd-arm64: 0.14.54
+ esbuild-linux-32: 0.14.54
+ esbuild-linux-64: 0.14.54
+ esbuild-linux-arm: 0.14.54
+ esbuild-linux-arm64: 0.14.54
+ esbuild-linux-mips64le: 0.14.54
+ esbuild-linux-ppc64le: 0.14.54
+ esbuild-linux-riscv64: 0.14.54
+ esbuild-linux-s390x: 0.14.54
+ esbuild-netbsd-64: 0.14.54
+ esbuild-openbsd-64: 0.14.54
+ esbuild-sunos-64: 0.14.54
+ esbuild-windows-32: 0.14.54
+ esbuild-windows-64: 0.14.54
+ esbuild-windows-arm64: 0.14.54
+ dev: true
+
+ /eventemitter3/4.0.7:
+ resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==}
+ dev: false
+
+ /fsevents/2.3.2:
+ resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
+ engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
+ os: [darwin]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /function-bind/1.1.1:
+ resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==}
+ dev: true
+
+ /has/1.0.3:
+ resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==}
+ engines: {node: '>= 0.4.0'}
+ dependencies:
+ function-bind: 1.1.1
+ dev: true
+
+ /inherits/2.0.3:
+ resolution: {integrity: sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==}
+ dev: false
+
+ /is-core-module/2.11.0:
+ resolution: {integrity: sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==}
+ dependencies:
+ has: 1.0.3
+ dev: true
+
+ /nanoid/3.3.4:
+ resolution: {integrity: sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==}
+ engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
+ hasBin: true
+ dev: true
+
+ /path-parse/1.0.7:
+ resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==}
+ dev: true
+
+ /path/0.12.7:
+ resolution: {integrity: sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==}
+ dependencies:
+ process: 0.11.10
+ util: 0.10.4
+ dev: false
+
+ /phaser/3.55.2:
+ resolution: {integrity: sha512-amKXsbb2Ht29dGPKvt1edq3yGGYKtq8373GpJYGKPNPnneYY6MtVTOgjHDuZwtmUyK4v86FugkT3hzW/N4tjxQ==}
+ dependencies:
+ eventemitter3: 4.0.7
+ path: 0.12.7
+ dev: false
+
+ /picocolors/1.0.0:
+ resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==}
+ dev: true
+
+ /postcss/8.4.19:
+ resolution: {integrity: sha512-h+pbPsyhlYj6N2ozBmHhHrs9DzGmbaarbLvWipMRO7RLS+v4onj26MPFXA5OBYFxyqYhUJK456SwDcY9H2/zsA==}
+ engines: {node: ^10 || ^12 || >=14}
+ dependencies:
+ nanoid: 3.3.4
+ picocolors: 1.0.0
+ source-map-js: 1.0.2
+ dev: true
+
+ /process/0.11.10:
+ resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==}
+ engines: {node: '>= 0.6.0'}
+ dev: false
+
+ /resolve/1.22.1:
+ resolution: {integrity: sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==}
+ hasBin: true
+ dependencies:
+ is-core-module: 2.11.0
+ path-parse: 1.0.7
+ supports-preserve-symlinks-flag: 1.0.0
+ dev: true
+
+ /rollup/2.77.3:
+ resolution: {integrity: sha512-/qxNTG7FbmefJWoeeYJFbHehJ2HNWnjkAFRKzWN/45eNBBF/r8lo992CwcJXEzyVxs5FmfId+vTSTQDb+bxA+g==}
+ engines: {node: '>=10.0.0'}
+ hasBin: true
+ optionalDependencies:
+ fsevents: 2.3.2
+ dev: true
+
+ /source-map-js/1.0.2:
+ resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==}
+ engines: {node: '>=0.10.0'}
+ dev: true
+
+ /supports-preserve-symlinks-flag/1.0.0:
+ resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
+ engines: {node: '>= 0.4'}
+ dev: true
+
+ /typescript/4.8.4:
+ resolution: {integrity: sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==}
+ engines: {node: '>=4.2.0'}
+ hasBin: true
+ dev: true
+
+ /util/0.10.4:
+ resolution: {integrity: sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==}
+ dependencies:
+ inherits: 2.0.3
+ dev: false
+
+ /vite/2.9.15:
+ resolution: {integrity: sha512-fzMt2jK4vQ3yK56te3Kqpkaeq9DkcZfBbzHwYpobasvgYmP2SoAr6Aic05CsB4CzCZbsDv4sujX3pkEGhLabVQ==}
+ engines: {node: '>=12.2.0'}
+ hasBin: true
+ peerDependencies:
+ less: '*'
+ sass: '*'
+ stylus: '*'
+ peerDependenciesMeta:
+ less:
+ optional: true
+ sass:
+ optional: true
+ stylus:
+ optional: true
+ dependencies:
+ esbuild: 0.14.54
+ postcss: 8.4.19
+ resolve: 1.22.1
+ rollup: 2.77.3
+ optionalDependencies:
+ fsevents: 2.3.2
+ dev: true
diff -r 000000000000 -r 6d2e2a8ac6f0 public/assets/bomb.png
Binary file public/assets/bomb.png has changed
diff -r 000000000000 -r 6d2e2a8ac6f0 public/assets/dude.png
Binary file public/assets/dude.png has changed
diff -r 000000000000 -r 6d2e2a8ac6f0 public/assets/platform.png
Binary file public/assets/platform.png has changed
diff -r 000000000000 -r 6d2e2a8ac6f0 public/assets/sky.png
Binary file public/assets/sky.png has changed
diff -r 000000000000 -r 6d2e2a8ac6f0 public/assets/star.png
Binary file public/assets/star.png has changed
diff -r 000000000000 -r 6d2e2a8ac6f0 public/favicon.ico
Binary file public/favicon.ico has changed
diff -r 000000000000 -r 6d2e2a8ac6f0 src/first-scene.ts
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/first-scene.ts Sun Nov 13 13:24:40 2022 -0800
@@ -0,0 +1,171 @@
+import Phaser from 'phaser';
+
+/**
+ * FirstGameScene is an example Phaser Scene
+ * @class
+ * @constructor
+ * @public
+ */
+export class FirstGameScene extends Phaser.Scene {
+
+ private gameOver!: boolean;
+ private score!: number;
+ private platforms!: Phaser.Physics.Arcade.StaticGroup;
+ private player!: Phaser.Physics.Arcade.Sprite;
+ private cursors!: Phaser.Types.Input.Keyboard.CursorKeys;
+ private stars!: Phaser.Physics.Arcade.Group;
+ private bombs!: Phaser.Physics.Arcade.Group;
+ private scoreText!: Phaser.GameObjects.Text;
+
+ constructor() {
+ super('FirstGameScene');
+ console.log('FirstGameScene.constructor()');
+ }
+
+ preload() {
+ console.log('FirstGameScene.preload');
+ this.load.image('sky', 'assets/sky.png');
+ this.load.image('ground', 'assets/platform.png');
+ this.load.image('star', 'assets/star.png');
+ this.load.image('bomb', 'assets/bomb.png');
+ this.load.spritesheet('dude', 'assets/dude.png', { frameWidth: 32, frameHeight: 48 });
+ }
+
+ create() {
+ console.log('FirstGameScene.create');
+ // initialize variables
+ this.gameOver = false;
+ this.score = 0;
+
+ // A simple background for our game
+ this.add.image(400, 300, 'sky');
+
+ // The platforms group contains the ground and the 2 ledges we can jump on
+ this.platforms = this.physics.add.staticGroup();
+
+ // Here we create the ground.
+ // Scale it to fit the width of the game (the original sprite is 400x32 in size)
+ this.platforms.create(400, 568, 'ground').setScale(2).refreshBody();
+
+ // Now let's create some ledges
+ this.platforms.create(600, 400, 'ground');
+ this.platforms.create(50, 250, 'ground');
+ this.platforms.create(750, 220, 'ground');
+
+ // The player and its settings
+ this.player = this.physics.add.sprite(100, 450, 'dude');
+
+ // Player physics properties. Give the little guy a slight bounce.
+ this.player.setBounce(0.2);
+ this.player.setCollideWorldBounds(true);
+
+ // Our player animations, turning, walking left and walking right.
+ this.anims.create({
+ key: 'left',
+ frames: this.anims.generateFrameNumbers('dude', { start: 0, end: 3 }),
+ frameRate: 10,
+ repeat: -1
+ });
+
+ this.anims.create({
+ key: 'turn',
+ frames: [{ key: 'dude', frame: 4 }],
+ frameRate: 20
+ });
+
+ this.anims.create({
+ key: 'right',
+ frames: this.anims.generateFrameNumbers('dude', { start: 5, end: 8 }),
+ frameRate: 10,
+ repeat: -1
+ });
+
+ // Input Events
+ this.cursors = this.input.keyboard.createCursorKeys();
+
+ // Some stars to collect, 12 in total, evenly spaced 70 pixels apart along the x axis
+ this.stars = this.physics.add.group({
+ key: 'star',
+ repeat: 11,
+ setXY: { x: 12, y: 0, stepX: 70 }
+ });
+
+ this.stars.children.iterate((child: Phaser.GameObjects.GameObject) => {
+ // Give each star a slightly different bounce
+ (child as Phaser.Physics.Arcade.Sprite).setBounceY(Phaser.Math.FloatBetween(0.4, 0.8));
+ });
+
+ this.bombs = this.physics.add.group();
+
+ // The score
+ this.scoreText = this.add.text(16, 16, 'score: 0');
+ this.scoreText.style.fontSize = '32px';
+ this.scoreText.style.setFill('#000');
+
+ // Collide the player and the stars with the platforms
+ this.physics.add.collider(this.player, this.platforms);
+ this.physics.add.collider(this.stars, this.platforms);
+ this.physics.add.collider(this.bombs, this.platforms);
+
+ // Checks to see if the player overlaps with any of the stars, if he does call the collectStar function
+ this.physics.add.overlap(this.player, this.stars, this.collectStar, undefined, this);
+
+ this.physics.add.collider(this.player, this.bombs, this.hitBomb, undefined, this);
+ }
+
+ update() {
+ if (this.gameOver) {
+ return;
+ }
+
+ if (this.cursors.left.isDown) {
+ this.player.setVelocityX(-160);
+
+ this.player.anims.play('left', true);
+ }
+ else if (this.cursors.right.isDown) {
+ this.player.setVelocityX(160);
+
+ this.player.anims.play('right', true);
+ }
+ else {
+ this.player.setVelocityX(0);
+
+ this.player.anims.play('turn');
+ }
+
+ if (this.cursors.up.isDown && this.player.body.touching.down) {
+ this.player.setVelocityY(-330);
+ }
+ }
+
+ collectStar(playerGO: Phaser.GameObjects.GameObject, starGO: Phaser.GameObjects.GameObject) {
+ const player = playerGO as Phaser.Physics.Arcade.Sprite;
+ const star = starGO as Phaser.Physics.Arcade.Sprite;
+ star.disableBody(true, true);
+ // Add and update the score
+ this.score += 10;
+ this.scoreText.setText('Score: ' + this.score);
+ if (this.stars.countActive(true) === 0) {
+ // A new batch of stars to collect
+ this.stars.children.iterate((childGO: Phaser.GameObjects.GameObject) => {
+ const child = childGO as Phaser.Physics.Arcade.Sprite;
+ child.enableBody(true, child.x, 0, true, true);
+ });
+ const x = (player.x < 400) ? Phaser.Math.Between(400, 800) : Phaser.Math.Between(0, 400);
+ const bomb = this.bombs.create(x, 16, 'bomb');
+ bomb.setBounce(1);
+ bomb.setCollideWorldBounds(true);
+ bomb.setVelocity(Phaser.Math.Between(-200, 200), 20);
+ bomb.allowGravity = false;
+ }
+ }
+
+ hitBomb(playerGO: Phaser.GameObjects.GameObject) {
+ const player = playerGO as Phaser.Physics.Arcade.Sprite;
+ this.physics.pause();
+ player.setTint(0xff0000);
+ player.anims.play('turn');
+ this.gameOver = true;
+ }
+}
diff -r 000000000000 -r 6d2e2a8ac6f0 src/main.ts
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main.ts Sun Nov 13 13:24:40 2022 -0800
@@ -0,0 +1,20 @@
+import { FirstGameScene } from './first-scene';
+import Phaser from 'phaser';
+import './style.css';
+
+const config: Phaser.Types.Core.GameConfig = {
+ width: 800,
+ height: 600,
+ type: Phaser.AUTO,
+ parent: 'game-container',
+ physics: {
+ default: 'arcade',
+ arcade: {
+ gravity: { y: 300 },
+ debug: false
+ }
+ },
+ scene: [FirstGameScene]
+ };
+
+new Phaser.Game(config);
\ No newline at end of file
diff -r 000000000000 -r 6d2e2a8ac6f0 src/style.css
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/style.css Sun Nov 13 13:24:40 2022 -0800
@@ -0,0 +1,3 @@
+body {
+ background-color: azure;
+}
\ No newline at end of file
diff -r 000000000000 -r 6d2e2a8ac6f0 src/vite-env.d.ts
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vite-env.d.ts Sun Nov 13 13:24:40 2022 -0800
@@ -0,0 +1,1 @@
+///
diff -r 000000000000 -r 6d2e2a8ac6f0 tsconfig.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsconfig.json Sun Nov 13 13:24:40 2022 -0800
@@ -0,0 +1,17 @@
+{
+ "compilerOptions": {
+ "target": "ESNext",
+ "module": "ESNext",
+ "lib": ["ESNext", "DOM", "scripthost"],
+ "moduleResolution": "Node",
+ "strict": true,
+ "sourceMap": true,
+ "resolveJsonModule": true,
+ "esModuleInterop": true,
+ "noEmit": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noImplicitReturns": true
+ },
+ "include": ["./src"]
+}
diff -r 000000000000 -r 6d2e2a8ac6f0 vite.config.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vite.config.js Sun Nov 13 13:24:40 2022 -0800
@@ -0,0 +1,4 @@
+import { defineConfig } from "vite";
+
+export default defineConfig({
+});
\ No newline at end of file