diff --git a/README.md b/README.md index 831029d..058aa82 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,11 @@ kphp-game/ $ make game ``` +```bash +# Play game +$ KPHP_GAME_ASSETS_PATH=~/kphp-project/kphp-game-master/assets/ ./bin/game +``` + Tested on: * Ubuntu (amd64 platform) diff --git a/src/AssetsManager.php b/src/AssetsManager.php index d749152..4041421 100644 --- a/src/AssetsManager.php +++ b/src/AssetsManager.php @@ -24,14 +24,13 @@ public static function font(string $name): string { } private static function getRootByTarget(): string { - $target = $_ENV['KPHP_GAME_TARGET'] ?? ''; - if ($target === 'linux') { - return "./assets/"; + $target = $_ENV['KPHP_GAME_ASSETS_PATH'] ? strval($_ENV['KPHP_GAME_ASSETS_PATH']) : ''; + if (!$target) { + throw new \RuntimeException("Should specify the assets path environment variable.\r\n for example: `KPHP_GAME_ASSETS_PATH=~/kphp-project/kphp-game/assets/ ./bin/game`\r\n"); } - if ($target === 'macos') { - return "./../Resources/"; + if (!is_dir($target)) { + throw new \RuntimeException("KPHP_GAME_ASSETS_PATH is not a valid directory\r\n"); } - // Otherwise, it's dev-mode. - return __DIR__ . "/../assets/"; + return $target; } }