Ribbon Magic tool sound effect
CC-BY 3.0 by https://freesound.org/people/CosmicEmbers/
This commit is contained in:
parent
375207f3d3
commit
ab53612d50
7 changed files with 40 additions and 18 deletions
|
|
@ -6,7 +6,7 @@ Copyright (c) 2002-2023
|
||||||
Various contributors (see below, and CHANGES.txt)
|
Various contributors (see below, and CHANGES.txt)
|
||||||
https://tuxpaint.org/
|
https://tuxpaint.org/
|
||||||
|
|
||||||
June 17, 2002 - May 22, 2023
|
June 17, 2002 - May 23, 2023
|
||||||
|
|
||||||
* Design and Coding:
|
* Design and Coding:
|
||||||
|
|
||||||
|
|
@ -202,6 +202,13 @@ June 17, 2002 - May 22, 2023
|
||||||
Creative Commons Attribution 4.0 International (CC BY 4.0)
|
Creative Commons Attribution 4.0 International (CC BY 4.0)
|
||||||
by https://freesound.org/people/PercyFrench/
|
by https://freesound.org/people/PercyFrench/
|
||||||
|
|
||||||
|
"Ribbon" Magic tool
|
||||||
|
by Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
|
Sound effect "cape-swoosh"
|
||||||
|
(https://freesound.org/people/CosmicEmbers/sounds/161415/)
|
||||||
|
Creative Commons Attribution 3.0 Unported (CC BY 3.0)
|
||||||
|
by https://freesound.org/people/CosmicEmbers/
|
||||||
|
|
||||||
Mouse accessibility code and keyboard access
|
Mouse accessibility code and keyboard access
|
||||||
Ankit Choudary <ankit.goaldecided@gmail.com>, as part of GSOC 2010,
|
Ankit Choudary <ankit.goaldecided@gmail.com>, as part of GSOC 2010,
|
||||||
with integration and fixes by Pere Pujal i Carabantes <pere@fornol.no-ip.org>
|
with integration and fixes by Pere Pujal i Carabantes <pere@fornol.no-ip.org>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ Copyright (c) 2002-2023
|
||||||
Various contributors (see below, and AUTHORS.txt)
|
Various contributors (see below, and AUTHORS.txt)
|
||||||
https://tuxpaint.org/
|
https://tuxpaint.org/
|
||||||
|
|
||||||
2023.May.22 (0.9.31)
|
2023.May.23 (0.9.31)
|
||||||
* New Magic Tools:
|
* New Magic Tools:
|
||||||
----------------
|
----------------
|
||||||
* WIP Loops - Draw loop-the-loops.
|
* WIP Loops - Draw loop-the-loops.
|
||||||
|
|
@ -15,17 +15,16 @@ https://tuxpaint.org/
|
||||||
https://freesound.org/people/Jagadamba/
|
https://freesound.org/people/Jagadamba/
|
||||||
- WIP needs icon
|
- WIP needs icon
|
||||||
|
|
||||||
* WIP Ribbon - Paints a flowing, fixed-length ribbon.
|
* Ribbon - Paints a flowing, fixed-length ribbon.
|
||||||
Bill Kendrick <bill@newbreedsoftware.com>
|
Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
- WIP needs sfx
|
Sound effect CC-BY 3.0 by
|
||||||
- WIP needs icon
|
https://freesound.org/people/CosmicEmbers/
|
||||||
|
|
||||||
* WIP Smooth - Freehand paintbrush with a smoothing effect (Bezier curve)
|
* Smooth - Freehand paintbrush with a smoothing effect (Bezier curve)
|
||||||
h/t Pere for the idea
|
h/t Pere for the idea
|
||||||
Bill Kendrick <bill@newbreedsoftware.com>
|
Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
Sound effect CC-BY 4.0 by
|
Sound effect CC-BY 4.0 by
|
||||||
https://freesound.org/people/PercyFrench/
|
https://freesound.org/people/PercyFrench/
|
||||||
- WIP needs icon
|
|
||||||
|
|
||||||
* WIP Squiggles - Draw squiggly shapes.
|
* WIP Squiggles - Draw squiggly shapes.
|
||||||
Bill Kendrick <bill@newbreedsoftware.com>
|
Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
|
|
|
||||||
BIN
magic/icons/ribbon.png
Normal file
BIN
magic/icons/ribbon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
magic/icons/smooth.png
Normal file
BIN
magic/icons/smooth.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
BIN
magic/sounds/ribbon.ogg
Normal file
BIN
magic/sounds/ribbon.ogg
Normal file
Binary file not shown.
|
|
@ -23,7 +23,7 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
(See COPYING.txt)
|
(See COPYING.txt)
|
||||||
|
|
||||||
Last updated: May 15, 2023
|
Last updated: May 23, 2023
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -44,6 +44,7 @@ static Uint8 ribbon_r, ribbon_g, ribbon_b;
|
||||||
static Uint32 ribbon_segment_color;
|
static Uint32 ribbon_segment_color;
|
||||||
static int ribbon_x[MAX_LENGTH], ribbon_y[MAX_LENGTH];
|
static int ribbon_x[MAX_LENGTH], ribbon_y[MAX_LENGTH];
|
||||||
static int ribbon_tail = 0, ribbon_head = 0;
|
static int ribbon_tail = 0, ribbon_head = 0;
|
||||||
|
static double ribbon_old_angle;
|
||||||
static Mix_Chunk *ribbon_snd;
|
static Mix_Chunk *ribbon_snd;
|
||||||
|
|
||||||
int ribbon_init(magic_api * api, Uint32 disabled_features);
|
int ribbon_init(magic_api * api, Uint32 disabled_features);
|
||||||
|
|
@ -88,7 +89,7 @@ int ribbon_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
char fname[1024];
|
char fname[1024];
|
||||||
|
|
||||||
snprintf(fname, sizeof(fname), "%ssounds/magic/rainbow.wav", api->data_directory); // FIXME
|
snprintf(fname, sizeof(fname), "%ssounds/magic/ribbon.ogg", api->data_directory);
|
||||||
ribbon_snd = Mix_LoadWAV(fname);
|
ribbon_snd = Mix_LoadWAV(fname);
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
|
|
@ -105,7 +106,7 @@ SDL_Surface *ribbon_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
char fname[1024];
|
char fname[1024];
|
||||||
|
|
||||||
snprintf(fname, sizeof(fname), "%simages/magic/rainbow.png", api->data_directory); // FIXME
|
snprintf(fname, sizeof(fname), "%simages/magic/ribbon.png", api->data_directory);
|
||||||
|
|
||||||
return (IMG_Load(fname));
|
return (IMG_Load(fname));
|
||||||
}
|
}
|
||||||
|
|
@ -164,11 +165,23 @@ void ribbon_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
if (ribbon_head == ribbon_tail)
|
if (ribbon_head == ribbon_tail)
|
||||||
ribbon_tail = (ribbon_tail + 1) % ribbon_max_length;
|
ribbon_tail = (ribbon_tail + 1) % ribbon_max_length;
|
||||||
|
|
||||||
|
|
||||||
|
angle = 0.0;
|
||||||
|
|
||||||
if (!first_click) {
|
if (!first_click) {
|
||||||
|
double x_angle;
|
||||||
|
|
||||||
|
if (sqrt((x - ox) * (x - ox) + (y - oy) * (y - oy)) > 16)
|
||||||
|
{
|
||||||
|
/* Play swooshing sfx if we're moving quickly and making a big angle */
|
||||||
|
x_angle = (fabs(atan2((double)(y - oy), (double)(x - ox))) * 2.0);
|
||||||
|
if (fabs(x_angle - ribbon_old_angle) > (M_PI / 4.0))
|
||||||
|
api->playsound(ribbon_snd, (x * 255) / canvas->w, 255);
|
||||||
|
ribbon_old_angle = x_angle;
|
||||||
|
}
|
||||||
|
|
||||||
pt = ribbon_tail;
|
pt = ribbon_tail;
|
||||||
angle = 0.0;
|
|
||||||
do {
|
do {
|
||||||
double x_angle;
|
|
||||||
int brt;
|
int brt;
|
||||||
|
|
||||||
pt2 = ((pt + 1) % ribbon_max_length);
|
pt2 = ((pt + 1) % ribbon_max_length);
|
||||||
|
|
@ -188,7 +201,6 @@ void ribbon_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
r = max(min(ribbon_r + brt, 255), 0);
|
r = max(min(ribbon_r + brt, 255), 0);
|
||||||
g = max(min(ribbon_g + brt, 255), 0);
|
g = max(min(ribbon_g + brt, 255), 0);
|
||||||
b = max(min(ribbon_b + brt, 255), 0);
|
b = max(min(ribbon_b + brt, 255), 0);
|
||||||
// b = (Uint8) (((double) ribbon_b * angle) / M_PI);
|
|
||||||
|
|
||||||
ribbon_segment_color = SDL_MapRGB(canvas->format, r, g, b);
|
ribbon_segment_color = SDL_MapRGB(canvas->format, r, g, b);
|
||||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, ribbon_linecb);
|
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, ribbon_linecb);
|
||||||
|
|
@ -200,15 +212,13 @@ void ribbon_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
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;
|
||||||
|
|
||||||
api->playsound(ribbon_snd, (x * 255) / canvas->w, 255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affect the canvas on click:
|
// Affect the canvas on click:
|
||||||
void ribbon_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
void ribbon_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect)
|
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect)
|
||||||
{
|
{
|
||||||
ribbon_head = ribbon_tail = 0;
|
ribbon_head = ribbon_tail = ribbon_old_angle = 0;
|
||||||
ribbon_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
ribbon_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,12 @@ enum {
|
||||||
NUM_TOOLS
|
NUM_TOOLS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char * smooth_icon_fnames[NUM_TOOLS] = {
|
||||||
|
"smooth.png",
|
||||||
|
"rainbow.png", // FIXME
|
||||||
|
"rainbow.png", // FIXME
|
||||||
|
};
|
||||||
|
|
||||||
char * smooth_snd_fnames[NUM_TOOLS] = {
|
char * smooth_snd_fnames[NUM_TOOLS] = {
|
||||||
"smooth.ogg",
|
"smooth.ogg",
|
||||||
"squiggles.ogg",
|
"squiggles.ogg",
|
||||||
|
|
@ -144,11 +150,11 @@ int smooth_get_tool_count(magic_api * api ATTRIBUTE_UNUSED)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load our icon:
|
// Load our icon:
|
||||||
SDL_Surface *smooth_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
SDL_Surface *smooth_get_icon(magic_api * api, int which)
|
||||||
{
|
{
|
||||||
char fname[1024];
|
char fname[1024];
|
||||||
|
|
||||||
snprintf(fname, sizeof(fname), "%simages/magic/rainbow.png", api->data_directory); // FIXME
|
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, smooth_icon_fnames[which]);
|
||||||
return (IMG_Load(fname));
|
return (IMG_Load(fname));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue