Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 6 additions & 7 deletions src/AssetsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}