diff --git a/TOUR.md b/TOUR.md index 7843a0d..3281c57 100644 --- a/TOUR.md +++ b/TOUR.md @@ -95,6 +95,10 @@ bool isReleased(Gamepad key, int id = 0); Vec2 wasd(); Vec2 wasdPressed(); Vec2 wasdReleased(); + +Vec2 mouse(); +Vec2 deltaMouse(); +float deltaWheel(); ``` ## Sound @@ -103,15 +107,10 @@ Parin provides a set of sound functions inside the `parin.engine` module. ```d void playSound(Sound sound); -void playSound(SoundId sound); void stopSound(Sound sound); -void stopSound(SoundId sound); void pauseSound(Sound sound); -void pauseSound(SoundId sound); void resumeSound(Sound sound); -void resumeSound(SoundId sound); void updateSound(Sound sound); -void updateSound(SoundId sound); ``` ## Drawing diff --git a/examples/follower.d b/examples/follower.d index b7fb363..0745730 100644 --- a/examples/follower.d +++ b/examples/follower.d @@ -20,10 +20,10 @@ bool update(float dt) { // The sprite should be updated every frame, regardless of whether it is running. sprite.update(dt); // Get some basic info about the mouse. - auto mouseDistance = sprite.position.distanceTo(mouseScreenPosition); - auto mouseDirection = sprite.position.directionTo(mouseScreenPosition); + auto mouseDistance = sprite.position.distanceTo(mouse); + auto mouseDirection = sprite.position.directionTo(mouse); // Move the sprite around in a smooth way. - sprite.followPositionWithSlowdown(mouseScreenPosition, 0.2); + sprite.followPositionWithSlowdown(mouse, 0.2); // Play the right animation. auto isWaiting = mouseDistance < 0.2; @@ -55,7 +55,7 @@ bool update(float dt) { // Draw the sprite, the mouse position and some info. drawSprite(atlas, sprite, options); - drawVec2(mouseScreenPosition, 8, isWaiting ? blank : white.alpha(150)); + drawVec2(mouse, 8, isWaiting ? blank : white.alpha(150)); drawDebugText("Press 1, 2 or 3 to change the character.", Vec2(8)); return false; } diff --git a/examples/viewport.d b/examples/viewport.d index d2ababe..f142fad 100644 --- a/examples/viewport.d +++ b/examples/viewport.d @@ -14,7 +14,7 @@ bool update(float dt) { if (isWindowResized) viewport.resize(resolutionWidth / 2, resolutionHeight / 2); // Draw the mouse position inside the viewport. auto viewportCenter = viewport.size * Vec2(0.5); - auto viewportMousePosition = mouseScreenPosition - Rect(resolution * Vec2(0.5), viewport.size).centerArea.position; + auto viewportMousePosition = mouse - Rect(resolution * Vec2(0.5), viewport.size).centerArea.position; viewport.attach(); drawVec2(viewportCenter, 20); drawVec2(viewportMousePosition, 20); diff --git a/setup/source/app.d b/setup/source/app.d index 43673ba..18bafaa 100755 --- a/setup/source/app.d +++ b/setup/source/app.d @@ -169,8 +169,8 @@ int runDubSetup(string[] args, bool isFirstRun) { } whileExit: if (arg == "Y" || arg == "y") { - auto dub1 = spawnProcess(["dub", "add", "raylib-d"]).wait(); - auto dub2 = spawnProcess(["dub", "run", "raylib-d:install"]).wait(); + auto dub1 = spawnProcess(["dub", "add", "raylib-d", "--verror"]).wait(); + auto dub2 = spawnProcess(["dub", "run", "raylib-d:install", "--verror", "--", "-q", "-u=no"]).wait(); // Remove the backup copies if something failed. if (dub1 != 0 || dub2 != 0) { if (exists(dubCopyFile)) std.file.remove(dubCopyFile); @@ -182,7 +182,7 @@ int runDubSetup(string[] args, bool isFirstRun) { // Replace the dub file content if needed. if (isFirstRun) { std.file.write(dubFile, dubFileContent); - std.file.remove(dubLockFile); + if (exists(dubLockFile)) std.file.remove(dubLockFile); // Remove the backup copies. if (exists(dubCopyFile)) std.file.remove(dubCopyFile); if (exists(dubLockCopyFile)) std.file.remove(dubLockCopyFile); @@ -202,8 +202,14 @@ int runDubSetup(string[] args, bool isFirstRun) { } int main(string[] args) { - auto isSimpProject = !exists(dubFile); + auto result = 0; auto isFirstRun = !exists(assetsDir); - if (isSimpProject) return runSimpSetup(args[1 .. $], isFirstRun); - else return runDubSetup(args[1 .. $], isFirstRun); + auto isSimpProject = !exists(dubFile); + if (isSimpProject) { + result = runSimpSetup(args[1 .. $], isFirstRun); + } else { + result = runDubSetup(args[1 .. $], isFirstRun); + } + if (result == 0) writeln("Done!"); + return result; } diff --git a/source/parin/engine.d b/source/parin/engine.d index aa99748..cd793b9 100644 --- a/source/parin/engine.d +++ b/source/parin/engine.d @@ -166,8 +166,8 @@ struct DrawOptions { Vec2 scale = Vec2(1.0f); /// The scale of the drawn object. float rotation = 0.0f; /// The rotation of the drawn object, in degrees. Color color = white; /// The color of the drawn object. - Hook hook = Hook.topLeft; /// An value representing the origin point of the drawn object when origin is set to zero. - Flip flip = Flip.none; /// An value representing flipping orientations. + Hook hook = Hook.topLeft; /// A value representing the origin point of the drawn object when origin is set to zero. + Flip flip = Flip.none; /// A value representing flipping orientations. @safe @nogc nothrow: @@ -555,9 +555,9 @@ struct SoundId { /// Represents the viewing area for rendering. struct Viewport { rl.RenderTexture2D data; - Color color; /// TOOO - Blend blend; /// TOOO - bool isAttached; /// Indicates whether the viewport is currently in use. + Color color; /// The background color of the viewport. + Blend blend; /// A value representing blending modes. + bool isAttached; /// Indicates whether the viewport is currently in use. @safe @nogc nothrow: @@ -1652,7 +1652,7 @@ float deltaTime() { /// Returns the change in mouse position since the last frame. @trusted Vec2 deltaMouse() { - return toParin(rl.GetMouseDelta()); + return rl.GetMouseDelta().toParin(); } /// Returns the change in mouse wheel position since the last frame. @@ -1675,9 +1675,8 @@ float deltaWheel() { /// Measures the size of the specified text when rendered with the given font and draw options. @trusted Vec2 measureTextSize(Font font, IStr text, DrawOptions options = DrawOptions()) { - if (font.isEmpty || text.length == 0) { - return Vec2(); - } + if (font.isEmpty || text.length == 0) return Vec2(); + auto result = Vec2(); auto tempByteCounter = 0; // Used to count longer text line num chars. auto byteCounter = 0;