├── docs ├── _config.yml ├── red.52be5f17.png ├── space.f9604c1b.png ├── favicon-16x16.c185778f.png ├── favicon-32x32.3df3657b.png ├── apple-touch-icon.968a9f06.png ├── android-chrome-192x192.678466e6.png ├── android-chrome-256x256.29e071d4.png ├── meta │ └── site.webmanifest ├── safari-pinned-tab.ead9fee4.svg └── index.html ├── .nvmrc ├── .babelrc ├── sandbox.config.json ├── .gitignore ├── src ├── assets │ ├── red.png │ └── space.png ├── meta │ ├── favicon.ico │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── apple-touch-icon.png │ ├── android-chrome-192x192.png │ ├── android-chrome-256x256.png │ ├── android-chrome-512x512.png │ ├── site.webmanifest │ └── safari-pinned-tab.svg ├── main.ts ├── gameConfig.ts ├── scenes │ ├── EndScene.ts │ ├── MenuScene.ts │ ├── BootScene.ts │ └── PlayScene.ts └── index.html ├── dist ├── red.5c208bbd.png ├── space.89e3a46b.png ├── favicon-16x16.fcfde30b.png ├── favicon-32x32.1c961af8.png ├── apple-touch-icon.8083eab7.png ├── android-chrome-192x192.793ee286.png ├── android-chrome-256x256.52cdbd65.png ├── meta │ └── site.webmanifest ├── safari-pinned-tab.a65600d3.svg ├── index.html ├── index.js └── index.js.map ├── .eslintrc.yml ├── Makefile ├── .editorconfig ├── README.md └── package.json /docs/_config.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v12.19.0 2 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env"] 3 | } -------------------------------------------------------------------------------- /sandbox.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "parcel" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.cache 2 | /package-lock.json 3 | node_modules/ 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /src/assets/red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/src/assets/red.png -------------------------------------------------------------------------------- /dist/red.5c208bbd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/dist/red.5c208bbd.png -------------------------------------------------------------------------------- /docs/red.52be5f17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/docs/red.52be5f17.png -------------------------------------------------------------------------------- /src/assets/space.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/src/assets/space.png -------------------------------------------------------------------------------- /src/meta/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/src/meta/favicon.ico -------------------------------------------------------------------------------- /dist/space.89e3a46b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/dist/space.89e3a46b.png -------------------------------------------------------------------------------- /docs/space.f9604c1b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/docs/space.f9604c1b.png -------------------------------------------------------------------------------- /src/meta/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/src/meta/favicon-16x16.png -------------------------------------------------------------------------------- /src/meta/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/src/meta/favicon-32x32.png -------------------------------------------------------------------------------- /src/meta/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/src/meta/apple-touch-icon.png -------------------------------------------------------------------------------- /dist/favicon-16x16.fcfde30b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/dist/favicon-16x16.fcfde30b.png -------------------------------------------------------------------------------- /dist/favicon-32x32.1c961af8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/dist/favicon-32x32.1c961af8.png -------------------------------------------------------------------------------- /docs/favicon-16x16.c185778f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/docs/favicon-16x16.c185778f.png -------------------------------------------------------------------------------- /docs/favicon-32x32.3df3657b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/docs/favicon-32x32.3df3657b.png -------------------------------------------------------------------------------- /dist/apple-touch-icon.8083eab7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/dist/apple-touch-icon.8083eab7.png -------------------------------------------------------------------------------- /docs/apple-touch-icon.968a9f06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/docs/apple-touch-icon.968a9f06.png -------------------------------------------------------------------------------- /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | extends: semistandard 2 | env: 3 | browser: true 4 | es6: true 5 | parserOptions: 6 | sourceType: module 7 | -------------------------------------------------------------------------------- /src/meta/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/src/meta/android-chrome-192x192.png -------------------------------------------------------------------------------- /src/meta/android-chrome-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/src/meta/android-chrome-256x256.png -------------------------------------------------------------------------------- /src/meta/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/src/meta/android-chrome-512x512.png -------------------------------------------------------------------------------- /dist/android-chrome-192x192.793ee286.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/dist/android-chrome-192x192.793ee286.png -------------------------------------------------------------------------------- /dist/android-chrome-256x256.52cdbd65.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/dist/android-chrome-256x256.52cdbd65.png -------------------------------------------------------------------------------- /docs/android-chrome-192x192.678466e6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/docs/android-chrome-192x192.678466e6.png -------------------------------------------------------------------------------- /docs/android-chrome-256x256.29e071d4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanuys/mathsgame/master/docs/android-chrome-256x256.29e071d4.png -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: run dist test 2 | 3 | dist: 4 | rm -rf docs/ 5 | mkdir -p docs 6 | touch docs/_config.yml 7 | npm run dist 8 | 9 | run: 10 | npm run start 11 | 12 | test: 13 | npm run test 14 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [{src,scripts}/**.{ts,json,js}] 4 | end_of_line = crlf 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | insert_final_newline = true 8 | indent_style = space 9 | indent_size = 4 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Get started 2 | 3 | npm install -g parcel-bundler 4 | 5 | Auto-compile and run dev server 6 | Parcel will also install deps with yarn. 7 | 8 | make run 9 | 10 | Compile for production 11 | 12 | make dist 13 | 14 | -------------------------------------------------------------------------------- /dist/meta/site.webmanifest: -------------------------------------------------------------------------------- 1 | {"name":"","short_name":"","icons":[{"src":"android-chrome-192x192.793ee286.png","sizes":"192x192","type":"image/png"},{"src":"android-chrome-256x256.52cdbd65.png","sizes":"256x256","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} -------------------------------------------------------------------------------- /docs/meta/site.webmanifest: -------------------------------------------------------------------------------- 1 | {"name":"","short_name":"","icons":[{"src":"android-chrome-192x192.678466e6.png","sizes":"192x192","type":"image/png"},{"src":"android-chrome-256x256.29e071d4.png","sizes":"256x256","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import Phaser from 'phaser' 2 | import gameConfig from './gameConfig' 3 | 4 | function newGame () { 5 | if (game) return 6 | game = new Phaser.Game(gameConfig) 7 | } 8 | 9 | function destroyGame () { 10 | if (!game) return 11 | game.destroy(true) 12 | game.runDestroy() 13 | game = null 14 | } 15 | 16 | let game 17 | 18 | if (module.hot) { 19 | module.hot.dispose(destroyGame) 20 | module.hot.accept(newGame) 21 | } 22 | 23 | if (!game) newGame() 24 | -------------------------------------------------------------------------------- /src/meta/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "short_name": "", 4 | "icons": [ 5 | { 6 | "src": "/meta/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/meta/android-chrome-256x256.png", 12 | "sizes": "256x256", 13 | "type": "image/png" 14 | } 15 | ], 16 | "theme_color": "#ffffff", 17 | "background_color": "#ffffff", 18 | "display": "standalone" 19 | } 20 | -------------------------------------------------------------------------------- /src/gameConfig.ts: -------------------------------------------------------------------------------- 1 | import Phaser from 'phaser'; 2 | import BootScene from './scenes/BootScene'; 3 | import PlayScene from './scenes/PlayScene'; 4 | import MenuScene from './scenes/MenuScene'; 5 | import EndScene from './scenes/EndScene'; 6 | 7 | export default { 8 | type: Phaser.AUTO, 9 | width: 800, 10 | height: 600, 11 | title: 'Quick maths game', 12 | url: 'https://github.com/opyate/phaser-parcel', 13 | banner: { text: 'white', background: ['#FD7400', '#FFE11A', '#BEDB39', '#1F8A70', '#004358'] }, 14 | scene: [BootScene, MenuScene, PlayScene, EndScene] 15 | }; 16 | -------------------------------------------------------------------------------- /src/scenes/EndScene.ts: -------------------------------------------------------------------------------- 1 | import Phaser from 'phaser' 2 | 3 | export default class EndScene extends Phaser.Scene { 4 | constructor () { 5 | super({ key: 'end' }) 6 | } 7 | 8 | create () { 9 | this.add.image(400, 300, 'space') 10 | 11 | this.add.text(400, 200, 'Game Over\n\n< menu >', { 12 | align: 'center', 13 | fill: 'white', 14 | fontFamily: 'sans-serif', 15 | fontSize: 48, 16 | }) 17 | .setOrigin(0.5, 0) 18 | 19 | this.input.on('pointerdown', function () { 20 | this.scene.switch('menu') 21 | }, this) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/scenes/MenuScene.ts: -------------------------------------------------------------------------------- 1 | import Phaser from 'phaser' 2 | 3 | export default class MenuScene extends Phaser.Scene { 4 | constructor () { 5 | super({ key: 'menu' }) 6 | } 7 | 8 | create () { 9 | // background 10 | this.add.image(400, 300, 'space') 11 | 12 | this.add.text(400, 200, 'A quick maths game\n\n< play >', { 13 | align: 'center', 14 | fill: 'white', 15 | fontFamily: 'sans-serif', 16 | fontSize: 48, 17 | }) 18 | .setOrigin(0.5, 0) 19 | 20 | this.input.on('pointerdown', function () { 21 | this.scene.switch('play') 22 | }, this) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/scenes/BootScene.ts: -------------------------------------------------------------------------------- 1 | import Phaser from 'phaser' 2 | // @ts-ignore 3 | import images from '../assets/*.png' 4 | 5 | export default class BootScene extends Phaser.Scene { 6 | constructor () { 7 | super({ key: 'boot' }) 8 | } 9 | 10 | preload () { 11 | const bg = this.add.rectangle(400, 300, 400, 30, 0x666666) 12 | const bar = this.add.rectangle(bg.x, bg.y, bg.width, bg.height, 0xffffff).setScale(0, 1) 13 | 14 | console.table(images) 15 | 16 | this.load.image('space', images.space) 17 | this.load.image('red', images.red) 18 | 19 | this.load.on('progress', function (progress) { 20 | bar.setScale(progress, 1) 21 | }) 22 | } 23 | 24 | update () { 25 | this.scene.start('menu') 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "phaser-parcel", 3 | "version": "1.0.0", 4 | "description": "A Phaser 3 game template using Parcel bundler", 5 | "main": "src/index.html", 6 | "scripts": { 7 | "dist": "parcel build src/index.html -d docs --public-url ./", 8 | "start": "parcel serve src/index.html", 9 | "clean": "rm -rfv dist && rm -rf .cache", 10 | "test": "jest --watch" 11 | }, 12 | "keywords": [ 13 | "phaser", 14 | "phaser3", 15 | "phaser-boilerplate" 16 | ], 17 | "author": "opyate", 18 | "license": "NONE", 19 | "dependencies": { 20 | "lodash": "^4.17.20", 21 | "phaser": "^3.24.1" 22 | }, 23 | "devDependencies": { 24 | "@babel/core": "^7.12.0", 25 | "@babel/preset-env": "^7.12.0", 26 | "cssnano": "^4.1.10", 27 | "eslint": "^5.16.0", 28 | "eslint-config-semistandard": "^13.0.0", 29 | "eslint-config-standard": "^12.0.0", 30 | "eslint-plugin-import": "^2.17.3", 31 | "eslint-plugin-node": "^8.0.1", 32 | "eslint-plugin-promise": "^4.1.1", 33 | "eslint-plugin-standard": "^4.0.0", 34 | "typescript": "^4.0.3" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/meta/safari-pinned-tab.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 26 | -------------------------------------------------------------------------------- /dist/safari-pinned-tab.a65600d3.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 26 | -------------------------------------------------------------------------------- /docs/safari-pinned-tab.ead9fee4.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 26 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 |