diff options
| author | tslil clingman <> | 2021-10-27 15:37:28 -0400 |
|---|---|---|
| committer | tslil clingman <> | 2021-10-27 15:37:28 -0400 |
| commit | 48dee0817f5fe8c09a085f0150e0c6b4a699ab7c (patch) | |
| tree | d6ab0a54f2260cb73c79e00ca1489c034f555f09 /src/sfml/audio/Sound.zig | |
| parent | 486935299e4b7e097754611d9f8dd40003351ae4 (diff) | |
Update SFML wrapper
Diffstat (limited to 'src/sfml/audio/Sound.zig')
| -rw-r--r-- | src/sfml/audio/Sound.zig | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/sfml/audio/Sound.zig b/src/sfml/audio/Sound.zig index 073aa5f..92acb46 100644 --- a/src/sfml/audio/Sound.zig +++ b/src/sfml/audio/Sound.zig @@ -14,7 +14,7 @@ pub fn create() !Sound { var sound = sf.c.sfSound_create(); if (sound == null) return sf.Error.nullptrUnknownReason; - return Sound{ .ptr = sound.? }; + return Sound{ ._ptr = sound.? }; } /// Inits a sound with a SoundBuffer object @@ -25,74 +25,74 @@ pub fn createFromBuffer(buffer: sf.SoundBuffer) !Sound { } /// Destroys this sound object -pub fn destroy(self: Sound) void { - sf.c.sfSound_destroy(self.ptr); +pub fn destroy(self: *Sound) void { + sf.c.sfSound_destroy(self._ptr); } // Sound control functions /// Plays the sound -pub fn play(self: Sound) void { - sf.c.sfSound_play(self.ptr); +pub fn play(self: *Sound) void { + sf.c.sfSound_play(self._ptr); } /// Pauses the sound -pub fn pause(self: Sound) void { - sf.c.sfSound_pause(self.ptr); +pub fn pause(self: *Sound) void { + sf.c.sfSound_pause(self._ptr); } /// Stops the sound and resets the player position -pub fn stop(self: Sound) void { - sf.c.sfSound_stop(self.ptr); +pub fn stop(self: *Sound) void { + sf.c.sfSound_stop(self._ptr); } // Getters / Setters /// Gets the buffer this sound is attached to pub fn getBuffer(self: Sound) ?sf.SoundBuffer { - var buf = sf.c.sfSound_getBuffer(self.ptr); + var buf = sf.c.sfSound_getBuffer(self._ptr); if (buf) |buffer| { - return .{ .ptr = buffer }; + return .{ ._ptr = buffer }; } else return null; } /// Sets the buffer this sound will play -pub fn setBuffer(self: Sound, buffer: sf.SoundBuffer) void { - sf.c.sfSound_setBuffer(self.ptr, buffer.ptr); +pub fn setBuffer(self: *Sound, buffer: sf.SoundBuffer) void { + sf.c.sfSound_setBuffer(self._ptr, buffer._ptr); } /// Gets the current playing offset of the sound pub fn getPlayingOffset(self: Sound) sf.Time { - return sf.Time.fromCSFML(sf.c.sfSound_getPlayingOffset(self.ptr)); + return sf.Time._fromCSFML(sf.c.sfSound_getPlayingOffset(self._ptr)); } /// Sets the current playing offset of the sound -pub fn setPlayingOffset(self: Sound, offset: sf.Time) void { - sf.c.sfSound_setPlayingOffset(self.ptr, offset.toCSFML()); +pub fn setPlayingOffset(self: *Sound, offset: sf.Time) void { + sf.c.sfSound_setPlayingOffset(self._ptr, offset._toCSFML()); } /// Tells whether or not this sound is in loop mode pub fn getLoop(self: Sound) bool { - return sf.c.sfSound_getLoop(self.ptr) != 0; + return sf.c.sfSound_getLoop(self._ptr) != 0; } /// Enable or disable auto loop -pub fn setLoop(self: Sound, loop: bool) void { - sf.c.sfSound_setLoop(self.ptr, if (loop) 1 else 0); +pub fn setLoop(self: *Sound, loop: bool) void { + sf.c.sfSound_setLoop(self._ptr, @boolToInt(loop)); } /// Sets the pitch of the sound pub fn getPitch(self: Sound) f32 { - return sf.c.sfSound_getPitch(self.ptr); + return sf.c.sfSound_getPitch(self._ptr); } /// Gets the pitch of the sound -pub fn setPitch(self: Sound, pitch: f32) void { - sf.c.sfSound_setPitch(self.ptr, pitch); +pub fn setPitch(self: *Sound, pitch: f32) void { + sf.c.sfSound_setPitch(self._ptr, pitch); } /// Sets the volume of the sound pub fn getVolume(self: Sound) f32 { - return sf.c.sfSound_getVolume(self.ptr); + return sf.c.sfSound_getVolume(self._ptr); } /// Gets the volume of the sound -pub fn setVolume(self: Sound, volume: f32) void { - sf.c.sfSound_setVolume(self.ptr, volume); +pub fn setVolume(self: *Sound, volume: f32) void { + sf.c.sfSound_setVolume(self._ptr, volume); } pub const getStatus = @compileError("Function is not implemented yet."); @@ -104,4 +104,4 @@ pub const getMinDistance = @compileError("Function is not implemented yet."); pub const getAttenuation = @compileError("Function is not implemented yet."); /// Pointer to the csfml sound -ptr: *sf.c.sfSound, +_ptr: *sf.c.sfSound, |
