From: kharhamel Date: Mon, 13 Apr 2020 17:40:10 +0000 (+0200) Subject: create an env variable for debug mode X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=33c58874e03fbdfc0e8d6b9d544db9cae788abaf;p=libreadventure.git create an env variable for debug mode --- diff --git a/.env.template b/.env.template new file mode 100644 index 0000000..81044e9 --- /dev/null +++ b/.env.template @@ -0,0 +1 @@ +DEBUG_MODE=false \ No newline at end of file diff --git a/.gitignore b/.gitignore index a806c47..bc00a82 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.env .idea .vagrant Vagrantfile \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index a23a520..0384223 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,6 +13,7 @@ services: front: image: thecodingmachine/nodejs:12 environment: + DEBUG_MODE: "$DEBUG_MODE" HOST: "0.0.0.0" NODE_ENV: development API_URL: http://api.workadventure.localhost diff --git a/front/src/Enum/EnvironmentVariable.ts b/front/src/Enum/EnvironmentVariable.ts index 3cf52b8..b4dd4f2 100644 --- a/front/src/Enum/EnvironmentVariable.ts +++ b/front/src/Enum/EnvironmentVariable.ts @@ -1,8 +1,10 @@ +const DEBUG_MODE: boolean = !!process.env.DEBUG_MODE || false; const API_URL = process.env.API_URL || "http://api.workadventure.localhost"; const ROOM = [process.env.ROOM || "THECODINGMACHINE"]; const RESOLUTION = 2; export { + DEBUG_MODE, API_URL, RESOLUTION, ROOM diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 48acf4a..88514a6 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -2,7 +2,7 @@ import {GameManagerInterface, StatusGameManagerEnum} from "./GameManager"; import {MessageUserPositionInterface} from "../../Connexion"; import {CameraManager, CameraManagerInterface} from "./CameraManager"; import {CurrentGamerInterface, GamerInterface, Player} from "../Player/Player"; -import {RESOLUTION} from "../../Enum/EnvironmentVariable"; +import {DEBUG_MODE, RESOLUTION} from "../../Enum/EnvironmentVariable"; import Tile = Phaser.Tilemaps.Tile; export enum Textures { @@ -97,13 +97,14 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{ //this.CurrentPlayer.say("Collision with layer : "+ (object2 as Tile).layer.name) }); Layer.setCollisionByProperty({collides: true}); - //debug code - //debug code to see the collision hitbox of the object in the top layer - /*Layer.renderDebug(this.add.graphics(), { - tileColor: null, //non-colliding tiles - collidingTileColor: new Phaser.Display.Color(243, 134, 48, 200), // Colliding tiles, - faceColor: new Phaser.Display.Color(40, 39, 37, 255) // Colliding face edges - });*/ + if (DEBUG_MODE) { + //debug code to see the collision hitbox of the object in the top layer + Layer.renderDebug(this.add.graphics(), { + tileColor: null, //non-colliding tiles + collidingTileColor: new Phaser.Display.Color(243, 134, 48, 200), // Colliding tiles, + faceColor: new Phaser.Display.Color(40, 39, 37, 255) // Colliding face edges + }); + } }); } @@ -142,6 +143,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{ //pixel position toz tile position let tile = this.Map.getTileAt(this.Map.worldToTileX(pointer.worldX), this.Map.worldToTileY(pointer.worldY)); if(tile){ + console.log(tile) this.CurrentPlayer.say("Your touch " + tile.layer.name); } }); diff --git a/front/src/index.ts b/front/src/index.ts index 5d90a19..f3dfb22 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -1,7 +1,7 @@ import 'phaser'; import GameConfig = Phaser.Types.Core.GameConfig; import {GameManager} from "./Phaser/Game/GameManager"; -import {RESOLUTION} from "./Enum/EnvironmentVariable"; +import {DEBUG_MODE, RESOLUTION} from "./Enum/EnvironmentVariable"; let gameManager = new GameManager(); @@ -15,7 +15,7 @@ const config: GameConfig = { physics: { default: "arcade", arcade: { - debug: true + debug: DEBUG_MODE } } }; diff --git a/front/webpack.config.js b/front/webpack.config.js index 21431e4..ff16480 100644 --- a/front/webpack.config.js +++ b/front/webpack.config.js @@ -29,6 +29,6 @@ module.exports = { new webpack.ProvidePlugin({ Phaser: 'phaser' }), - new webpack.EnvironmentPlugin(['API_URL']) + new webpack.EnvironmentPlugin(['API_URL', 'DEBUG_MODE']) ] };