mirror of
https://github.com/Kapendev/parin.git
synced 2025-04-29 22:49:54 +03:00
Fixed bug in setup script and added sprite for examples.
This commit is contained in:
parent
ca5c140e3c
commit
a21abd929a
5 changed files with 45 additions and 23 deletions
|
@ -55,16 +55,17 @@ dub run popka:setup
|
||||||
|
|
||||||
The last line will download raylib and create some folders necessary for Popka to function properly. The folders:
|
The last line will download raylib and create some folders necessary for Popka to function properly. The folders:
|
||||||
|
|
||||||
* `assets`: This folder is used to store game assets such as images, sounds and fonts.
|
* assets: This folder is used to store game assets such as images, sounds and fonts.
|
||||||
* `web`: This folder is used for exporting to the web.
|
* web: This folder is used for exporting to the web.
|
||||||
|
|
||||||
The last line also changes the default app.d file.
|
The last line also changes the default app.d file.
|
||||||
Once the installation is complete, you should be able to compile by running:
|
Once the installation is complete, you should be able to compile/run with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
dub run
|
dub run
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can pass `offline` to the script if you don't want to download raylib.
|
||||||
For more info about exporting to web, see [this](#web-support).
|
For more info about exporting to web, see [this](#web-support).
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
4
dub.json
4
dub.json
|
@ -9,11 +9,11 @@
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "pdefault",
|
"name": "pdefault",
|
||||||
"excludedSourceFiles": ["examples/*.d", "web/source/*.d"]
|
"excludedSourceFiles": ["examples/*.d", "setup/source/*.d", "web/source/*.d"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ptest",
|
"name": "ptest",
|
||||||
"excludedSourceFiles": ["examples/*.d", "web/source/*.d", "source/popka/package.d", "source/popka/game/*.d", "source/popka/vendor/*.d"]
|
"excludedSourceFiles": ["examples/*.d", "setup/source/*.d", "web/source/*.d", "source/popka/package.d", "source/popka/game/*.d", "source/popka/vendor/*.d"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"subPackages" : [
|
"subPackages" : [
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
# Examples
|
# Examples
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> For examples that use sprites, you must download the [atlas.png](atlas.png) file and save it in your project's assets folder.
|
||||||
|
|
||||||
## [Hello](hello.d)
|
## [Hello](hello.d)
|
||||||
|
|
||||||
This example serves as a classic hello-world program, introducing the fundamental structure of a Popka program.
|
This example serves as a classic hello-world program, introducing the fundamental structure of a Popka program.
|
||||||
|
|
BIN
examples/atlas.png
Normal file
BIN
examples/atlas.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
|
@ -9,6 +9,21 @@ import std.stdio;
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.process;
|
import std.process;
|
||||||
|
|
||||||
|
|
||||||
|
// The config.
|
||||||
|
// ----------
|
||||||
|
enum noLibsArg = "offline";
|
||||||
|
|
||||||
|
enum dubFile = buildPath(".", "dub.json");
|
||||||
|
enum dubyFile = buildPath(".", "dub.selections.json");
|
||||||
|
enum appFile = buildPath(".", "source", "app.d");
|
||||||
|
enum gitignoreFile = buildPath(".", ".gitignore");
|
||||||
|
|
||||||
|
enum assetsDir = buildPath(".", "assets");
|
||||||
|
enum webDir = buildPath(".", "web");
|
||||||
|
// ----------
|
||||||
|
|
||||||
|
|
||||||
enum defaultDubContent = `{
|
enum defaultDubContent = `{
|
||||||
"name" : "game",
|
"name" : "game",
|
||||||
"description" : "A game made with Popka.",
|
"description" : "A game made with Popka.",
|
||||||
|
@ -39,7 +54,7 @@ enum defaultDubContent = `{
|
||||||
"targetType": "executable",
|
"targetType": "executable",
|
||||||
"platforms": ["windows"],
|
"platforms": ["windows"],
|
||||||
"libs": [
|
"libs": [
|
||||||
"raylibdll"
|
"raylib"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -112,33 +127,36 @@ void deleteFile(const(char)[] path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main(string[] args) {
|
||||||
if (check(buildPath(".", "dub.json"), false)) {
|
if (check(dubFile, false)) {
|
||||||
writeln("Error: This is not a DUB project.");
|
writeln("Error: This is not a DUB project.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
writeln("Info: Pass `%s` if you don't want to download raylib.".format(noLibsArg));
|
||||||
|
|
||||||
// Use the raylib-d script to download the raylib library files.
|
// Use the raylib-d script to download the raylib library files.
|
||||||
// We also have to use `spawnShell` here because raylib-d:install does not accept arguments.
|
// We also have to use `spawnShell` here because raylib-d:install does not accept arguments.
|
||||||
// TODO: Ask the raylib-d project to do something about that.
|
// TODO: Ask the raylib-d project to do something about that.
|
||||||
|
if (args.length == 1 || (args.length > 1 && args[1] != noLibsArg)) {
|
||||||
run("dub add raylib-d");
|
run("dub add raylib-d");
|
||||||
writeln();
|
writeln();
|
||||||
writeln(`"Saying yes to happiness means learning to say no to the things and people that stress you out." - Thema Davis`);
|
writeln(`"Saying yes to happiness means learning to say no to the things and people that stress you out." - Thema Davis`);
|
||||||
writeln();
|
writeln();
|
||||||
auto pid = spawnShell("dub run raylib-d:install");
|
auto pid = spawnShell("dub run raylib-d:install");
|
||||||
wait(pid);
|
wait(pid);
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the old files.
|
// Delete the old files.
|
||||||
deleteFile(buildPath(".", "dub.json"));
|
deleteFile(dubFile);
|
||||||
deleteFile(buildPath(".", "dub.selections.json"));
|
deleteFile(dubyFile);
|
||||||
deleteFile(buildPath(".", ".gitignore"));
|
deleteFile(gitignoreFile);
|
||||||
deleteFile(buildPath(".", "source", "app.d"));
|
deleteFile(appFile);
|
||||||
|
|
||||||
// Create the new files.
|
// Create the new files.
|
||||||
std.file.write(buildPath(".", "dub.json"), defaultDubContent);
|
std.file.write(dubFile, defaultDubContent);
|
||||||
std.file.write(buildPath(".", ".gitignore"), defaultGitignoreContent);
|
std.file.write(gitignoreFile, defaultGitignoreContent);
|
||||||
std.file.write(buildPath(".", "source", "app.d"), defaultAppContent);
|
std.file.write(appFile, defaultAppContent);
|
||||||
if (check(buildPath(".", "assets"), false)) std.file.mkdir(buildPath(".", "assets"));
|
if (check(assetsDir, false)) std.file.mkdir(assetsDir);
|
||||||
if (check(buildPath(".", "web"), false)) std.file.mkdir(buildPath(".", "web"));
|
if (check(webDir, false)) std.file.mkdir(webDir);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue