Initial commit

This commit is contained in:
KGrzeg 2021-10-12 15:30:05 +02:00
commit 3ba46bc350
11 changed files with 18382 additions and 0 deletions

4
.eslintignore Normal file
View file

@ -0,0 +1,4 @@
# don't ever lint node_modules
node_modules
# don't lint build output (make sure it's set to your correct build folder name)
dist

19
.eslintrc.js Normal file
View file

@ -0,0 +1,19 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint'
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended'
],
rules: {
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/ban-ts-ignore': 0,
'@typescript-eslint/no-namespace': { 'allowDeclarations': true },
'@typescript-eslint/member-delimiter-style': 0,
'@typescript-eslint/no-explicit-any': 0
}
}

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
/.cache
/dist
/node_modules
/.DS_Store

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 ourcade
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.

18062
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

38
package.json Normal file
View file

@ -0,0 +1,38 @@
{
"name": "hs3jam-miner",
"version": "1.0.0",
"description": "Simple Phaser 3 game for the Hackerspace Trójmiasto's little game jam",
"scripts": {
"start": "parcel src/index.html -p 8000",
"build": "parcel build src/index.html --out-dir dist",
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint ./src --ext .js,.jsx,.ts,.tsx"
},
"author": "Grzegorz Kupczyk",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ourcade/phaser3-parcel-template.git"
},
"homepage": "https://github.com/ourcade/phaser3-parcel-template",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@typescript-eslint/parser": "^2.29.0",
"eslint": "^6.8.0",
"minimist": ">=1.2.2",
"parcel-bundler": "^1.12.5",
"parcel-plugin-clean-easy": "^1.0.2",
"parcel-plugin-static-files-copy": "^2.4.3",
"typescript": "^3.8.3"
},
"dependencies": {
"phaser": "^3.55.2"
},
"parcelCleanPaths": [
"dist"
],
"staticFiles": {
"staticPath": "public",
"watcherGlob": "**"
}
}

138
readme.md Normal file
View file

@ -0,0 +1,138 @@
This is a fork of [phaser3-typescript-parcel-template](https://github.com/ourcade/phaser3-typescript-parcel-template)
![phaser3-parceljs-template](https://user-images.githubusercontent.com/2236153/71606463-37a0da80-2b2e-11ea-9b5f-5d26ccc84f91.png)
# Phaser 3 + TypeScript + Parcel Template
> For people who want to spend time making Phaser 3 games in TypeScript instead of configuring build tools.
![License](https://img.shields.io/badge/license-MIT-green)
This is a TypeScript specific fork of [phaser3-parcel-template](https://github.com/ourcade/phaser3-parcel-template).
## Prerequisites
You'll need [Node.js](https://nodejs.org/en/), [npm](https://www.npmjs.com/), and [Parcel](https://parceljs.org/) installed.
It is highly recommended to use [Node Version Manager](https://github.com/nvm-sh/nvm) (nvm) to install Node.js and npm.
For Windows users there is [Node Version Manager for Windows](https://github.com/coreybutler/nvm-windows).
Install Node.js and `npm` with `nvm`:
```bash
nvm install node
nvm use node
```
Replace 'node' with 'latest' for `nvm-windows`.
Then install Parcel:
```bash
npm install -g parcel-bundler
```
## Getting Started
Clone this repository to your local machine:
```bash
git clone https://github.com/ourcade/phaser3-typescript-parcel-template.git
```
This will create a folder named `phaser3-typescript-parcel-template`. You can specify a different folder name like this:
```bash
git clone https://github.com/ourcade/phaser3-typescript-parcel-template.git my-folder-name
```
Go into your new project folder and install dependencies:
```bash
cd phaser3-typescript-parcel-template # or 'my-folder-name'
npm install
```
Start development server:
```
npm run start
```
To create a production build:
```
npm run build
```
Production files will be placed in the `dist` folder. Then upload those files to a web server. 🎉
## Project Structure
```
.
├── dist
├── node_modules
├── public
├── src
│ ├── scenes
│ │ ├── HelloWorldScene.ts
│ ├── index.html
│ ├── main.ts
├── package.json
```
The contents of this template is the basic [Phaser 3 getting started example](http://phaser.io/tutorials/getting-started-phaser3/part5).
This template assumes you will want to organize your code into multiple files and use TypeScript.
TypeScript files are intended for the `src` folder. `main.ts` is the entry point referenced by `index.html`.
Other than that there is no opinion on how you should structure your project. There is a `scenes` folder in `src` where the `HelloWorldScene.ts` lives but you can do whatever you want.
## Static Assets
Any static assets like images or audio files should be placed in the `public` folder. It'll then be served at http://localhost:8000/images/my-image.png
Example `public` structure:
```
public
├── images
│ ├── my-image.png
├── music
│ ├── ...
├── sfx
│ ├── ...
```
They can then be loaded by Phaser with `this.image.load('my-image', 'images/my-image.png')`.
## TypeScript ESLint
This template uses a basic `typescript-eslint` set up for code linting.
It does not aim to be opinionated.
## Dev Server Port
You can change the dev server's port number by modifying the `start` script in `package.json`. We use Parcel's `-p` option to specify the port number.
The script looks like this:
```
parcel src/index.html -p 8000
```
Change 8000 to whatever you want.
## Other Notes
[parcel-plugin-clean-easy](https://github.com/lifuzhao100/parcel-plugin-clean-easy) is used to ensure only the latest files are in the `dist` folder. You can modify this behavior by changing `parcelCleanPaths` in `package.json`.
[parcel-plugin-static-files](https://github.com/elwin013/parcel-plugin-static-files-copy#readme) is used to copy static files from `public` into the output directory and serve it. You can add additional paths by modifying `staticFiles` in `package.json`.
## License
[MIT License](https://github.com/ourcade/phaser3-typescript-parcel-template/blob/master/LICENSE)

8
src/index.html Normal file
View file

@ -0,0 +1,8 @@
<html>
<head>
<title>Phaser3 + Parceljs Template</title>
</head>
<body>
<script src="main.ts"></script>
</body>
</html>

18
src/main.ts Normal file
View file

@ -0,0 +1,18 @@
import Phaser from 'phaser'
import HelloWorldScene from './scenes/HelloWorldScene'
const config: Phaser.Types.Core.GameConfig = {
type: Phaser.AUTO,
width: 800,
height: 600,
physics: {
default: 'arcade',
arcade: {
gravity: { y: 200 }
}
},
scene: [HelloWorldScene]
}
export default new Phaser.Game(config)

View file

@ -0,0 +1,39 @@
import Phaser from 'phaser'
export default class HelloWorldScene extends Phaser.Scene
{
constructor()
{
super('hello-world')
}
preload()
{
this.load.setBaseURL('http://labs.phaser.io')
this.load.image('sky', 'assets/skies/space3.png')
this.load.image('logo', 'assets/sprites/phaser3-logo.png')
this.load.image('red', 'assets/particles/red.png')
}
create()
{
this.add.image(400, 300, 'sky')
const particles = this.add.particles('red')
const emitter = particles.createEmitter({
speed: 100,
scale: { start: 1, end: 0 },
blendMode: 'ADD'
})
const logo = this.physics.add.image(400, 100, 'logo')
logo.setVelocity(100, 200)
logo.setBounce(1, 1)
logo.setCollideWorldBounds(true)
emitter.startFollow(logo)
}
}

31
tsconfig.json Normal file
View file

@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "es2016",
"module": "es6",
"strict": true,
"noImplicitAny": false,
"noEmit": true,
"allowJs": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": "./src",
"paths": {
"~/*": ["./*"]
},
"typeRoots": [
"node_modules/@types",
"node_module/phaser/types"
],
"types": [
"phaser"
]
},
"include": [
"src/**/*"
]
}