├── .gitignore ├── src ├── lib │ └── phaser.js ├── game │ └── Carrot.js ├── main.js └── scenes │ ├── GameOver.js │ └── Game.js ├── jsconfig.json ├── assets ├── carrot.png ├── bg_layer1.png ├── bunny1_jump.png ├── bunny1_stand.png ├── ground_grass.png └── sfx │ └── phaseJump1.wav ├── .gitattributes ├── index.html ├── LICENSE ├── readme.md └── .github └── workflows └── main.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /src/lib/phaser.js: -------------------------------------------------------------------------------- 1 | export default window.Phaser -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "es6", 4 | "target": "es6" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /assets/carrot.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2c10380a2ac669990ca5086cb2abce202238c6fefcb654ca6d8f9addaeb2201c 3 | size 1366 4 | -------------------------------------------------------------------------------- /assets/bg_layer1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:27e7aa05db99aee759f366f42aa1948322987e9d563c9a124924801dece8fb44 3 | size 621 4 | -------------------------------------------------------------------------------- /assets/bunny1_jump.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:75c81738e48de0d9526cd12487fb211e6f2528a2db44e81ca06682022fefb18a 3 | size 3701 4 | -------------------------------------------------------------------------------- /assets/bunny1_stand.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7e04a1c77614c67fd82db79ba670e42d8caa8fb2bad7581e5d84f29db248145e 3 | size 3555 4 | -------------------------------------------------------------------------------- /assets/ground_grass.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f9b8c2aa510b0804dc99f4c621a6aa801c154225512ec4acddb775b7921cab4f 3 | size 2644 4 | -------------------------------------------------------------------------------- /assets/sfx/phaseJump1.wav: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9d7cea60e73f18a80091ac075a0754ecca60fee67feac72da4ee3e62d37559e7 3 | size 83278 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.png filter=lfs diff=lfs merge=lfs -text 2 | *.jpg filter=lfs diff=lfs merge=lfs -text 3 | *jpeg filter=lfs diff=lfs merge=lfs -text 4 | *.gif filter=lfs diff=lfs merge=lfs -text 5 | *.wav filter=lfs diff=lfs merge=lfs -text 6 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Bunny Jump! 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/game/Carrot.js: -------------------------------------------------------------------------------- 1 | import Phaser from '../lib/phaser.js' 2 | 3 | export default class Carrot extends Phaser.Physics.Arcade.Sprite 4 | { 5 | /** 6 | * @param {Phaser.Scene} scene 7 | * @param {number} x 8 | * @param {number} y 9 | * @param {string} texture 10 | */ 11 | constructor(scene, x, y, texture = 'carrot') 12 | { 13 | super(scene, x, y, texture) 14 | 15 | this.setScale(0.5) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Phaser from './lib/phaser.js' 2 | 3 | import Game from './scenes/Game.js' 4 | import GameOver from './scenes/GameOver.js' 5 | 6 | export default new Phaser.Game({ 7 | type: Phaser.AUTO, 8 | width: 480, 9 | height: 640, 10 | scene: [Game, GameOver], 11 | physics: { 12 | default: 'arcade', 13 | arcade: { 14 | gravity: { 15 | y: 200 16 | }, 17 | debug: true 18 | } 19 | } 20 | }) 21 | -------------------------------------------------------------------------------- /src/scenes/GameOver.js: -------------------------------------------------------------------------------- 1 | import Phaser from '../lib/phaser.js' 2 | 3 | export default class GameOver extends Phaser.Scene 4 | { 5 | constructor() 6 | { 7 | super('game-over') 8 | } 9 | 10 | create() 11 | { 12 | const width = this.scale.width 13 | const height = this.scale.height 14 | 15 | this.add.text(width * 0.5, height * 0.5, 'Game Over', { 16 | fontSize: 48 17 | }) 18 | .setOrigin(0.5) 19 | 20 | this.input.keyboard.once('keydown-SPACE', () => { 21 | this.scene.start('game') 22 | }) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 ourcade 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Infinite Jumper Template 2 | > A starting point written in Phaser 3 with modern JavaScript 3 | 4 | ![License](https://img.shields.io/badge/license-MIT-green) 5 | 6 | ## Overview 7 | 8 | This is the source code for an infinite jumper starting point in Phaser 3 as created by the free book: [Infinite Jumper in Phaser 3 with Modern JavaScript](https://ourcade.co/books/infinite-jumper-phaser3/). 9 | 10 | This project uses no tooling and is intended for beginners to easily start developing games for the web. 11 | 12 | ## Getting Started 13 | 14 | The Infinite Jumper in Phaser 3 with Modern JavaScript book suggests using the Live Server extension for Visual Studio Code to launch a development server. 15 | 16 | JavaScript files are included via the `