create an env variable for debug mode
authorkharhamel <oognic@gmail.com>
Mon, 13 Apr 2020 17:40:10 +0000 (19:40 +0200)
committerkharhamel <oognic@gmail.com>
Mon, 13 Apr 2020 17:40:10 +0000 (19:40 +0200)
.env.template [new file with mode: 0644]
.gitignore
docker-compose.yaml
front/src/Enum/EnvironmentVariable.ts
front/src/Phaser/Game/GameScene.ts
front/src/index.ts
front/webpack.config.js

diff --git a/.env.template b/.env.template
new file mode 100644 (file)
index 0000000..81044e9
--- /dev/null
@@ -0,0 +1 @@
+DEBUG_MODE=false
\ No newline at end of file
index a806c47e612b4fcd42e10b5eb7314d550d078d45..bc00a82a34eb1d9d63da868c04536e0d6f29bc10 100644 (file)
@@ -1,3 +1,4 @@
+.env
 .idea
 .vagrant
 Vagrantfile
\ No newline at end of file
index a23a5204e729ead750b665d835bc9e671d7c4a87..03842238851820f9dda63d4e2bd936a9735dd04e 100644 (file)
@@ -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
index 3cf52b85dc5e19d378ff6bba2377f303dda7cfb8..b4dd4f26d0fc674a7e694327b0d9a1d37d781567 100644 (file)
@@ -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
index 48acf4a2046f76ea990ba5ee14047c9866048981..88514a6e4f856a3e55e0afceeb64d82f1e736252 100644 (file)
@@ -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);
             }
         });
index 5d90a19e784c64ed0b8997d029a1dd9e3dc7d39b..f3dfb22f51a298291042351b476c7d6c70dc2d61 100644 (file)
@@ -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
         }
     }
 };
index 21431e4ca1dcc2acf7f88f0ec9b20d9ecbc08664..ff16480421fc3dd60efaaa3c04c70f04c54b1c6e 100644 (file)
@@ -29,6 +29,6 @@ module.exports = {
         new webpack.ProvidePlugin({
             Phaser: 'phaser'
         }),
-        new webpack.EnvironmentPlugin(['API_URL'])
+        new webpack.EnvironmentPlugin(['API_URL', 'DEBUG_MODE'])
     ]
 };