Sparkles can now be different colors.
This commit is contained in:
parent
445a32230d
commit
2f29e8aef1
3 changed files with 86 additions and 5 deletions
|
|
@ -19,6 +19,10 @@ $Id$
|
||||||
back into 16-bit unicode characters to satisfy SDL_ttf. Tested on
|
back into 16-bit unicode characters to satisfy SDL_ttf. Tested on
|
||||||
Windows and Linux.)
|
Windows and Linux.)
|
||||||
John Popplewell <john@johnnypops.demon.co.uk>
|
John Popplewell <john@johnnypops.demon.co.uk>
|
||||||
|
|
||||||
|
* Magic tool improvements:
|
||||||
|
------------------------
|
||||||
|
* Sparkles can now be different colors.
|
||||||
|
|
||||||
* Translation Updates:
|
* Translation Updates:
|
||||||
--------------------
|
--------------------
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@
|
||||||
For Tux Paint
|
For Tux Paint
|
||||||
List of available tools.
|
List of available tools.
|
||||||
|
|
||||||
Copyright (c) 2004 by Bill Kendrick
|
Copyright (c) 2002-2006 by Bill Kendrick
|
||||||
bill@newbreedsoftware.com
|
bill@newbreedsoftware.com
|
||||||
http://www.newbreedsoftware.com/tuxpaint/
|
http://www.newbreedsoftware.com/tuxpaint/
|
||||||
|
|
||||||
June 29, 2002 - December 11, 2004
|
June 29, 2002 - February 13, 2006
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ const int magic_colors[] = {
|
||||||
COLORSEL_ENABLE, // small bricks
|
COLORSEL_ENABLE, // small bricks
|
||||||
|
|
||||||
COLORSEL_DISABLE,
|
COLORSEL_DISABLE,
|
||||||
COLORSEL_DISABLE,
|
COLORSEL_ENABLE, // sparkles
|
||||||
|
|
||||||
COLORSEL_DISABLE,
|
COLORSEL_DISABLE,
|
||||||
COLORSEL_DISABLE,
|
COLORSEL_DISABLE,
|
||||||
|
|
|
||||||
|
|
@ -1547,7 +1547,7 @@ static SDL_Surface * img_scroll_up_off, * img_scroll_down_off;
|
||||||
static SDL_Surface * img_grow, * img_shrink;
|
static SDL_Surface * img_grow, * img_shrink;
|
||||||
static SDL_Surface * img_bold, * img_italic;
|
static SDL_Surface * img_bold, * img_italic;
|
||||||
|
|
||||||
static SDL_Surface * img_sparkles;
|
static SDL_Surface * img_sparkles, * img_sparkles_color;
|
||||||
static SDL_Surface * img_grass;
|
static SDL_Surface * img_grass;
|
||||||
|
|
||||||
static SDL_Surface * img_title_on, * img_title_off,
|
static SDL_Surface * img_title_on, * img_title_off,
|
||||||
|
|
@ -2377,6 +2377,7 @@ static Uint32 (*getpixels[])(SDL_Surface *, int, int) = {
|
||||||
static void do_undo(void);
|
static void do_undo(void);
|
||||||
static void do_redo(void);
|
static void do_redo(void);
|
||||||
static void render_brush(void);
|
static void render_brush(void);
|
||||||
|
static void render_sparkles(void);
|
||||||
static void playsound(int chan, int s, int override);
|
static void playsound(int chan, int s, int override);
|
||||||
static void line_xor(int x1, int y1, int x2, int y2);
|
static void line_xor(int x1, int y1, int x2, int y2);
|
||||||
static void rect_xor(int x1, int y1, int x2, int y2);
|
static void rect_xor(int x1, int y1, int x2, int y2);
|
||||||
|
|
@ -2747,6 +2748,7 @@ int main(int argc, char * argv[])
|
||||||
|
|
||||||
img_cur_brush = NULL;
|
img_cur_brush = NULL;
|
||||||
render_brush();
|
render_brush();
|
||||||
|
render_sparkles();
|
||||||
|
|
||||||
brush_scroll = 0;
|
brush_scroll = 0;
|
||||||
stamp_scroll = 0;
|
stamp_scroll = 0;
|
||||||
|
|
@ -3899,6 +3901,7 @@ static void mainloop(void)
|
||||||
playsound(1, SND_BUBBLE, 1);
|
playsound(1, SND_BUBBLE, 1);
|
||||||
draw_colors(COLORSEL_REFRESH);
|
draw_colors(COLORSEL_REFRESH);
|
||||||
render_brush();
|
render_brush();
|
||||||
|
render_sparkles();
|
||||||
draw_tux_text(TUX_KISS, color_names[cur_color], 1);
|
draw_tux_text(TUX_KISS, color_names[cur_color], 1);
|
||||||
|
|
||||||
if (cur_tool == TOOL_TEXT)
|
if (cur_tool == TOOL_TEXT)
|
||||||
|
|
@ -6271,7 +6274,7 @@ static void blit_magic(int x, int y, int button_down)
|
||||||
dest.x = x - 16;
|
dest.x = x - 16;
|
||||||
dest.y = y - 16;
|
dest.y = y - 16;
|
||||||
|
|
||||||
SDL_BlitSurface(img_sparkles, &src, canvas, &dest);
|
SDL_BlitSurface(img_sparkles_color, &src, canvas, &dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cur_magic == MAGIC_GRASS)
|
else if (cur_magic == MAGIC_GRASS)
|
||||||
|
|
@ -10889,6 +10892,79 @@ static void render_brush(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Create the sparkles in the current color: */
|
||||||
|
|
||||||
|
static void render_sparkles(void)
|
||||||
|
{
|
||||||
|
Uint32 amask;
|
||||||
|
int x, y;
|
||||||
|
Uint8 r, g, b, a;
|
||||||
|
Uint32 (*getpixel_sparkles)(SDL_Surface *, int, int) = getpixels[img_sparkles->format->BytesPerPixel];
|
||||||
|
void (*putpixel_sparkles)(SDL_Surface *, int, int, Uint32) = putpixels[img_sparkles->format->BytesPerPixel];
|
||||||
|
|
||||||
|
|
||||||
|
/* Free the old rendered brush (if any): */
|
||||||
|
|
||||||
|
if (img_sparkles_color != NULL)
|
||||||
|
{
|
||||||
|
SDL_FreeSurface(img_sparkles_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Create a surface to render into: */
|
||||||
|
|
||||||
|
amask = ~(img_sparkles->format->Rmask |
|
||||||
|
img_sparkles->format->Gmask |
|
||||||
|
img_sparkles->format->Bmask);
|
||||||
|
|
||||||
|
img_sparkles_color =
|
||||||
|
SDL_CreateRGBSurface(SDL_SWSURFACE,
|
||||||
|
img_sparkles->w,
|
||||||
|
img_sparkles->h,
|
||||||
|
img_sparkles->format->BitsPerPixel,
|
||||||
|
img_sparkles->format->Rmask,
|
||||||
|
img_sparkles->format->Gmask,
|
||||||
|
img_sparkles->format->Bmask,
|
||||||
|
amask);
|
||||||
|
|
||||||
|
if (img_sparkles_color == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "\nError: Can't render sparkles!\n"
|
||||||
|
"The Simple DirectMedia Layer error that occurred was:\n"
|
||||||
|
"%s\n\n", SDL_GetError());
|
||||||
|
|
||||||
|
cleanup();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Render the colored sparkles: */
|
||||||
|
|
||||||
|
SDL_LockSurface(img_sparkles);
|
||||||
|
SDL_LockSurface(img_sparkles_color);
|
||||||
|
|
||||||
|
for (y = 0; y < img_sparkles->h; y++)
|
||||||
|
{
|
||||||
|
for (x = 0; x < img_sparkles->w; x++)
|
||||||
|
{
|
||||||
|
SDL_GetRGBA(getpixel_sparkles(img_sparkles, x, y),
|
||||||
|
img_sparkles->format,
|
||||||
|
&r, &g, &b, &a);
|
||||||
|
|
||||||
|
putpixel_sparkles(img_sparkles_color, x, y,
|
||||||
|
SDL_MapRGBA(img_sparkles_color->format,
|
||||||
|
color_hexes[cur_color][0],
|
||||||
|
color_hexes[cur_color][1],
|
||||||
|
color_hexes[cur_color][2],
|
||||||
|
a));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_UnlockSurface(img_sparkles_color);
|
||||||
|
SDL_UnlockSurface(img_sparkles);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Play a sound: */
|
/* Play a sound: */
|
||||||
|
|
||||||
static void playsound(int chan, int s, int override)
|
static void playsound(int chan, int s, int override)
|
||||||
|
|
@ -12766,6 +12842,7 @@ static void cleanup(void)
|
||||||
free_surface( &img_italic );
|
free_surface( &img_italic );
|
||||||
|
|
||||||
free_surface( &img_sparkles );
|
free_surface( &img_sparkles );
|
||||||
|
free_surface( &img_sparkles_color );
|
||||||
free_surface( &img_grass );
|
free_surface( &img_grass );
|
||||||
|
|
||||||
free_surface_array( undo_bufs, NUM_UNDO_BUFS );
|
free_surface_array( undo_bufs, NUM_UNDO_BUFS );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue