X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDL-Tutorial-Animation.html-inc;h=df5b3fb1dc91da7a8b268cdae63f16dce189ca7b;hb=0b221bb4fce84647a6cb9d7343de7330fb561c71;hp=6c06b63f3ee77486b6b75ad2855c7b95d54b187f;hpb=60f74f6f8f641636a03bd789ede09bebe208108b;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDL-Tutorial-Animation.html-inc b/pages/SDL-Tutorial-Animation.html-inc index 6c06b63..df5b3fb 100644 --- a/pages/SDL-Tutorial-Animation.html-inc +++ b/pages/SDL-Tutorial-Animation.html-inc @@ -59,19 +59,41 @@ frame and saving and restoring the background for every object drawn.

Since you have to draw the screen in the right order once to start with it's pretty easy to make this into a loop and redraw things in the right order for -every frame. Given a SDL::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:

+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 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
 	{
 		my ($app, %args) = @_;
 
-		$app->fill( $args{ bg }, $args{ bg_color } );
-		$app->fill( $args{rect}, $args{rect_color} );
-		$app->update( $args{bg} );
+		SDL::Video::fill_rect($app,  $args{bg},   $args{bg_color}   );
+		SDL::Video::fill_rect($app, $args{rect}, $args{rect_color} );
+		SDL::Video::update_rects($app, $args{bg} );
 	}
 
 
@@ -118,9 +140,10 @@ figure out the rectangle of the correct size to update(). No thank { my ($app, %args) = @_; - $app->fill( $args{old_rect}, $args{bg_color} ); - $app->fill( $args{rect], $args{rect_color} ); - $app->update( $args{old_rect}, $args{rect} ); + SDL::Video::fill_rect($app, $args{old_rect}, $args{bg_color} ); + SDL::Video::fill_rect($app, $args{rect}, $args{rect_color} ); + SDL::Video::update_rects($app, $args{old_rect} ); + SDL::Video::update_rects($app, $args{rect} ); } @@ -155,11 +178,11 @@ them soon.

SEE ALSO

Top

-
SDL::Tutorial::Drawing
+
SDL::Tutorial::Drawing

basic drawing with SDL Perl

-
SDL::Tutorial::Images
+
SDL::Tutorial::Images

animating images

@@ -169,7 +192,8 @@ them soon.

AUTHOR

Top

chromatic, <chromatic@wgz.org>

-

Written for and maintained by the Perl SDL project, http://sdl.perl.org/.

+

Written for and maintained by the Perl SDL project, http://sdl.perl.org/. +See AUTHORS in SDL.

BUGS

Top