Spaces:
Sleeping
Sleeping
Add application file
Browse files- .gitignore +48 -0
- Dockerfile +26 -0
- LICENSE +21 -0
- README.md +228 -10
- log.js +36 -0
- next.config.js +15 -0
- next.config.mjs +7 -0
- package-lock.json +479 -0
- package.json +42 -0
- public/assets/bg.png +0 -0
- public/assets/logo.png +0 -0
- public/assets/star.png +0 -0
- public/favicon.png +0 -0
- screenshot.png +0 -0
- src/App.tsx +104 -0
- src/game/EventBus.ts +5 -0
- src/game/PhaserGame.tsx +86 -0
- src/game/config.ts +21 -0
- src/game/main.ts +31 -0
- src/game/scenes/Boot.ts +22 -0
- src/game/scenes/Game.ts +36 -0
- src/game/scenes/GameOver.ts +36 -0
- src/game/scenes/MainMenu.ts +76 -0
- src/game/scenes/Preloader.ts +47 -0
- src/pages/_app.tsx +6 -0
- src/pages/_document.tsx +13 -0
- src/pages/index.tsx +24 -0
- src/styles/Home.module.css +0 -0
- src/styles/globals.css +48 -0
- tsconfig.json +22 -0
.gitignore
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Dependencies
|
2 |
+
/node_modules
|
3 |
+
/.pnp
|
4 |
+
.pnp.js
|
5 |
+
|
6 |
+
# Testing
|
7 |
+
/coverage
|
8 |
+
|
9 |
+
# Next.js
|
10 |
+
/.next/
|
11 |
+
/out/
|
12 |
+
|
13 |
+
# Production
|
14 |
+
/build
|
15 |
+
/dist
|
16 |
+
|
17 |
+
# Misc
|
18 |
+
.DS_Store
|
19 |
+
*.pem
|
20 |
+
.env
|
21 |
+
.env.local
|
22 |
+
.env.development.local
|
23 |
+
.env.test.local
|
24 |
+
.env.production.local
|
25 |
+
|
26 |
+
# Debug
|
27 |
+
npm-debug.log*
|
28 |
+
yarn-debug.log*
|
29 |
+
yarn-error.log*
|
30 |
+
|
31 |
+
# IDE
|
32 |
+
.idea
|
33 |
+
.vscode
|
34 |
+
*.suo
|
35 |
+
*.ntvs*
|
36 |
+
*.njsproj
|
37 |
+
*.sln
|
38 |
+
*.sw?
|
39 |
+
|
40 |
+
# Vercel
|
41 |
+
.vercel
|
42 |
+
|
43 |
+
# TypeScript
|
44 |
+
*.tsbuildinfo
|
45 |
+
next-env.d.ts
|
46 |
+
|
47 |
+
# Cache
|
48 |
+
.cache
|
Dockerfile
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM node:18-alpine
|
2 |
+
|
3 |
+
WORKDIR /app
|
4 |
+
|
5 |
+
# Copie des fichiers de configuration
|
6 |
+
COPY package*.json ./
|
7 |
+
COPY next.config.js ./
|
8 |
+
COPY tsconfig.json ./
|
9 |
+
|
10 |
+
# Installation des dépendances
|
11 |
+
RUN npm install
|
12 |
+
|
13 |
+
# Copie du reste du code source
|
14 |
+
COPY . .
|
15 |
+
|
16 |
+
# Build de l'application
|
17 |
+
RUN npm run build
|
18 |
+
|
19 |
+
# Exposition du port 7860
|
20 |
+
EXPOSE 7860
|
21 |
+
|
22 |
+
# Configuration de la variable d'environnement pour le port
|
23 |
+
ENV PORT=7860
|
24 |
+
|
25 |
+
# Démarrage de l'application
|
26 |
+
CMD ["npm", "start"]
|
LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2024 Phaser
|
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.
|
README.md
CHANGED
@@ -1,10 +1,228 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Phaser Next.js Template
|
2 |
+
|
3 |
+
This is a Phaser 3 project template that uses the Next.js framework. It includes a bridge for React to Phaser game communication, hot-reloading for quick development workflow and scripts to generate production-ready builds.
|
4 |
+
|
5 |
+
### Versions
|
6 |
+
|
7 |
+
This template has been updated for:
|
8 |
+
|
9 |
+
- [Phaser 3.87.0](https://github.com/phaserjs/phaser)
|
10 |
+
- [Next.js 14.2.3](https://github.com/vercel/next.js)
|
11 |
+
- [TypeScript 5](https://github.com/microsoft/TypeScript)
|
12 |
+
|
13 |
+

|
14 |
+
|
15 |
+
## Requirements
|
16 |
+
|
17 |
+
[Node.js](https://nodejs.org) is required to install dependencies and run scripts via `npm`.
|
18 |
+
|
19 |
+
## Available Commands
|
20 |
+
|
21 |
+
| Command | Description |
|
22 |
+
|---------|-------------|
|
23 |
+
| `npm install` | Install project dependencies |
|
24 |
+
| `npm run dev` | Launch a development web server |
|
25 |
+
| `npm run build` | Create a production build in the `dist` folder |
|
26 |
+
| `npm run dev-nolog` | Launch a development web server without sending anonymous data (see "About log.js" below) |
|
27 |
+
| `npm run build-nolog` | Create a production build in the `dist` folder without sending anonymous data (see "About log.js" below) |
|
28 |
+
|
29 |
+
## Writing Code
|
30 |
+
|
31 |
+
After cloning the repo, run `npm install` from your project directory. Then, you can start the local development server by running `npm run dev`.
|
32 |
+
|
33 |
+
The local development server runs on `http://localhost:8080` by default. Please see the Next.js documentation if you wish to change this, or add SSL support.
|
34 |
+
|
35 |
+
Once the server is running you can edit any of the files in the `src` folder. Next.js will automatically recompile your code and then reload the browser.
|
36 |
+
|
37 |
+
## Template Project Structure
|
38 |
+
|
39 |
+
We have provided a default project structure to get you started. This is as follows:
|
40 |
+
|
41 |
+
- `src/pages/_document.tsx` - A basic Next.js component entry point. It is used to define the `<html>` and `<body>` tags and other globally shared UI.
|
42 |
+
- `src` - Contains the Next.js client source code.
|
43 |
+
- `src/styles/globals.css` - Some simple global CSS rules to help with page layout. You can enable Tailwind CSS here.
|
44 |
+
- `src/page/_app.tsx` - The main Next.js component.
|
45 |
+
- `src/App.tsx` - Midleware component used to run Phaser in client mode.
|
46 |
+
- `src/game/PhaserGame.tsx` - The React component that initializes the Phaser Game and serve like a bridge between React and Phaser.
|
47 |
+
- `src/game/EventBus.ts` - A simple event bus to communicate between React and Phaser.
|
48 |
+
- `src/game` - Contains the game source code.
|
49 |
+
- `src/game/main.tsx` - The main **game** entry point. This contains the game configuration and start the game.
|
50 |
+
- `src/game/scenes/` - The Phaser Scenes are in this folder.
|
51 |
+
- `public/favicon.png` - The default favicon for the project.
|
52 |
+
- `public/assets` - Contains the static assets used by the game.
|
53 |
+
## React Bridge
|
54 |
+
|
55 |
+
The `PhaserGame.tsx` component is the bridge between React and Phaser. It initializes the Phaser game and passes events between the two.
|
56 |
+
|
57 |
+
To communicate between React and Phaser, you can use the **EventBus.js** file. This is a simple event bus that allows you to emit and listen for events from both React and Phaser.
|
58 |
+
|
59 |
+
```js
|
60 |
+
// In React
|
61 |
+
import { EventBus } from './EventBus';
|
62 |
+
|
63 |
+
// Emit an event
|
64 |
+
EventBus.emit('event-name', data);
|
65 |
+
|
66 |
+
// In Phaser
|
67 |
+
// Listen for an event
|
68 |
+
EventBus.on('event-name', (data) => {
|
69 |
+
// Do something with the data
|
70 |
+
});
|
71 |
+
```
|
72 |
+
|
73 |
+
In addition to this, the `PhaserGame` component exposes the Phaser game instance along with the most recently active Phaser Scene using React forwardRef.
|
74 |
+
|
75 |
+
Once exposed, you can access them like any regular react reference.
|
76 |
+
|
77 |
+
## Phaser Scene Handling
|
78 |
+
|
79 |
+
In Phaser, the Scene is the lifeblood of your game. It is where you sprites, game logic and all of the Phaser systems live. You can also have multiple scenes running at the same time. This template provides a way to obtain the current active scene from React.
|
80 |
+
|
81 |
+
You can get the current Phaser Scene from the component event `"current-active-scene"`. In order to do this, you need to emit the event `"current-scene-ready"` from the Phaser Scene class. This event should be emitted when the scene is ready to be used. You can see this done in all of the Scenes in our template.
|
82 |
+
|
83 |
+
**Important**: When you add a new Scene to your game, make sure you expose to React by emitting the `"current-scene-ready"` event via the `EventBus`, like this:
|
84 |
+
|
85 |
+
|
86 |
+
```ts
|
87 |
+
class MyScene extends Phaser.Scene
|
88 |
+
{
|
89 |
+
constructor ()
|
90 |
+
{
|
91 |
+
super('MyScene');
|
92 |
+
}
|
93 |
+
|
94 |
+
create ()
|
95 |
+
{
|
96 |
+
// Your Game Objects and logic here
|
97 |
+
|
98 |
+
// At the end of create method:
|
99 |
+
EventBus.emit('current-scene-ready', this);
|
100 |
+
}
|
101 |
+
}
|
102 |
+
```
|
103 |
+
|
104 |
+
You don't have to emit this event if you don't need to access the specific scene from React. Also, you don't have to emit it at the end of `create`, you can emit it at any point. For example, should your Scene be waiting for a network request or API call to complete, it could emit the event once that data is ready.
|
105 |
+
|
106 |
+
### React Component Example
|
107 |
+
|
108 |
+
Here's an example of how to access Phaser data for use in a React Component:
|
109 |
+
|
110 |
+
```ts
|
111 |
+
import { useRef } from 'react';
|
112 |
+
import { IRefPhaserGame } from "./game/PhaserGame";
|
113 |
+
|
114 |
+
// In a parent component
|
115 |
+
const ReactComponent = () => {
|
116 |
+
|
117 |
+
const phaserRef = useRef<IRefPhaserGame>(); // you can access to this ref from phaserRef.current
|
118 |
+
|
119 |
+
const onCurrentActiveScene = (scene: Phaser.Scene) => {
|
120 |
+
|
121 |
+
// This is invoked
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
return (
|
126 |
+
...
|
127 |
+
<PhaserGame ref={phaserRef} currentActiveScene={onCurrentActiveScene} />
|
128 |
+
...
|
129 |
+
);
|
130 |
+
|
131 |
+
}
|
132 |
+
```
|
133 |
+
|
134 |
+
In the code above, you can get a reference to the current Phaser Game instance and the current Scene by creating a reference with `useRef()` and assign to PhaserGame component.
|
135 |
+
|
136 |
+
From this state reference, the game instance is available via `phaserRef.current.game` and the most recently active Scene via `phaserRef.current.scene`.
|
137 |
+
|
138 |
+
The `onCurrentActiveScene` callback will also be invoked whenever the the Phaser Scene changes, as long as you emit the event via the EventBus, as outlined above.
|
139 |
+
|
140 |
+
## Handling Assets
|
141 |
+
|
142 |
+
To load your static games files such as audio files, images, videos, etc place them into the `public/assets` folder. Then you can use this path in the Loader calls within Phaser:
|
143 |
+
|
144 |
+
```js
|
145 |
+
preload ()
|
146 |
+
{
|
147 |
+
// This is an example of loading a static image
|
148 |
+
// from the public/assets folder:
|
149 |
+
this.load.image('background', 'assets/bg.png');
|
150 |
+
}
|
151 |
+
```
|
152 |
+
|
153 |
+
When you issue the `npm run build` command, all static assets are automatically copied to the `dist/assets` folder.
|
154 |
+
|
155 |
+
## Deploying to Production
|
156 |
+
|
157 |
+
After you run the `npm run build` command, your code will be built into a single bundle and saved to the `dist` folder, along with any other assets your project imported, or stored in the public assets folder.
|
158 |
+
|
159 |
+
In order to deploy your game, you will need to upload *all* of the contents of the `dist` folder to a public facing web server.
|
160 |
+
|
161 |
+
## Customizing the Template
|
162 |
+
|
163 |
+
### Next.js
|
164 |
+
|
165 |
+
If you want to customize your build, such as adding plugin (i.e. for loading CSS or fonts), you can modify the `next.config.mjs` file for cross-project changes, or you can modify and/or create new configuration files and target them in specific npm tasks inside of `package.json`. Please see the [Next.js documentation](https://nextjs.org/docs) for more information.
|
166 |
+
|
167 |
+
## About log.js
|
168 |
+
|
169 |
+
If you inspect our node scripts you will see there is a file called `log.js`. This file makes a single silent API call to a domain called `gryzor.co`. This domain is owned by Phaser Studio Inc. The domain name is a homage to one of our favorite retro games.
|
170 |
+
|
171 |
+
We send the following 3 pieces of data to this API: The name of the template being used (vue, react, etc). If the build was 'dev' or 'prod' and finally the version of Phaser being used.
|
172 |
+
|
173 |
+
At no point is any personal data collected or sent. We don't know about your project files, device, browser or anything else. Feel free to inspect the `log.js` file to confirm this.
|
174 |
+
|
175 |
+
Why do we do this? Because being open source means we have no visible metrics about which of our templates are being used. We work hard to maintain a large and diverse set of templates for Phaser developers and this is our small anonymous way to determine if that work is actually paying off, or not. In short, it helps us ensure we're building the tools for you.
|
176 |
+
|
177 |
+
However, if you don't want to send any data, you can use these commands instead:
|
178 |
+
|
179 |
+
Dev:
|
180 |
+
|
181 |
+
```bash
|
182 |
+
npm run dev-nolog
|
183 |
+
```
|
184 |
+
|
185 |
+
Build:
|
186 |
+
|
187 |
+
```bash
|
188 |
+
npm run build-nolog
|
189 |
+
```
|
190 |
+
|
191 |
+
Or, to disable the log entirely, simply delete the file `log.js` and remove the call to it in the `scripts` section of `package.json`:
|
192 |
+
|
193 |
+
Before:
|
194 |
+
|
195 |
+
```json
|
196 |
+
"scripts": {
|
197 |
+
"dev": "node log.js dev & dev-template-script",
|
198 |
+
"build": "node log.js build & build-template-script"
|
199 |
+
},
|
200 |
+
```
|
201 |
+
|
202 |
+
After:
|
203 |
+
|
204 |
+
```json
|
205 |
+
"scripts": {
|
206 |
+
"dev": "dev-template-script",
|
207 |
+
"build": "build-template-script"
|
208 |
+
},
|
209 |
+
```
|
210 |
+
|
211 |
+
Either of these will stop `log.js` from running. If you do decide to do this, please could you at least join our Discord and tell us which template you're using! Or send us a quick email. Either will be super-helpful, thank you.
|
212 |
+
|
213 |
+
## Join the Phaser Community!
|
214 |
+
|
215 |
+
We love to see what developers like you create with Phaser! It really motivates us to keep improving. So please join our community and show-off your work 😄
|
216 |
+
|
217 |
+
**Visit:** The [Phaser website](https://phaser.io) and follow on [Phaser Twitter](https://twitter.com/phaser_)<br />
|
218 |
+
**Play:** Some of the amazing games [#madewithphaser](https://twitter.com/search?q=%23madewithphaser&src=typed_query&f=live)<br />
|
219 |
+
**Learn:** [API Docs](https://newdocs.phaser.io), [Support Forum](https://phaser.discourse.group/) and [StackOverflow](https://stackoverflow.com/questions/tagged/phaser-framework)<br />
|
220 |
+
**Discord:** Join us on [Discord](https://discord.gg/phaser)<br />
|
221 |
+
**Code:** 2000+ [Examples](https://labs.phaser.io)<br />
|
222 |
+
**Read:** The [Phaser World](https://phaser.io/community/newsletter) Newsletter<br />
|
223 |
+
|
224 |
+
Created by [Phaser Studio](mailto:support@phaser.io). Powered by coffee, anime, pixels and love.
|
225 |
+
|
226 |
+
The Phaser logo and characters are © 2011 - 2024 Phaser Studio Inc.
|
227 |
+
|
228 |
+
All rights reserved.
|
log.js
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const fs = require('fs');
|
2 |
+
const https = require('https');
|
3 |
+
|
4 |
+
const main = async () => {
|
5 |
+
const args = process.argv.slice(2);
|
6 |
+
const packageData = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
7 |
+
const event = args[0] || 'unknown';
|
8 |
+
const phaserVersion = packageData.dependencies.phaser;
|
9 |
+
|
10 |
+
const options = {
|
11 |
+
hostname: 'gryzor.co',
|
12 |
+
port: 443,
|
13 |
+
path: `/v/${event}/${phaserVersion}/${packageData.name}`,
|
14 |
+
method: 'GET'
|
15 |
+
};
|
16 |
+
|
17 |
+
try {
|
18 |
+
const req = https.request(options, (res) => {
|
19 |
+
res.on('data', () => {});
|
20 |
+
res.on('end', () => {
|
21 |
+
process.exit(0);
|
22 |
+
});
|
23 |
+
});
|
24 |
+
|
25 |
+
req.on('error', (error) => {
|
26 |
+
process.exit(1);
|
27 |
+
});
|
28 |
+
|
29 |
+
req.end();
|
30 |
+
} catch (error) {
|
31 |
+
// Silence is the canvas where the soul paints its most profound thoughts.
|
32 |
+
process.exit(1);
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
main();
|
next.config.js
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/** @type {import('next').NextConfig} */
|
2 |
+
const nextConfig = {
|
3 |
+
reactStrictMode: true,
|
4 |
+
assetPrefix: process.env.NODE_ENV === 'production' ? '.' : '',
|
5 |
+
images: {
|
6 |
+
domains: ['huggingface.co'],
|
7 |
+
unoptimized: true,
|
8 |
+
},
|
9 |
+
server: {
|
10 |
+
port: 7860,
|
11 |
+
host: '0.0.0.0'
|
12 |
+
},
|
13 |
+
}
|
14 |
+
|
15 |
+
module.exports = nextConfig
|
next.config.mjs
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/** @type {import('next').NextConfig} */
|
2 |
+
const nextConfig = {
|
3 |
+
output: 'export',
|
4 |
+
distDir: 'dist'
|
5 |
+
};
|
6 |
+
|
7 |
+
export default nextConfig;
|
package-lock.json
ADDED
@@ -0,0 +1,479 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "template-nextjs",
|
3 |
+
"version": "1.1.1",
|
4 |
+
"lockfileVersion": 3,
|
5 |
+
"requires": true,
|
6 |
+
"packages": {
|
7 |
+
"": {
|
8 |
+
"name": "template-nextjs",
|
9 |
+
"version": "1.1.1",
|
10 |
+
"license": "MIT",
|
11 |
+
"dependencies": {
|
12 |
+
"next": "14.2.3",
|
13 |
+
"phaser": "^3.87.0",
|
14 |
+
"react": "^18",
|
15 |
+
"react-dom": "^18"
|
16 |
+
},
|
17 |
+
"devDependencies": {
|
18 |
+
"@types/node": "^20",
|
19 |
+
"@types/react": "^18",
|
20 |
+
"@types/react-dom": "^18",
|
21 |
+
"typescript": "^5"
|
22 |
+
}
|
23 |
+
},
|
24 |
+
"node_modules/@next/env": {
|
25 |
+
"version": "14.2.3",
|
26 |
+
"resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.3.tgz",
|
27 |
+
"integrity": "sha512-W7fd7IbkfmeeY2gXrzJYDx8D2lWKbVoTIj1o1ScPHNzvp30s1AuoEFSdr39bC5sjxJaxTtq3OTCZboNp0lNWHA=="
|
28 |
+
},
|
29 |
+
"node_modules/@next/swc-darwin-arm64": {
|
30 |
+
"version": "14.2.3",
|
31 |
+
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.3.tgz",
|
32 |
+
"integrity": "sha512-3pEYo/RaGqPP0YzwnlmPN2puaF2WMLM3apt5jLW2fFdXD9+pqcoTzRk+iZsf8ta7+quAe4Q6Ms0nR0SFGFdS1A==",
|
33 |
+
"cpu": [
|
34 |
+
"arm64"
|
35 |
+
],
|
36 |
+
"optional": true,
|
37 |
+
"os": [
|
38 |
+
"darwin"
|
39 |
+
],
|
40 |
+
"engines": {
|
41 |
+
"node": ">= 10"
|
42 |
+
}
|
43 |
+
},
|
44 |
+
"node_modules/@next/swc-darwin-x64": {
|
45 |
+
"version": "14.2.3",
|
46 |
+
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.3.tgz",
|
47 |
+
"integrity": "sha512-6adp7waE6P1TYFSXpY366xwsOnEXM+y1kgRpjSRVI2CBDOcbRjsJ67Z6EgKIqWIue52d2q/Mx8g9MszARj8IEA==",
|
48 |
+
"cpu": [
|
49 |
+
"x64"
|
50 |
+
],
|
51 |
+
"optional": true,
|
52 |
+
"os": [
|
53 |
+
"darwin"
|
54 |
+
],
|
55 |
+
"engines": {
|
56 |
+
"node": ">= 10"
|
57 |
+
}
|
58 |
+
},
|
59 |
+
"node_modules/@next/swc-linux-arm64-gnu": {
|
60 |
+
"version": "14.2.3",
|
61 |
+
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.3.tgz",
|
62 |
+
"integrity": "sha512-cuzCE/1G0ZSnTAHJPUT1rPgQx1w5tzSX7POXSLaS7w2nIUJUD+e25QoXD/hMfxbsT9rslEXugWypJMILBj/QsA==",
|
63 |
+
"cpu": [
|
64 |
+
"arm64"
|
65 |
+
],
|
66 |
+
"optional": true,
|
67 |
+
"os": [
|
68 |
+
"linux"
|
69 |
+
],
|
70 |
+
"engines": {
|
71 |
+
"node": ">= 10"
|
72 |
+
}
|
73 |
+
},
|
74 |
+
"node_modules/@next/swc-linux-arm64-musl": {
|
75 |
+
"version": "14.2.3",
|
76 |
+
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.3.tgz",
|
77 |
+
"integrity": "sha512-0D4/oMM2Y9Ta3nGuCcQN8jjJjmDPYpHX9OJzqk42NZGJocU2MqhBq5tWkJrUQOQY9N+In9xOdymzapM09GeiZw==",
|
78 |
+
"cpu": [
|
79 |
+
"arm64"
|
80 |
+
],
|
81 |
+
"optional": true,
|
82 |
+
"os": [
|
83 |
+
"linux"
|
84 |
+
],
|
85 |
+
"engines": {
|
86 |
+
"node": ">= 10"
|
87 |
+
}
|
88 |
+
},
|
89 |
+
"node_modules/@next/swc-linux-x64-gnu": {
|
90 |
+
"version": "14.2.3",
|
91 |
+
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.3.tgz",
|
92 |
+
"integrity": "sha512-ENPiNnBNDInBLyUU5ii8PMQh+4XLr4pG51tOp6aJ9xqFQ2iRI6IH0Ds2yJkAzNV1CfyagcyzPfROMViS2wOZ9w==",
|
93 |
+
"cpu": [
|
94 |
+
"x64"
|
95 |
+
],
|
96 |
+
"optional": true,
|
97 |
+
"os": [
|
98 |
+
"linux"
|
99 |
+
],
|
100 |
+
"engines": {
|
101 |
+
"node": ">= 10"
|
102 |
+
}
|
103 |
+
},
|
104 |
+
"node_modules/@next/swc-linux-x64-musl": {
|
105 |
+
"version": "14.2.3",
|
106 |
+
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.3.tgz",
|
107 |
+
"integrity": "sha512-BTAbq0LnCbF5MtoM7I/9UeUu/8ZBY0i8SFjUMCbPDOLv+un67e2JgyN4pmgfXBwy/I+RHu8q+k+MCkDN6P9ViQ==",
|
108 |
+
"cpu": [
|
109 |
+
"x64"
|
110 |
+
],
|
111 |
+
"optional": true,
|
112 |
+
"os": [
|
113 |
+
"linux"
|
114 |
+
],
|
115 |
+
"engines": {
|
116 |
+
"node": ">= 10"
|
117 |
+
}
|
118 |
+
},
|
119 |
+
"node_modules/@next/swc-win32-arm64-msvc": {
|
120 |
+
"version": "14.2.3",
|
121 |
+
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.3.tgz",
|
122 |
+
"integrity": "sha512-AEHIw/dhAMLNFJFJIJIyOFDzrzI5bAjI9J26gbO5xhAKHYTZ9Or04BesFPXiAYXDNdrwTP2dQceYA4dL1geu8A==",
|
123 |
+
"cpu": [
|
124 |
+
"arm64"
|
125 |
+
],
|
126 |
+
"optional": true,
|
127 |
+
"os": [
|
128 |
+
"win32"
|
129 |
+
],
|
130 |
+
"engines": {
|
131 |
+
"node": ">= 10"
|
132 |
+
}
|
133 |
+
},
|
134 |
+
"node_modules/@next/swc-win32-ia32-msvc": {
|
135 |
+
"version": "14.2.3",
|
136 |
+
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.3.tgz",
|
137 |
+
"integrity": "sha512-vga40n1q6aYb0CLrM+eEmisfKCR45ixQYXuBXxOOmmoV8sYST9k7E3US32FsY+CkkF7NtzdcebiFT4CHuMSyZw==",
|
138 |
+
"cpu": [
|
139 |
+
"ia32"
|
140 |
+
],
|
141 |
+
"optional": true,
|
142 |
+
"os": [
|
143 |
+
"win32"
|
144 |
+
],
|
145 |
+
"engines": {
|
146 |
+
"node": ">= 10"
|
147 |
+
}
|
148 |
+
},
|
149 |
+
"node_modules/@next/swc-win32-x64-msvc": {
|
150 |
+
"version": "14.2.3",
|
151 |
+
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.3.tgz",
|
152 |
+
"integrity": "sha512-Q1/zm43RWynxrO7lW4ehciQVj+5ePBhOK+/K2P7pLFX3JaJ/IZVC69SHidrmZSOkqz7ECIOhhy7XhAFG4JYyHA==",
|
153 |
+
"cpu": [
|
154 |
+
"x64"
|
155 |
+
],
|
156 |
+
"optional": true,
|
157 |
+
"os": [
|
158 |
+
"win32"
|
159 |
+
],
|
160 |
+
"engines": {
|
161 |
+
"node": ">= 10"
|
162 |
+
}
|
163 |
+
},
|
164 |
+
"node_modules/@swc/counter": {
|
165 |
+
"version": "0.1.3",
|
166 |
+
"resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz",
|
167 |
+
"integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ=="
|
168 |
+
},
|
169 |
+
"node_modules/@swc/helpers": {
|
170 |
+
"version": "0.5.5",
|
171 |
+
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.5.tgz",
|
172 |
+
"integrity": "sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A==",
|
173 |
+
"dependencies": {
|
174 |
+
"@swc/counter": "^0.1.3",
|
175 |
+
"tslib": "^2.4.0"
|
176 |
+
}
|
177 |
+
},
|
178 |
+
"node_modules/@types/node": {
|
179 |
+
"version": "20.12.12",
|
180 |
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz",
|
181 |
+
"integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==",
|
182 |
+
"dev": true,
|
183 |
+
"dependencies": {
|
184 |
+
"undici-types": "~5.26.4"
|
185 |
+
}
|
186 |
+
},
|
187 |
+
"node_modules/@types/prop-types": {
|
188 |
+
"version": "15.7.12",
|
189 |
+
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.12.tgz",
|
190 |
+
"integrity": "sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==",
|
191 |
+
"dev": true
|
192 |
+
},
|
193 |
+
"node_modules/@types/react": {
|
194 |
+
"version": "18.3.2",
|
195 |
+
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.2.tgz",
|
196 |
+
"integrity": "sha512-Btgg89dAnqD4vV7R3hlwOxgqobUQKgx3MmrQRi0yYbs/P0ym8XozIAlkqVilPqHQwXs4e9Tf63rrCgl58BcO4w==",
|
197 |
+
"dev": true,
|
198 |
+
"dependencies": {
|
199 |
+
"@types/prop-types": "*",
|
200 |
+
"csstype": "^3.0.2"
|
201 |
+
}
|
202 |
+
},
|
203 |
+
"node_modules/@types/react-dom": {
|
204 |
+
"version": "18.3.0",
|
205 |
+
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.0.tgz",
|
206 |
+
"integrity": "sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==",
|
207 |
+
"dev": true,
|
208 |
+
"dependencies": {
|
209 |
+
"@types/react": "*"
|
210 |
+
}
|
211 |
+
},
|
212 |
+
"node_modules/busboy": {
|
213 |
+
"version": "1.6.0",
|
214 |
+
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
|
215 |
+
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
|
216 |
+
"dependencies": {
|
217 |
+
"streamsearch": "^1.1.0"
|
218 |
+
},
|
219 |
+
"engines": {
|
220 |
+
"node": ">=10.16.0"
|
221 |
+
}
|
222 |
+
},
|
223 |
+
"node_modules/caniuse-lite": {
|
224 |
+
"version": "1.0.30001618",
|
225 |
+
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001618.tgz",
|
226 |
+
"integrity": "sha512-p407+D1tIkDvsEAPS22lJxLQQaG8OTBEqo0KhzfABGk0TU4juBNDSfH0hyAp/HRyx+M8L17z/ltyhxh27FTfQg==",
|
227 |
+
"funding": [
|
228 |
+
{
|
229 |
+
"type": "opencollective",
|
230 |
+
"url": "https://opencollective.com/browserslist"
|
231 |
+
},
|
232 |
+
{
|
233 |
+
"type": "tidelift",
|
234 |
+
"url": "https://tidelift.com/funding/github/npm/caniuse-lite"
|
235 |
+
},
|
236 |
+
{
|
237 |
+
"type": "github",
|
238 |
+
"url": "https://github.com/sponsors/ai"
|
239 |
+
}
|
240 |
+
]
|
241 |
+
},
|
242 |
+
"node_modules/client-only": {
|
243 |
+
"version": "0.0.1",
|
244 |
+
"resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz",
|
245 |
+
"integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA=="
|
246 |
+
},
|
247 |
+
"node_modules/csstype": {
|
248 |
+
"version": "3.1.3",
|
249 |
+
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
|
250 |
+
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",
|
251 |
+
"dev": true
|
252 |
+
},
|
253 |
+
"node_modules/eventemitter3": {
|
254 |
+
"version": "5.0.1",
|
255 |
+
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz",
|
256 |
+
"integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="
|
257 |
+
},
|
258 |
+
"node_modules/graceful-fs": {
|
259 |
+
"version": "4.2.11",
|
260 |
+
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
261 |
+
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="
|
262 |
+
},
|
263 |
+
"node_modules/js-tokens": {
|
264 |
+
"version": "4.0.0",
|
265 |
+
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
266 |
+
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
|
267 |
+
},
|
268 |
+
"node_modules/loose-envify": {
|
269 |
+
"version": "1.4.0",
|
270 |
+
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
|
271 |
+
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
|
272 |
+
"dependencies": {
|
273 |
+
"js-tokens": "^3.0.0 || ^4.0.0"
|
274 |
+
},
|
275 |
+
"bin": {
|
276 |
+
"loose-envify": "cli.js"
|
277 |
+
}
|
278 |
+
},
|
279 |
+
"node_modules/nanoid": {
|
280 |
+
"version": "3.3.7",
|
281 |
+
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
|
282 |
+
"integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==",
|
283 |
+
"funding": [
|
284 |
+
{
|
285 |
+
"type": "github",
|
286 |
+
"url": "https://github.com/sponsors/ai"
|
287 |
+
}
|
288 |
+
],
|
289 |
+
"bin": {
|
290 |
+
"nanoid": "bin/nanoid.cjs"
|
291 |
+
},
|
292 |
+
"engines": {
|
293 |
+
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
294 |
+
}
|
295 |
+
},
|
296 |
+
"node_modules/next": {
|
297 |
+
"version": "14.2.3",
|
298 |
+
"resolved": "https://registry.npmjs.org/next/-/next-14.2.3.tgz",
|
299 |
+
"integrity": "sha512-dowFkFTR8v79NPJO4QsBUtxv0g9BrS/phluVpMAt2ku7H+cbcBJlopXjkWlwxrk/xGqMemr7JkGPGemPrLLX7A==",
|
300 |
+
"dependencies": {
|
301 |
+
"@next/env": "14.2.3",
|
302 |
+
"@swc/helpers": "0.5.5",
|
303 |
+
"busboy": "1.6.0",
|
304 |
+
"caniuse-lite": "^1.0.30001579",
|
305 |
+
"graceful-fs": "^4.2.11",
|
306 |
+
"postcss": "8.4.31",
|
307 |
+
"styled-jsx": "5.1.1"
|
308 |
+
},
|
309 |
+
"bin": {
|
310 |
+
"next": "dist/bin/next"
|
311 |
+
},
|
312 |
+
"engines": {
|
313 |
+
"node": ">=18.17.0"
|
314 |
+
},
|
315 |
+
"optionalDependencies": {
|
316 |
+
"@next/swc-darwin-arm64": "14.2.3",
|
317 |
+
"@next/swc-darwin-x64": "14.2.3",
|
318 |
+
"@next/swc-linux-arm64-gnu": "14.2.3",
|
319 |
+
"@next/swc-linux-arm64-musl": "14.2.3",
|
320 |
+
"@next/swc-linux-x64-gnu": "14.2.3",
|
321 |
+
"@next/swc-linux-x64-musl": "14.2.3",
|
322 |
+
"@next/swc-win32-arm64-msvc": "14.2.3",
|
323 |
+
"@next/swc-win32-ia32-msvc": "14.2.3",
|
324 |
+
"@next/swc-win32-x64-msvc": "14.2.3"
|
325 |
+
},
|
326 |
+
"peerDependencies": {
|
327 |
+
"@opentelemetry/api": "^1.1.0",
|
328 |
+
"@playwright/test": "^1.41.2",
|
329 |
+
"react": "^18.2.0",
|
330 |
+
"react-dom": "^18.2.0",
|
331 |
+
"sass": "^1.3.0"
|
332 |
+
},
|
333 |
+
"peerDependenciesMeta": {
|
334 |
+
"@opentelemetry/api": {
|
335 |
+
"optional": true
|
336 |
+
},
|
337 |
+
"@playwright/test": {
|
338 |
+
"optional": true
|
339 |
+
},
|
340 |
+
"sass": {
|
341 |
+
"optional": true
|
342 |
+
}
|
343 |
+
}
|
344 |
+
},
|
345 |
+
"node_modules/phaser": {
|
346 |
+
"version": "3.87.0",
|
347 |
+
"resolved": "https://registry.npmjs.org/phaser/-/phaser-3.87.0.tgz",
|
348 |
+
"integrity": "sha512-AyI1b3T5fp05gzf6WUmu2FNqaZL+Y7w88yBRLf7YZXF9bncUSHpnDrupnTGoPqy/RKHRLBcay7zWeqQ2wiMWcw==",
|
349 |
+
"dependencies": {
|
350 |
+
"eventemitter3": "^5.0.1"
|
351 |
+
}
|
352 |
+
},
|
353 |
+
"node_modules/picocolors": {
|
354 |
+
"version": "1.0.1",
|
355 |
+
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz",
|
356 |
+
"integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew=="
|
357 |
+
},
|
358 |
+
"node_modules/postcss": {
|
359 |
+
"version": "8.4.31",
|
360 |
+
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz",
|
361 |
+
"integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==",
|
362 |
+
"funding": [
|
363 |
+
{
|
364 |
+
"type": "opencollective",
|
365 |
+
"url": "https://opencollective.com/postcss/"
|
366 |
+
},
|
367 |
+
{
|
368 |
+
"type": "tidelift",
|
369 |
+
"url": "https://tidelift.com/funding/github/npm/postcss"
|
370 |
+
},
|
371 |
+
{
|
372 |
+
"type": "github",
|
373 |
+
"url": "https://github.com/sponsors/ai"
|
374 |
+
}
|
375 |
+
],
|
376 |
+
"dependencies": {
|
377 |
+
"nanoid": "^3.3.6",
|
378 |
+
"picocolors": "^1.0.0",
|
379 |
+
"source-map-js": "^1.0.2"
|
380 |
+
},
|
381 |
+
"engines": {
|
382 |
+
"node": "^10 || ^12 || >=14"
|
383 |
+
}
|
384 |
+
},
|
385 |
+
"node_modules/react": {
|
386 |
+
"version": "18.3.1",
|
387 |
+
"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
|
388 |
+
"integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
|
389 |
+
"dependencies": {
|
390 |
+
"loose-envify": "^1.1.0"
|
391 |
+
},
|
392 |
+
"engines": {
|
393 |
+
"node": ">=0.10.0"
|
394 |
+
}
|
395 |
+
},
|
396 |
+
"node_modules/react-dom": {
|
397 |
+
"version": "18.3.1",
|
398 |
+
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",
|
399 |
+
"integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==",
|
400 |
+
"dependencies": {
|
401 |
+
"loose-envify": "^1.1.0",
|
402 |
+
"scheduler": "^0.23.2"
|
403 |
+
},
|
404 |
+
"peerDependencies": {
|
405 |
+
"react": "^18.3.1"
|
406 |
+
}
|
407 |
+
},
|
408 |
+
"node_modules/scheduler": {
|
409 |
+
"version": "0.23.2",
|
410 |
+
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz",
|
411 |
+
"integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==",
|
412 |
+
"dependencies": {
|
413 |
+
"loose-envify": "^1.1.0"
|
414 |
+
}
|
415 |
+
},
|
416 |
+
"node_modules/source-map-js": {
|
417 |
+
"version": "1.2.0",
|
418 |
+
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
|
419 |
+
"integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==",
|
420 |
+
"engines": {
|
421 |
+
"node": ">=0.10.0"
|
422 |
+
}
|
423 |
+
},
|
424 |
+
"node_modules/streamsearch": {
|
425 |
+
"version": "1.1.0",
|
426 |
+
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
|
427 |
+
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
|
428 |
+
"engines": {
|
429 |
+
"node": ">=10.0.0"
|
430 |
+
}
|
431 |
+
},
|
432 |
+
"node_modules/styled-jsx": {
|
433 |
+
"version": "5.1.1",
|
434 |
+
"resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.1.tgz",
|
435 |
+
"integrity": "sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==",
|
436 |
+
"dependencies": {
|
437 |
+
"client-only": "0.0.1"
|
438 |
+
},
|
439 |
+
"engines": {
|
440 |
+
"node": ">= 12.0.0"
|
441 |
+
},
|
442 |
+
"peerDependencies": {
|
443 |
+
"react": ">= 16.8.0 || 17.x.x || ^18.0.0-0"
|
444 |
+
},
|
445 |
+
"peerDependenciesMeta": {
|
446 |
+
"@babel/core": {
|
447 |
+
"optional": true
|
448 |
+
},
|
449 |
+
"babel-plugin-macros": {
|
450 |
+
"optional": true
|
451 |
+
}
|
452 |
+
}
|
453 |
+
},
|
454 |
+
"node_modules/tslib": {
|
455 |
+
"version": "2.6.2",
|
456 |
+
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
457 |
+
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
|
458 |
+
},
|
459 |
+
"node_modules/typescript": {
|
460 |
+
"version": "5.4.5",
|
461 |
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz",
|
462 |
+
"integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==",
|
463 |
+
"dev": true,
|
464 |
+
"bin": {
|
465 |
+
"tsc": "bin/tsc",
|
466 |
+
"tsserver": "bin/tsserver"
|
467 |
+
},
|
468 |
+
"engines": {
|
469 |
+
"node": ">=14.17"
|
470 |
+
}
|
471 |
+
},
|
472 |
+
"node_modules/undici-types": {
|
473 |
+
"version": "5.26.5",
|
474 |
+
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
475 |
+
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
|
476 |
+
"dev": true
|
477 |
+
}
|
478 |
+
}
|
479 |
+
}
|
package.json
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "template-nextjs",
|
3 |
+
"version": "1.1.1",
|
4 |
+
"description": "A Phaser 3 Next.js project template that demonstrates Next.js with React communication and uses Vite for bundling.",
|
5 |
+
"repository": {
|
6 |
+
"type": "git",
|
7 |
+
"url": "git+https://github.com/phaserjs/template-nextjs.git"
|
8 |
+
},
|
9 |
+
"author": "Phaser Studio <support@phaser.io> (https://phaser.io/)",
|
10 |
+
"license": "MIT",
|
11 |
+
"licenseUrl": "http://www.opensource.org/licenses/mit-license.php",
|
12 |
+
"bugs": {
|
13 |
+
"url": "https://github.com/phaserjs/template-nextjs/issues"
|
14 |
+
},
|
15 |
+
"homepage": "https://github.com/phaserjs/template-nextjs#readme",
|
16 |
+
"keywords": [
|
17 |
+
"phaser",
|
18 |
+
"phaser3",
|
19 |
+
"next",
|
20 |
+
"nextjs",
|
21 |
+
"vite",
|
22 |
+
"typescript"
|
23 |
+
],
|
24 |
+
"scripts": {
|
25 |
+
"dev": "next dev",
|
26 |
+
"build": "next build",
|
27 |
+
"start": "next start",
|
28 |
+
"lint": "next lint"
|
29 |
+
},
|
30 |
+
"dependencies": {
|
31 |
+
"next": "14.2.3",
|
32 |
+
"phaser": "^3.87.0",
|
33 |
+
"react": "^18",
|
34 |
+
"react-dom": "^18"
|
35 |
+
},
|
36 |
+
"devDependencies": {
|
37 |
+
"@types/node": "^20",
|
38 |
+
"@types/react": "^18",
|
39 |
+
"@types/react-dom": "^18",
|
40 |
+
"typescript": "^5"
|
41 |
+
}
|
42 |
+
}
|
public/assets/bg.png
ADDED
![]() |
public/assets/logo.png
ADDED
![]() |
public/assets/star.png
ADDED
![]() |
public/favicon.png
ADDED
![]() |
screenshot.png
ADDED
![]() |
src/App.tsx
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { useRef, useState } from 'react';
|
2 |
+
import { IRefPhaserGame, PhaserGame } from './game/PhaserGame';
|
3 |
+
import { MainMenu } from './game/scenes/MainMenu';
|
4 |
+
|
5 |
+
function App()
|
6 |
+
{
|
7 |
+
// The sprite can only be moved in the MainMenu Scene
|
8 |
+
const [canMoveSprite, setCanMoveSprite] = useState(true);
|
9 |
+
|
10 |
+
// References to the PhaserGame component (game and scene are exposed)
|
11 |
+
const phaserRef = useRef<IRefPhaserGame | null>(null);
|
12 |
+
const [spritePosition, setSpritePosition] = useState({ x: 0, y: 0 });
|
13 |
+
|
14 |
+
const changeScene = () => {
|
15 |
+
|
16 |
+
if(phaserRef.current)
|
17 |
+
{
|
18 |
+
const scene = phaserRef.current.scene as MainMenu;
|
19 |
+
|
20 |
+
if (scene)
|
21 |
+
{
|
22 |
+
scene.changeScene();
|
23 |
+
}
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
const moveSprite = () => {
|
28 |
+
|
29 |
+
if(phaserRef.current)
|
30 |
+
{
|
31 |
+
|
32 |
+
const scene = phaserRef.current.scene as MainMenu;
|
33 |
+
|
34 |
+
if (scene && scene.scene.key === 'MainMenu')
|
35 |
+
{
|
36 |
+
// Get the update logo position
|
37 |
+
scene.moveLogo(({ x, y }) => {
|
38 |
+
|
39 |
+
setSpritePosition({ x, y });
|
40 |
+
|
41 |
+
});
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
}
|
46 |
+
|
47 |
+
const addSprite = () => {
|
48 |
+
|
49 |
+
if (phaserRef.current)
|
50 |
+
{
|
51 |
+
const scene = phaserRef.current.scene;
|
52 |
+
|
53 |
+
if (scene)
|
54 |
+
{
|
55 |
+
// Add more stars
|
56 |
+
const x = Phaser.Math.Between(64, scene.scale.width - 64);
|
57 |
+
const y = Phaser.Math.Between(64, scene.scale.height - 64);
|
58 |
+
|
59 |
+
// `add.sprite` is a Phaser GameObjectFactory method and it returns a Sprite Game Object instance
|
60 |
+
const star = scene.add.sprite(x, y, 'star');
|
61 |
+
|
62 |
+
// ... which you can then act upon. Here we create a Phaser Tween to fade the star sprite in and out.
|
63 |
+
// You could, of course, do this from within the Phaser Scene code, but this is just an example
|
64 |
+
// showing that Phaser objects and systems can be acted upon from outside of Phaser itself.
|
65 |
+
scene.add.tween({
|
66 |
+
targets: star,
|
67 |
+
duration: 500 + Math.random() * 1000,
|
68 |
+
alpha: 0,
|
69 |
+
yoyo: true,
|
70 |
+
repeat: -1
|
71 |
+
});
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
// Event emitted from the PhaserGame component
|
77 |
+
const currentScene = (scene: Phaser.Scene) => {
|
78 |
+
|
79 |
+
setCanMoveSprite(scene.scene.key !== 'MainMenu');
|
80 |
+
|
81 |
+
}
|
82 |
+
|
83 |
+
return (
|
84 |
+
<div id="app">
|
85 |
+
<PhaserGame ref={phaserRef} currentActiveScene={currentScene} />
|
86 |
+
<div>
|
87 |
+
<div>
|
88 |
+
<button className="button" onClick={changeScene}>Change Scene</button>
|
89 |
+
</div>
|
90 |
+
<div>
|
91 |
+
<button disabled={canMoveSprite} className="button" onClick={moveSprite}>Toggle Movement</button>
|
92 |
+
</div>
|
93 |
+
<div className="spritePosition">Sprite Position:
|
94 |
+
<pre>{`{\n x: ${spritePosition.x}\n y: ${spritePosition.y}\n}`}</pre>
|
95 |
+
</div>
|
96 |
+
<div>
|
97 |
+
<button className="button" onClick={addSprite}>Add New Sprite</button>
|
98 |
+
</div>
|
99 |
+
</div>
|
100 |
+
</div>
|
101 |
+
)
|
102 |
+
}
|
103 |
+
|
104 |
+
export default App
|
src/game/EventBus.ts
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Events } from 'phaser';
|
2 |
+
|
3 |
+
// Used to emit events between React components and Phaser scenes
|
4 |
+
// https://newdocs.phaser.io/docs/3.70.0/Phaser.Events.EventEmitter
|
5 |
+
export const EventBus = new Events.EventEmitter();
|
src/game/PhaserGame.tsx
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { forwardRef, useEffect, useLayoutEffect, useRef } from 'react';
|
2 |
+
import StartGame from './main';
|
3 |
+
import { EventBus } from './EventBus';
|
4 |
+
|
5 |
+
export interface IRefPhaserGame
|
6 |
+
{
|
7 |
+
game: Phaser.Game | null;
|
8 |
+
scene: Phaser.Scene | null;
|
9 |
+
}
|
10 |
+
|
11 |
+
interface IProps
|
12 |
+
{
|
13 |
+
currentActiveScene?: (scene_instance: Phaser.Scene) => void
|
14 |
+
}
|
15 |
+
|
16 |
+
export const PhaserGame = forwardRef<IRefPhaserGame, IProps>(function PhaserGame({ currentActiveScene }, ref)
|
17 |
+
{
|
18 |
+
const game = useRef<Phaser.Game | null>(null!);
|
19 |
+
|
20 |
+
useLayoutEffect(() =>
|
21 |
+
{
|
22 |
+
if (game.current === null)
|
23 |
+
{
|
24 |
+
|
25 |
+
game.current = StartGame("game-container");
|
26 |
+
|
27 |
+
if (typeof ref === 'function')
|
28 |
+
{
|
29 |
+
ref({ game: game.current, scene: null });
|
30 |
+
} else if (ref)
|
31 |
+
{
|
32 |
+
ref.current = { game: game.current, scene: null };
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
return () =>
|
38 |
+
{
|
39 |
+
if (game.current)
|
40 |
+
{
|
41 |
+
game.current.destroy(true);
|
42 |
+
if (game.current !== null)
|
43 |
+
{
|
44 |
+
game.current = null;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}, [ref]);
|
49 |
+
|
50 |
+
useEffect(() =>
|
51 |
+
{
|
52 |
+
EventBus.on('current-scene-ready', (scene_instance: Phaser.Scene) =>
|
53 |
+
{
|
54 |
+
if (currentActiveScene && typeof currentActiveScene === 'function')
|
55 |
+
{
|
56 |
+
|
57 |
+
currentActiveScene(scene_instance);
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
if (typeof ref === 'function')
|
62 |
+
{
|
63 |
+
|
64 |
+
ref({ game: game.current, scene: scene_instance });
|
65 |
+
|
66 |
+
} else if (ref)
|
67 |
+
{
|
68 |
+
|
69 |
+
ref.current = { game: game.current, scene: scene_instance };
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
});
|
74 |
+
return () =>
|
75 |
+
{
|
76 |
+
|
77 |
+
EventBus.removeListener('current-scene-ready');
|
78 |
+
|
79 |
+
}
|
80 |
+
}, [currentActiveScene, ref]);
|
81 |
+
|
82 |
+
return (
|
83 |
+
<div id="game-container"></div>
|
84 |
+
);
|
85 |
+
|
86 |
+
});
|
src/game/config.ts
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { MazeScene } from './scenes/MazeScene';
|
2 |
+
|
3 |
+
export const gameConfig: Phaser.Types.Core.GameConfig = {
|
4 |
+
type: Phaser.AUTO,
|
5 |
+
parent: 'game-content',
|
6 |
+
backgroundColor: '#4488aa',
|
7 |
+
scale: {
|
8 |
+
mode: Phaser.Scale.FIT,
|
9 |
+
autoCenter: Phaser.Scale.CENTER_BOTH,
|
10 |
+
width: 256, // 8 tiles * 32 pixels
|
11 |
+
height: 256, // 8 tiles * 32 pixels
|
12 |
+
},
|
13 |
+
physics: {
|
14 |
+
default: 'arcade',
|
15 |
+
arcade: {
|
16 |
+
gravity: { y: 0 },
|
17 |
+
debug: false,
|
18 |
+
},
|
19 |
+
},
|
20 |
+
scene: [MazeScene],
|
21 |
+
};
|
src/game/main.ts
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Boot } from './scenes/Boot';
|
2 |
+
import { GameOver } from './scenes/GameOver';
|
3 |
+
import { Game as MainGame } from './scenes/Game';
|
4 |
+
import { MainMenu } from './scenes/MainMenu';
|
5 |
+
import { AUTO, Game } from 'phaser';
|
6 |
+
import { Preloader } from './scenes/Preloader';
|
7 |
+
|
8 |
+
// Find out more information about the Game Config at:
|
9 |
+
// https://newdocs.phaser.io/docs/3.70.0/Phaser.Types.Core.GameConfig
|
10 |
+
const config: Phaser.Types.Core.GameConfig = {
|
11 |
+
type: AUTO,
|
12 |
+
width: 1024,
|
13 |
+
height: 768,
|
14 |
+
parent: 'game-container',
|
15 |
+
backgroundColor: '#028af8',
|
16 |
+
scene: [
|
17 |
+
Boot,
|
18 |
+
Preloader,
|
19 |
+
MainMenu,
|
20 |
+
MainGame,
|
21 |
+
GameOver
|
22 |
+
]
|
23 |
+
};
|
24 |
+
|
25 |
+
const StartGame = (parent: string) => {
|
26 |
+
|
27 |
+
return new Game({ ...config, parent });
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
export default StartGame;
|
src/game/scenes/Boot.ts
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Scene } from 'phaser';
|
2 |
+
|
3 |
+
export class Boot extends Scene
|
4 |
+
{
|
5 |
+
constructor ()
|
6 |
+
{
|
7 |
+
super('Boot');
|
8 |
+
}
|
9 |
+
|
10 |
+
preload ()
|
11 |
+
{
|
12 |
+
// The Boot Scene is typically used to load in any assets you require for your Preloader, such as a game logo or background.
|
13 |
+
// The smaller the file size of the assets, the better, as the Boot Scene itself has no preloader.
|
14 |
+
|
15 |
+
this.load.image('background', 'assets/bg.png');
|
16 |
+
}
|
17 |
+
|
18 |
+
create ()
|
19 |
+
{
|
20 |
+
this.scene.start('Preloader');
|
21 |
+
}
|
22 |
+
}
|
src/game/scenes/Game.ts
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { EventBus } from '../EventBus';
|
2 |
+
import { Scene } from 'phaser';
|
3 |
+
|
4 |
+
export class Game extends Scene
|
5 |
+
{
|
6 |
+
camera: Phaser.Cameras.Scene2D.Camera;
|
7 |
+
background: Phaser.GameObjects.Image;
|
8 |
+
gameText: Phaser.GameObjects.Text;
|
9 |
+
|
10 |
+
constructor ()
|
11 |
+
{
|
12 |
+
super('Game');
|
13 |
+
}
|
14 |
+
|
15 |
+
create ()
|
16 |
+
{
|
17 |
+
this.camera = this.cameras.main;
|
18 |
+
this.camera.setBackgroundColor(0x00ff00);
|
19 |
+
|
20 |
+
this.background = this.add.image(512, 384, 'background');
|
21 |
+
this.background.setAlpha(0.5);
|
22 |
+
|
23 |
+
this.gameText = this.add.text(512, 384, 'Make something fun!\nand share it with us:\nsupport@phaser.io', {
|
24 |
+
fontFamily: 'Arial Black', fontSize: 38, color: '#ffffff',
|
25 |
+
stroke: '#000000', strokeThickness: 8,
|
26 |
+
align: 'center'
|
27 |
+
}).setOrigin(0.5).setDepth(100);
|
28 |
+
|
29 |
+
EventBus.emit('current-scene-ready', this);
|
30 |
+
}
|
31 |
+
|
32 |
+
changeScene ()
|
33 |
+
{
|
34 |
+
this.scene.start('GameOver');
|
35 |
+
}
|
36 |
+
}
|
src/game/scenes/GameOver.ts
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { EventBus } from '../EventBus';
|
2 |
+
import { Scene } from 'phaser';
|
3 |
+
|
4 |
+
export class GameOver extends Scene
|
5 |
+
{
|
6 |
+
camera: Phaser.Cameras.Scene2D.Camera;
|
7 |
+
background: Phaser.GameObjects.Image;
|
8 |
+
gameOverText : Phaser.GameObjects.Text;
|
9 |
+
|
10 |
+
constructor ()
|
11 |
+
{
|
12 |
+
super('GameOver');
|
13 |
+
}
|
14 |
+
|
15 |
+
create ()
|
16 |
+
{
|
17 |
+
this.camera = this.cameras.main
|
18 |
+
this.camera.setBackgroundColor(0xff0000);
|
19 |
+
|
20 |
+
this.background = this.add.image(512, 384, 'background');
|
21 |
+
this.background.setAlpha(0.5);
|
22 |
+
|
23 |
+
this.gameOverText = this.add.text(512, 384, 'Game Over', {
|
24 |
+
fontFamily: 'Arial Black', fontSize: 64, color: '#ffffff',
|
25 |
+
stroke: '#000000', strokeThickness: 8,
|
26 |
+
align: 'center'
|
27 |
+
}).setOrigin(0.5).setDepth(100);
|
28 |
+
|
29 |
+
EventBus.emit('current-scene-ready', this);
|
30 |
+
}
|
31 |
+
|
32 |
+
changeScene ()
|
33 |
+
{
|
34 |
+
this.scene.start('MainMenu');
|
35 |
+
}
|
36 |
+
}
|
src/game/scenes/MainMenu.ts
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { GameObjects, Scene } from 'phaser';
|
2 |
+
|
3 |
+
import { EventBus } from '../EventBus';
|
4 |
+
|
5 |
+
export class MainMenu extends Scene
|
6 |
+
{
|
7 |
+
background: GameObjects.Image;
|
8 |
+
logo: GameObjects.Image;
|
9 |
+
title: GameObjects.Text;
|
10 |
+
logoTween: Phaser.Tweens.Tween | null;
|
11 |
+
|
12 |
+
constructor ()
|
13 |
+
{
|
14 |
+
super('MainMenu');
|
15 |
+
}
|
16 |
+
|
17 |
+
create ()
|
18 |
+
{
|
19 |
+
this.background = this.add.image(512, 384, 'background');
|
20 |
+
|
21 |
+
this.logo = this.add.image(512, 300, 'logo').setDepth(100);
|
22 |
+
|
23 |
+
this.title = this.add.text(512, 460, 'Main Menu', {
|
24 |
+
fontFamily: 'Arial Black', fontSize: 38, color: '#ffffff',
|
25 |
+
stroke: '#000000', strokeThickness: 8,
|
26 |
+
align: 'center'
|
27 |
+
}).setOrigin(0.5).setDepth(100);
|
28 |
+
|
29 |
+
EventBus.emit('current-scene-ready', this);
|
30 |
+
}
|
31 |
+
|
32 |
+
changeScene ()
|
33 |
+
{
|
34 |
+
if (this.logoTween)
|
35 |
+
{
|
36 |
+
this.logoTween.stop();
|
37 |
+
this.logoTween = null;
|
38 |
+
}
|
39 |
+
|
40 |
+
this.scene.start('Game');
|
41 |
+
}
|
42 |
+
|
43 |
+
moveLogo (reactCallback: ({ x, y }: { x: number, y: number }) => void)
|
44 |
+
{
|
45 |
+
if (this.logoTween)
|
46 |
+
{
|
47 |
+
if (this.logoTween.isPlaying())
|
48 |
+
{
|
49 |
+
this.logoTween.pause();
|
50 |
+
}
|
51 |
+
else
|
52 |
+
{
|
53 |
+
this.logoTween.play();
|
54 |
+
}
|
55 |
+
}
|
56 |
+
else
|
57 |
+
{
|
58 |
+
this.logoTween = this.tweens.add({
|
59 |
+
targets: this.logo,
|
60 |
+
x: { value: 750, duration: 3000, ease: 'Back.easeInOut' },
|
61 |
+
y: { value: 80, duration: 1500, ease: 'Sine.easeOut' },
|
62 |
+
yoyo: true,
|
63 |
+
repeat: -1,
|
64 |
+
onUpdate: () => {
|
65 |
+
if (reactCallback)
|
66 |
+
{
|
67 |
+
reactCallback({
|
68 |
+
x: Math.floor(this.logo.x),
|
69 |
+
y: Math.floor(this.logo.y)
|
70 |
+
});
|
71 |
+
}
|
72 |
+
}
|
73 |
+
});
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
src/game/scenes/Preloader.ts
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Scene } from 'phaser';
|
2 |
+
|
3 |
+
export class Preloader extends Scene
|
4 |
+
{
|
5 |
+
constructor ()
|
6 |
+
{
|
7 |
+
super('Preloader');
|
8 |
+
}
|
9 |
+
|
10 |
+
init ()
|
11 |
+
{
|
12 |
+
// We loaded this image in our Boot Scene, so we can display it here
|
13 |
+
this.add.image(512, 384, 'background');
|
14 |
+
|
15 |
+
// A simple progress bar. This is the outline of the bar.
|
16 |
+
this.add.rectangle(512, 384, 468, 32).setStrokeStyle(1, 0xffffff);
|
17 |
+
|
18 |
+
// This is the progress bar itself. It will increase in size from the left based on the % of progress.
|
19 |
+
const bar = this.add.rectangle(512-230, 384, 4, 28, 0xffffff);
|
20 |
+
|
21 |
+
// Use the 'progress' event emitted by the LoaderPlugin to update the loading bar
|
22 |
+
this.load.on('progress', (progress: number) => {
|
23 |
+
|
24 |
+
// Update the progress bar (our bar is 464px wide, so 100% = 464px)
|
25 |
+
bar.width = 4 + (460 * progress);
|
26 |
+
|
27 |
+
});
|
28 |
+
}
|
29 |
+
|
30 |
+
preload ()
|
31 |
+
{
|
32 |
+
// Load the assets for the game - Replace with your own assets
|
33 |
+
this.load.setPath('assets');
|
34 |
+
|
35 |
+
this.load.image('logo', 'logo.png');
|
36 |
+
this.load.image('star', 'star.png');
|
37 |
+
}
|
38 |
+
|
39 |
+
create ()
|
40 |
+
{
|
41 |
+
// When all the assets have loaded, it's often worth creating global objects here that the rest of the game can use.
|
42 |
+
// For example, you can define global animations here, so we can use them in other scenes.
|
43 |
+
|
44 |
+
// Move to the MainMenu. You could also swap this for a Scene Transition, such as a camera fade.
|
45 |
+
this.scene.start('MainMenu');
|
46 |
+
}
|
47 |
+
}
|
src/pages/_app.tsx
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import "@/styles/globals.css";
|
2 |
+
import type { AppProps } from "next/app";
|
3 |
+
|
4 |
+
export default function App({ Component, pageProps }: AppProps) {
|
5 |
+
return <Component {...pageProps} />;
|
6 |
+
}
|
src/pages/_document.tsx
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Html, Head, Main, NextScript } from "next/document";
|
2 |
+
|
3 |
+
export default function Document() {
|
4 |
+
return (
|
5 |
+
<Html lang="en">
|
6 |
+
<Head />
|
7 |
+
<body>
|
8 |
+
<Main />
|
9 |
+
<NextScript />
|
10 |
+
</body>
|
11 |
+
</Html>
|
12 |
+
);
|
13 |
+
}
|
src/pages/index.tsx
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Head from "next/head";
|
2 |
+
import { Inter } from "next/font/google";
|
3 |
+
import styles from "@/styles/Home.module.css";
|
4 |
+
import dynamic from "next/dynamic";
|
5 |
+
|
6 |
+
const inter = Inter({ subsets: ["latin"] });
|
7 |
+
|
8 |
+
const AppWithoutSSR = dynamic(() => import("@/App"), { ssr: false });
|
9 |
+
|
10 |
+
export default function Home() {
|
11 |
+
return (
|
12 |
+
<>
|
13 |
+
<Head>
|
14 |
+
<title>Phaser Nextjs Template</title>
|
15 |
+
<meta name="description" content="A Phaser 3 Next.js project template that demonstrates Next.js with React communication and uses Vite for bundling." />
|
16 |
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
17 |
+
<link rel="icon" href="/favicon.png" />
|
18 |
+
</Head>
|
19 |
+
<main className={`${styles.main} ${inter.className}`}>
|
20 |
+
<AppWithoutSSR />
|
21 |
+
</main>
|
22 |
+
</>
|
23 |
+
);
|
24 |
+
}
|
src/styles/Home.module.css
ADDED
File without changes
|
src/styles/globals.css
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
body {
|
2 |
+
margin: 0;
|
3 |
+
padding: 0;
|
4 |
+
color: rgba(255, 255, 255, 0.87);
|
5 |
+
background-color: #000000;
|
6 |
+
font-family: Arial, Helvetica, sans-serif;
|
7 |
+
}
|
8 |
+
|
9 |
+
#app {
|
10 |
+
width: 100%;
|
11 |
+
height: 100vh;
|
12 |
+
overflow: hidden;
|
13 |
+
display: flex;
|
14 |
+
justify-content: center;
|
15 |
+
align-items: center;
|
16 |
+
}
|
17 |
+
|
18 |
+
.spritePosition {
|
19 |
+
margin: 10px 0 0 10px;
|
20 |
+
font-size: 0.8em;
|
21 |
+
}
|
22 |
+
|
23 |
+
.button {
|
24 |
+
width: 140px;
|
25 |
+
margin: 10px;
|
26 |
+
padding: 10px;
|
27 |
+
background-color: #000000;
|
28 |
+
color: rgba(255, 255, 255, 0.87);
|
29 |
+
border: 1px solid rgba(255, 255, 255, 0.87);
|
30 |
+
cursor: pointer;
|
31 |
+
transition: all 0.3s;
|
32 |
+
|
33 |
+
&:hover {
|
34 |
+
border: 1px solid #0ec3c9;
|
35 |
+
color: #0ec3c9;
|
36 |
+
}
|
37 |
+
|
38 |
+
&:active {
|
39 |
+
background-color: #0ec3c9;
|
40 |
+
}
|
41 |
+
|
42 |
+
/* Disabled styles */
|
43 |
+
&:disabled {
|
44 |
+
cursor: not-allowed;
|
45 |
+
border: 1px solid rgba(255, 255, 255, 0.3);
|
46 |
+
color: rgba(255, 255, 255, 0.3);
|
47 |
+
}
|
48 |
+
}
|
tsconfig.json
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"compilerOptions": {
|
3 |
+
"lib": ["dom", "dom.iterable", "esnext"],
|
4 |
+
"allowJs": true,
|
5 |
+
"skipLibCheck": true,
|
6 |
+
"strict": true,
|
7 |
+
"noEmit": true,
|
8 |
+
"esModuleInterop": true,
|
9 |
+
"module": "esnext",
|
10 |
+
"moduleResolution": "bundler",
|
11 |
+
"resolveJsonModule": true,
|
12 |
+
"isolatedModules": true,
|
13 |
+
"jsx": "preserve",
|
14 |
+
"incremental": true,
|
15 |
+
"strictPropertyInitialization": false,
|
16 |
+
"paths": {
|
17 |
+
"@/*": ["./src/*"]
|
18 |
+
}
|
19 |
+
},
|
20 |
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
21 |
+
"exclude": ["node_modules"]
|
22 |
+
}
|