"Rotate" sound effects

This commit is contained in:
Bill Kendrick 2024-09-24 23:55:37 -07:00
parent 23a82cef5a
commit 4ee781c6de
5 changed files with 33 additions and 9 deletions

View file

@ -6,7 +6,7 @@ Copyright (c) 2002-2024
Various contributors (see below, and CHANGES.txt) Various contributors (see below, and CHANGES.txt)
https://tuxpaint.org/ https://tuxpaint.org/
June 17, 2002 - September 17, 2024 June 17, 2002 - September 24, 2024
* Design and Coding: * Design and Coding:
@ -189,6 +189,14 @@ June 17, 2002 - September 17, 2024
Creative Commons 0 by DigitalUnderglow Creative Commons 0 by DigitalUnderglow
<https://freesound.org/people/DigitalUnderglow/> <https://freesound.org/people/DigitalUnderglow/>
Rotate magic tool
by Bill Kendrick <bill@newbreedsoftware.com>
Rotate sound effects
Sound effects based on "Rotating tank turret planetary electric motor"
<https://freesound.org/people/lorefold/sounds/607310/>
Creative Commons 0 by lorefold <https://freesound.org/people/lorefold/>
Bloom magic tool Bloom magic tool
by Bill Kendrick <bill@newbreedsoftware.com> by Bill Kendrick <bill@newbreedsoftware.com>

View file

@ -18,8 +18,10 @@ https://tuxpaint.org/
+ Closes https://sourceforge.net/p/tuxpaint/feature-requests/257/ + Closes https://sourceforge.net/p/tuxpaint/feature-requests/257/
* "Rotate", rotate's the entire image on the canvas. * "Rotate", rotate's the entire image on the canvas.
+ Bill Kendrick <bill@newbreedsoftware.com> + Code Bill Kendrick <bill@newbreedsoftware.com>
+ TODO Sound effect + Sound effects based on "Rotating tank turret planetary electric motor"
Creative Commons 0 by lorefold
<https://freesound.org/people/lorefold/>
+ TODO Icon + TODO Icon
+ TODO Documentation + TODO Documentation

Binary file not shown.

Binary file not shown.

View file

@ -32,7 +32,7 @@
#include "SDL_mixer.h" #include "SDL_mixer.h"
#include "SDL2_rotozoom.h" #include "SDL2_rotozoom.h"
static Mix_Chunk *rotate_snd; static Mix_Chunk *rotate_snd_drag, *rotate_snd_release;
SDL_Surface * rotate_snapshot = NULL; SDL_Surface * rotate_snapshot = NULL;
Uint32 rotate_color; Uint32 rotate_color;
float rotate_last_angle = 0.0; float rotate_last_angle = 0.0;
@ -79,8 +79,11 @@ int rotate_init(magic_api * api, Uint8 disabled_features ATTRIBUTE_UNUSED, Uint8
{ {
char fname[1024]; char fname[1024];
snprintf(fname, sizeof(fname), "%ssounds/magic/xor.ogg", api->data_directory); // FIXME snprintf(fname, sizeof(fname), "%ssounds/magic/rotate-drag.ogg", api->data_directory);
rotate_snd = Mix_LoadWAV(fname); rotate_snd_drag = Mix_LoadWAV(fname);
snprintf(fname, sizeof(fname), "%ssounds/magic/rotate-release.ogg", api->data_directory);
rotate_snd_release = Mix_LoadWAV(fname);
return (1); return (1);
} }
@ -166,7 +169,7 @@ void rotate_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * canv
update_rect->w = canvas->w; update_rect->w = canvas->w;
update_rect->h = canvas->h; update_rect->h = canvas->h;
api->playsound(rotate_snd, 128, 255); api->playsound(rotate_snd_drag, 128, 255);
} }
void rotate_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, void rotate_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
@ -181,6 +184,10 @@ void rotate_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
* switching [back] to thsi tool */ * switching [back] to thsi tool */
rotate_clicked_since_switchin = 1; rotate_clicked_since_switchin = 1;
/* Stop any sound (in case "release" version is playing),
so we can play the main "drag" sound immediately */
api->stopsound();
/* Call the drag function to do the work /* Call the drag function to do the work
* (it will add the click positions angle, making it a net * (it will add the click positions angle, making it a net
* 0-radian rotation _this time_) */ * 0-radian rotation _this time_) */
@ -202,12 +209,19 @@ void rotate_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED
update_rect->y = 0; update_rect->y = 0;
update_rect->w = canvas->w; update_rect->w = canvas->w;
update_rect->h = canvas->h; update_rect->h = canvas->h;
/* Stop any "drag" sound, and play "release" immediately */
api->stopsound();
api->playsound(rotate_snd_release, 128, 255);
} }
void rotate_shutdown(magic_api * api ATTRIBUTE_UNUSED) void rotate_shutdown(magic_api * api ATTRIBUTE_UNUSED)
{ {
if (rotate_snd != NULL) if (rotate_snd_drag != NULL)
Mix_FreeChunk(rotate_snd); Mix_FreeChunk(rotate_snd_drag);
if (rotate_snd_release != NULL)
Mix_FreeChunk(rotate_snd_release);
if (rotate_snapshot != NULL) if (rotate_snapshot != NULL)
{ {