diff --git a/.gitignore b/.gitignore index 4696b1b..3413291 100644 --- a/.gitignore +++ b/.gitignore @@ -9,8 +9,7 @@ # Cheers! # -andrewrk -SDL2_image-devel-2.6.2-VC/ -SDL2-devel-2.26.1-VC/ +SDL2*/ zig-cache/ zig-out/ /release/ diff --git a/README.md b/README.md index 6fade20..489743d 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,9 @@ Aside from zig (obviously), you need both SDL2 and SDL_Image development release 1. Download the sdl development release SDL2-devel-2.26.1-VC and unzip in the main directory of this repo. [releases](https://github.com/libsdl-org/SDL/releases/tag/release-2.26.1) 2. Download the sdl2 image development release SDL2_image-devel-2.6.2-VC and unzip in the main directory of this repo. [releases](https://github.com/libsdl-org/SDL_image/releases/tag/release-2.6.2) -3. Run `zig build -Dnative=true` this builds a native executable that can be found in the `zig-out/bin` directory -4. Run `./game1.exe` and let the fun begin. +3. Download the sdl2 mixer development release SDL2_mixer-devel-2.6.2-VC and unzip in the main directory of this repo. [releases](https://github.com/libsdl-org/SDL_mixer/releases/tag/release-2.6.2) +4. Run `zig build -Dnative=true` this builds a native executable that can be found in the `zig-out/bin` directory +5. Run `./game1.exe` and let the fun begin. ### WASM @@ -117,11 +118,12 @@ mset(x, y, v) -- set map value #### Audio -##### Not Yet Implemented + +##### Partially Implemented ``` -music([n, [fade_len, [channel_mask]]]) -- play music; n = -1: stop -sfx(n, [channel, [offset]]) -- play sfx; n = -1: stop in channel; n = -2: release loop in channel +sfx(n) -- WASM only: play sfx N; sfx files are expected to be in .wav format in the resources folder, named numerically, (0.wav, 1.wav, etc). SFX files will play once, and if the same SFX file is called before the first completes, it will terminate the first preemptively. +music([n, [fade_len, [channel_mask]]]) -- WASM only: play "n" pattern music; n = -1: stop. fade_len will fade-in the music over fade_len milliseconds. channel_mask is not currently used. Music files are expected to be in mp3 format in the resources folder, named numerically (0.mp3, 1.mp3, etc). ``` ## Current Status diff --git a/build.zig b/build.zig index 77bd28f..bcb4d0c 100644 --- a/build.zig +++ b/build.zig @@ -9,6 +9,8 @@ pub fn build(b: *std.build.Builder) void { if (build_native) { const installSprites = b.addInstallFile(.{ .path = "assets/sprites.png" }, "bin/sprites.png"); + const installMusic = b.addInstallFile(.{ .path = "assets/0.mp3" }, "bin/0.mp3"); + const installSfx = b.addInstallFile(.{ .path = "assets/0.wav" }, "bin/0.wav"); // Standard release options allow the person running `zig build` to select // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. @@ -18,21 +20,29 @@ pub fn build(b: *std.build.Builder) void { exe.addIncludePath("SDL2-devel-2.26.1-VC/SDL2-2.26.1/include"); exe.addLibraryPath("SDL2_image-devel-2.6.2-VC/SDL2_image-2.6.2/lib/x64"); exe.addIncludePath("SDL2_image-devel-2.6.2-VC/SDL2_image-2.6.2/include"); + exe.addLibraryPath("SDL2_mixer-devel-2.6.2-VC/SDL2_mixer-2.6.2/lib/x64"); + exe.addIncludePath("SDL2_mixer-devel-2.6.2-VC/SDL2_mixer-2.6.2/include"); + const installSDLMixerDLL = b.addInstallFile(.{ .path = "SDL2_mixer-devel-2.6.2-VC/SDL2_mixer-2.6.2/lib/x64/SDL2_mixer.dll" }, "bin/SDL2_mixer.dll"); const installSDLImageDLL = b.addInstallFile(.{ .path = "SDL2_image-devel-2.6.2-VC/SDL2_image-2.6.2/lib/x64/SDL2_image.dll" }, "bin/SDL2_image.dll"); const installSDLDLL = b.addInstallFile(.{ .path = "SDL2-devel-2.26.1-VC/SDL2-2.26.1/lib/x64/SDL2.dll" }, "bin/SDL2.dll"); exe.linkLibC(); exe.linkSystemLibraryName("SDL2"); exe.linkSystemLibraryName("SDL2_image"); + exe.linkSystemLibraryName("SDL2_mixer"); exe.setTarget(target); exe.setBuildMode(mode); exe.install(); + + exe.step.dependOn(&installSDLMixerDLL.step); exe.step.dependOn(&installSDLImageDLL.step); exe.step.dependOn(&installSDLDLL.step); + exe.step.dependOn(&installMusic.step); + exe.step.dependOn(&installSfx.step); exe.step.dependOn(&installSprites.step); } diff --git a/index.html b/index.html index 71823bf..79b12cf 100644 --- a/index.html +++ b/index.html @@ -7,6 +7,8 @@
The buttons are a, s and the arrow keys.
+ +