diff --git a/README.md b/README.md index f1614c1..19674ac 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,45 @@ Tested on node `v14.17.3` -You can play the game [here](#) +You can play the game [here](https://mystifying-hypatia-4b1cef.netlify.app/) (unfortunelly I can not setup server, so this instance do not provides ranking πŸ˜₯). +Please be patient. The game **will** load, but slower on the crappy, free hosting, than on localhost. -In the `game` directory there game client. -In the `server` directory there are authentiaction and ranking server. +The game was created for the first edition of [Hackerspace TrΓ³jmiasto's Community](https://github.com/hs3city/hs3-jam) Jam. -To start the app locally, you need... *TODO* :) +![Screenshot](ss.jpg) + +## How to start a game + +You need the [NodeJS](https://nodejs.org/en/) installed. + +The game's server do not serve game client's files. They are separately apps. +The server is responsible for authentication and storing records. +Data is stored as plain JSON files in `server/storage` directory. +You do not have to setup any external database :) + +The game *should* work without server, with some limitations. +Game works fine on desktop + +Steering: `WSAD + Mouse` + +## Setup and run server +```sh +🐧 cd server +🐧 npm install # install dependencies +🐧 cp .env.example .env +🐧 # edit .env file - UPDATE THE SECRET! +🐧 npm start # the server listening on port 3000. +``` + +## Setup and run client +```sh +🐧 cd .. # only if your cwd is server directory +🐧 cd game +🐧 npm install # install dependencies +🐧 # edit first line of src/api.ts to match your server +🐧 npm start # to run in Dev mode (hot reloading and recompilling) +🐧 npm run build +🐧 # your app is in dist directory, you need to serve it via www server +``` + +## Enjoy! diff --git a/game/README.md b/game/README.md new file mode 100644 index 0000000..4d2635f --- /dev/null +++ b/game/README.md @@ -0,0 +1,5 @@ +# Start Game Client + +For more info look at main README.md + +I used [phaser3-typescript-parcel-template](https://github.com/ourcade/phaser3-typescript-parcel-template) as startup project (but typescript config was messed up) diff --git a/game/package.json b/game/package.json index 1bc0222..35f5b96 100644 --- a/game/package.json +++ b/game/package.json @@ -4,9 +4,7 @@ "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 --no-source-maps", - "test": "echo \"Error: no test specified\" && exit 1", - "lint": "eslint ./src --ext .js,.jsx,.ts,.tsx" + "build": "parcel build src/index.html --out-dir dist --no-source-maps" }, "author": "Grzegorz Kupczyk", "license": "MIT", diff --git a/game/readme.md b/game/readme.md deleted file mode 100644 index e5be41c..0000000 --- a/game/readme.md +++ /dev/null @@ -1,138 +0,0 @@ -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) diff --git a/server/.env.example b/server/.env.example index 65735ce..82ee1e0 100644 --- a/server/.env.example +++ b/server/.env.example @@ -1,2 +1,3 @@ -secret = oIMzR4YvM9x9NoPrQfk4 +secret = HVuwh1dmaFhg4q1fef7xI4D6UeV7ImGK6NTp7i9eH6qiyJ9kxsvqPu29JXnhNGQY enableJusticeGuard = 1 +PORT = 3001 diff --git a/server/README.md b/server/README.md new file mode 100644 index 0000000..8cf536e --- /dev/null +++ b/server/README.md @@ -0,0 +1,5 @@ +# Start Game Server + +For more info look at main README.md + +I used [phaser3-typescript-parcel-template](https://github.com/ourcade/phaser3-typescript-parcel-template) as startup project (but typescript config was messed up) diff --git a/server/package.json b/server/package.json index c786caf..20b1855 100644 --- a/server/package.json +++ b/server/package.json @@ -4,7 +4,8 @@ "description": "", "main": "index.js", "scripts": { - "start": "nodemon --ignore ./storage/ --exec babel-node server.js" + "dedv": "nodemon --ignore ./storage/ --exec babel-node server.js", + "start": "babel-node server.js" }, "type": "module", "keywords": [], diff --git a/server/server.js b/server/server.js index 713d437..96badd2 100644 --- a/server/server.js +++ b/server/server.js @@ -110,4 +110,8 @@ app.use(function (err, req, res, next) { }); await db.read() -app.listen(3000) + +const port = process.env.PORT || 3000 +app.listen(port, () => { + console.log(`Server listening on port ${port}!`); +}) diff --git a/ss.jpg b/ss.jpg new file mode 100644 index 0000000..6492311 Binary files /dev/null and b/ss.jpg differ