X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDL-Tutorial-Animation.html-inc;h=66647e94ea716f8ddfd59aea6956850adf52b5bb;hb=4e2d4d920f2a28412875f637b69407dc5c2ca044;hp=9971729a3da0037ee48720ff1aa6baf350bfc2fb;hpb=ca0a3441dd72000cbbbb4be484b18d0d305fdb29;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDL-Tutorial-Animation.html-inc b/pages/SDL-Tutorial-Animation.html-inc index 9971729..66647e9 100644 --- a/pages/SDL-Tutorial-Animation.html-inc +++ b/pages/SDL-Tutorial-Animation.html-inc @@ -61,9 +61,31 @@ frame and saving and restoring the background for every object drawn.

pretty easy to make this into a loop and redraw things in the right order for every frame. Given a SDLx::App object $app, a SDL::Rect $rect, and a SDL::Color $color, you only have to create a new SDL::Rect $bg, -representing the whole of the background surface and a new SDL::Color -$bg_color, representing the background color. You can write a -draw_frame() function as follows:

+representing the whole of the background surface and a new mapped color +$bg_color, representing the background color. The colors need to be mapped +to the format of the current display. This is done by SDL::Video::map_RGB.

+

 

+

my $color = SDL::Video::map_RGB ( + $app->format, + $rect_r, + $rect_g, + $rect_b, +);

+

my $bg_color = SDL::Video::map_RGB ( + $app->format, + $bg_r, + $bg_g, + $bg_b, +);

+

 

+ + + + + + + +

You can write a draw_frame() function as follows:

 

	sub draw_frame
 	{