-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added example code from the loader plugin video
Signed-off-by: Scott Westover <[email protected]>
- Loading branch information
1 parent
827753e
commit 69cebb5
Showing
14 changed files
with
1,789 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"eslint.format.enable": true, | ||
"eslint.options": { | ||
"overrideConfigFile": "config/.eslintrc" | ||
}, | ||
"editor.defaultFormatter": "dbaeumer.vscode-eslint", | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit" | ||
}, | ||
"cSpell.words": [ | ||
"devshareacademy", | ||
"mediump", | ||
"tweakpane" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Phaser 3 TypeScript - Loader Plugin Example | ||
|
||
Contains example code for reviewing the Phaser 3 Loader Plugin and how to load assets in the `preload` and `create` methods. | ||
|
||
You can see a live demo of the example here: [Phaser 3 Arcade Physics Conveyor Belt Demo](https://devshareacademy.github.io/phaser-3-typescript-games-and-examples/examples/arcade-physics-conveyor-belt/index.html) | ||
|
||
![Example](./docs/example.gif?raw=true) | ||
|
||
## Local Development | ||
|
||
### Requirements | ||
|
||
[Node.js](https://nodejs.org) and [pNPm](https://pnpm.io/) are required to install dependencies and run scripts via `pnpm`. | ||
|
||
[Vite](https://vitejs.dev/) is required to bundle and serve the web application. This is included as part of the projects dev dependencies. | ||
|
||
### Available Commands | ||
|
||
| Command | Description | | ||
|---------|-------------| | ||
| `pnpm install --frozen-lockfile` | Install project dependencies | | ||
| `pnpm start` | Build project and open web server running project | | ||
| `pnpm build` | Builds code bundle for production | | ||
| `pnpm lint` | Uses ESLint to lint code | | ||
|
||
### Writing Code | ||
|
||
After cloning the repo, run `pnpm install --frozen-lockfile` from your project directory. Then, you can start the local development | ||
server by running `pnpm start`. | ||
|
||
After starting the development server with `pnpm start`, you can edit any files in the `src` folder | ||
and parcel will automatically recompile and reload your server (available at `http://localhost:8080` | ||
by default). | ||
|
||
### Deploying Code | ||
|
||
After you run the `pnpm build` command, your code will be built into a single bundle located at | ||
`dist/*` along with any other assets you project depended. | ||
|
||
If you put the contents of the `dist` folder in a publicly-accessible location (say something like `http://myserver.com`), | ||
you should be able to open `http://myserver.com/index.html` and play your game. | ||
|
||
### 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:8080/path-to-file-your-file/file-name.file-type`. | ||
|
||
## Credits | ||
|
||
The assets used in this demo were made from free assets that were created from the following artists: [ansimuz](https://ansimuz.itch.io/). | ||
|
||
List of assets: | ||
|
||
* [Star Fighter](https://ansimuz.itch.io/star-fighter) | ||
* [Warped Vehicles](https://ansimuz.itch.io/warped-vehicles) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"root": true, | ||
"extends": "@devshareacademy/eslint-config", | ||
"parserOptions": { | ||
"project": "./tsconfig.json" | ||
}, | ||
"rules": {}, | ||
"ignorePatterns": ["node_modules", "dist"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig } from 'vite'; | ||
|
||
export default defineConfig({ | ||
base: "./", | ||
build: { | ||
rollupOptions: { | ||
output: { | ||
entryFileNames: 'assets/js/[name]-[hash].js', | ||
}, | ||
}, | ||
}, | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Phaser 3 - Loader Plugin</title> | ||
<style> | ||
html, | ||
body, | ||
.container { | ||
margin: 0px; | ||
height: 100vh; | ||
width: 100vw; | ||
overflow: hidden; | ||
background: #d7d7d7; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container" id="game-container"> | ||
</div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "@devshareacademy/phaser-3-loader-plugin", | ||
"version": "1.0.0", | ||
"description": "Example used for reviewing the phaser 3 loader plugin.", | ||
"scripts": { | ||
"start": "vite --config config/vite.config.js", | ||
"build": "tsc && vite build --config config/vite.config.js", | ||
"serve": "vite preview --config config/vite.config.js", | ||
"lint": "eslint ./src --ext .ts,.tsx --config ./config/.eslintrc" | ||
}, | ||
"author": "scottwestover", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/devshareacademy/phaser-3-typescript-games-and-examples.git" | ||
}, | ||
"homepage": "https://github.com/devshareacademy/phaser-3-typescript-games-and-examples", | ||
"devDependencies": { | ||
"@devshareacademy/eslint-config": "0.0.18", | ||
"@devshareacademy/prettier-config": "0.0.6", | ||
"@devshareacademy/tsconfig": "0.0.3", | ||
"@typescript-eslint/eslint-plugin": "7.1.0", | ||
"@typescript-eslint/parser": "7.1.0", | ||
"eslint": "8.57.0", | ||
"eslint-config-prettier": "9.1.0", | ||
"eslint-plugin-prettier": "5.1.3", | ||
"prettier": "3.2.5", | ||
"typescript": "5.3.3", | ||
"vite": "5.1.4" | ||
}, | ||
"dependencies": { | ||
"phaser": "3.80.0" | ||
}, | ||
"resolutions": {}, | ||
"prettier": "@devshareacademy/prettier-config", | ||
"volta": { | ||
"node": "20.11.1", | ||
"yarn": "1.22.11", | ||
"pnpm": "8.15.4" | ||
}, | ||
"engines": { | ||
"node": ">=20.11.0", | ||
"npm": ">=10.2.0", | ||
"pnpm": ">=8.15.0" | ||
} | ||
} |
Oops, something went wrong.