mirror of
https://github.com/Kapendev/parin.git
synced 2025-04-25 20:49:57 +03:00
Made managed stuff nicer and changed asset names to avoid name collisions.
This commit is contained in:
parent
23615c4c8e
commit
a7c844f210
9 changed files with 47 additions and 24 deletions
|
@ -1,4 +1,4 @@
|
|||
# Assets
|
||||
|
||||
* [Atlas](atlas.png): By [Kapendev](https://kapendev.itch.io), CC0
|
||||
* [Monogram](monogram.png): By [DATAGOBLIN](https://datagoblin.itch.io/monogram), CC0
|
||||
* [Atlas](parin_atlas.png): By [Kapendev](https://kapendev.itch.io), CC0
|
||||
* [Monogram](parin_monogram.png): By [DATAGOBLIN](https://datagoblin.itch.io/monogram), CC0
|
||||
|
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
@ -10,7 +10,7 @@ auto tileFlip = Flip.none;
|
|||
|
||||
void ready() {
|
||||
lockResolution(320, 180);
|
||||
atlas = loadTexture("atlas.png");
|
||||
atlas = loadTexture("parin_atlas.png");
|
||||
// Parse a CSV string representing a tile map, where each tile is 16x16 pixels in size.
|
||||
map.parse("-1,-1,-1\n21,22,23\n37,38,39\n53,54,55", 16, 16);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ auto patchAtlasArea = Rect(5 * 16, 1 * 16, Vec2(16 * 3));
|
|||
|
||||
void ready() {
|
||||
lockResolution(320, 180);
|
||||
atlas = loadTexture("atlas.png");
|
||||
atlas = loadTexture("parin_atlas.png");
|
||||
}
|
||||
|
||||
bool update(float dt) {
|
||||
|
|
|
@ -11,7 +11,7 @@ auto walkAnimation = SpriteAnimation(0, 2, 6);
|
|||
|
||||
void ready() {
|
||||
lockResolution(320, 180);
|
||||
atlas = loadTexture("atlas.png");
|
||||
atlas = loadTexture("parin_atlas.png");
|
||||
}
|
||||
|
||||
bool update(float dt) {
|
||||
|
|
|
@ -21,7 +21,7 @@ bool myButton(Rect area, IStr text) {
|
|||
|
||||
void ready() {
|
||||
lockResolution(320, 180);
|
||||
atlas = loadTexture("atlas.png");
|
||||
atlas = loadTexture("parin_atlas.png");
|
||||
}
|
||||
|
||||
bool update(float dt) {
|
||||
|
|
|
@ -301,6 +301,16 @@ struct TextureId {
|
|||
return getOr().size;
|
||||
}
|
||||
|
||||
/// Sets the filter mode of the texture associated with the resource identifier.
|
||||
void setFilter(Filter value) {
|
||||
getOr().setFilter(value);
|
||||
}
|
||||
|
||||
/// Sets the wrap mode of the texture associated with the resource identifier.
|
||||
void setWrap(Wrap value) {
|
||||
getOr().setWrap(value);
|
||||
}
|
||||
|
||||
/// Checks if the resource identifier is valid. It becomes automatically invalid when the resource is freed.
|
||||
bool isValid() {
|
||||
return data && engineState.textures.has(data);
|
||||
|
@ -392,6 +402,16 @@ struct FontId {
|
|||
return getOr().size;
|
||||
}
|
||||
|
||||
/// Sets the filter mode of the font associated with the resource identifier.
|
||||
void setFilter(Filter value) {
|
||||
getOr().setFilter(value);
|
||||
}
|
||||
|
||||
/// Sets the wrap mode of the font associated with the resource identifier.
|
||||
void setWrap(Wrap value) {
|
||||
getOr().setWrap(value);
|
||||
}
|
||||
|
||||
/// Checks if the resource identifier is valid. It becomes automatically invalid when the resource is freed.
|
||||
bool isValid() {
|
||||
return data && engineState.fonts.has(data);
|
||||
|
@ -519,6 +539,11 @@ struct SoundId {
|
|||
|
||||
@safe @nogc nothrow:
|
||||
|
||||
/// Returns true if the sound associated with the resource identifier is playing.
|
||||
bool isPlaying() {
|
||||
return getOr().isPlaying;
|
||||
}
|
||||
|
||||
/// Returns the current playback time of the sound associated with the resource identifier.
|
||||
float time() {
|
||||
return getOr().time;
|
||||
|
@ -533,6 +558,21 @@ struct SoundId {
|
|||
return getOr().progress;
|
||||
}
|
||||
|
||||
/// Sets the volume level for the sound associated with the resource identifier.
|
||||
void setVolume(float value) {
|
||||
getOr().setVolume(value);
|
||||
}
|
||||
|
||||
/// Sets the pitch for the sound associated with the resource identifier.
|
||||
void setPitch(float value) {
|
||||
getOr().setPitch(value);
|
||||
}
|
||||
|
||||
/// Sets the stereo panning for the sound associated with the resource identifier.
|
||||
void setPan(float value) {
|
||||
getOr().setPan(value);
|
||||
}
|
||||
|
||||
/// Checks if the resource identifier is valid. It becomes automatically invalid when the resource is freed.
|
||||
bool isValid() {
|
||||
return data && engineState.sounds.has(data);
|
||||
|
@ -1299,7 +1339,7 @@ void openWindow(int width, int height, const(IStr)[] args, IStr title = "Parin")
|
|||
engineState.saveTextBuffer.reserve(8192);
|
||||
if (args.length) engineState.assetsPath.append(pathConcat(args[0].pathDir, "assets"));
|
||||
// Load debug font.
|
||||
auto monogramData = cast(const(ubyte)[]) import("monogram.png");
|
||||
auto monogramData = cast(const(ubyte)[]) import("parin_monogram.png");
|
||||
auto monogramImage = rl.LoadImageFromMemory(".png", monogramData.ptr, cast(int) monogramData.length);
|
||||
auto monogramTexture = rl.LoadTextureFromImage(monogramImage);
|
||||
engineState.debugFont = monogramTexture.toParin().toFont(6, 12);
|
||||
|
|
|
@ -284,23 +284,6 @@ struct TileMap {
|
|||
}
|
||||
}
|
||||
|
||||
Result!TileMap toTileMap(IStr csv, int tileWidth, int tileHeight) {
|
||||
auto value = TileMap();
|
||||
auto fault = value.parse(csv, tileWidth, tileHeight);
|
||||
if (fault) {
|
||||
value.free();
|
||||
}
|
||||
return Result!TileMap(value, fault);
|
||||
}
|
||||
|
||||
Result!TileMap loadRawTileMap(IStr path, int tileWidth, int tileHeight) {
|
||||
auto temp = loadTempText(path);
|
||||
if (temp.isNone) {
|
||||
return Result!TileMap(temp.fault);
|
||||
}
|
||||
return toTileMap(temp.get(), tileWidth, tileHeight);
|
||||
}
|
||||
|
||||
Fault saveTileMap(IStr path, TileMap map) {
|
||||
auto csv = prepareTempText();
|
||||
foreach (row; 0 .. map.rowCount) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue