update
[sdlgit/SDL-Site.git] / pages / SDL-Tutorial-Animation.html-inc
index 9971729..6f0e579 100644 (file)
@@ -2,12 +2,8 @@
 <!-- INDEX START -->
 <h3 id="TOP">Index</h3>
 
-<ul><li><a href="#NAME">NAME</a>
-<ul><li><a href="#CATEGORY">CATEGORY</a></li>
-</ul>
-</li>
-<li><a href="#SYNOPSIS">SYNOPSIS</a></li>
-<li><a href="#ANIMATING_A_RECTANGLE">ANIMATING A RECTANGLE</a>
+<ul>
+<li>
 <ul><li><a href="#Redrawing_the_Screen">Redrawing the Screen</a></li>
 <li><a href="#Undrawing_the_Updated_Rectangle">Undrawing the Updated Rectangle</a></li>
 </ul>
 </ul><hr />
 <!-- INDEX END --><a href="assets/Animation.jpg" target="_blank"><img src="assets/Animation.jpg" style="height: 160px" alt="Animation.jpg"/></a><hr />
 
-<h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
-<div id="NAME_CONTENT">
-<p>SDL::Tutorial::Animation</p>
-
-</div>
-<h2 id="CATEGORY">CATEGORY</h2>
-<div id="CATEGORY_CONTENT">
-<p>Tutorials</p>
-
-</div>
-<h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
-<div id="SYNOPSIS_CONTENT">
-<pre>  # to read this tutorial
-       $ perldoc SDL::Tutorial::Animation
-
-       # to create a demo animation program based on this tutorial
-       $ perl -MSDL::Tutorial::Animation=sdl_anim.pl -e 1
-
-</pre>
-
-</div>
-<h1 id="ANIMATING_A_RECTANGLE">ANIMATING A RECTANGLE</h1><p><a href="#TOP" class="toplink">Top</a></p>
-<div id="ANIMATING_A_RECTANGLE_CONTENT">
-<p>Now that you can display a rectangle on the screen, the next step is to animate
-that rectangle.  As with movies, there's no actual motion.  Computer animations are just very very fast slideshows.  The hard work is creating nearly identical images in every slide (or frame, in graphics terms).</p>
-<p>Okay, it's not that difficult.</p>
-<p>There is one small difficulty to address, however.  Once you blit one surface
-onto another, the destination is changed permanently.  There's no concept of
-layers here unless you write it yourself.  If you fail to take this into
-account (and just about everyone does at first), you'll end up with blurry
-graphics moving around on the screen.</p>
-<p>There are two approaches to solve this problem, redrawing the screen on every
-frame and saving and restoring the background for every object drawn.</p>
-
-</div>
 <h2 id="Redrawing_the_Screen">Redrawing the Screen</h2>
 <div id="Redrawing_the_Screen_CONTENT">
 <p>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 <a href="http://search.cpan.org/perldoc?SDLx::App">SDLx::App</a> object <code>$app</code>, a <a href="SDL-Rect.html">SDL::Rect</a> <code>$rect</code>, and
 a <a href="SDL-Color.html">SDL::Color</a> <code>$color</code>, you only have to create a new SDL::Rect <code>$bg</code>,
-representing the whole of the background surface and a new SDL::Color
-<code>$bg_color</code>, representing the background color.  You can write a
-<code>draw_frame()</code> function as follows:</p>
+representing the whole of the background surface and a new mapped color 
+<code>$bg_color</code>, representing the background color.  The colors need to be mapped 
+to the format of the current display. This is done by <a href="/SDL-Video.html#map_RGB">SDL::Video::map_RGB</a>.</p>
+<p>&nbsp;</p>
+<p>my $color = SDL::Video::map_RGB (
+        $app-&gt;format,
+        $rect_r,
+        $rect_g,
+        $rect_b,
+);</p>
+<p>my $bg_color = SDL::Video::map_RGB (
+        $app-&gt;format,
+        $bg_r,
+        $bg_g,
+        $bg_b,
+);</p>
+<p>&nbsp;</p>
+
+
+
+
+
+
+
+<p>You can write a <code>draw_frame()</code> function as follows:</p>
 <p>&nbsp;</p>
 <pre>  sub draw_frame
        {