Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleaned up 03 events

  • Loading branch information...
commit c95333374df5bfe47ca8c680933095120573ae4d 1 parent 79a54f9
@kthakore kthakore authored
View
118 dist/SDL_Manual.html
@@ -347,6 +347,19 @@
<pre><code> my $color = [255, 255, 255, 255];</code></pre>
+<p>The magnitude of each color value determines how much of that color
+component will be mixed into the resulting color. A 0 value specifies that
+none of the color channel should be used while 255 specifies a maximum
+intensity for a particular channel. The first value corresponds with the
+Red channel, so a higher number there means more red will be mixed into the
+resulting color. It is a common practice to achieve a grayscale of varying
+intensity by specifying the same value for each of the Red, Green, and Blue
+color channels. The fourth and final value designates the transparency (or
+Alpha channel) where a 0 value makes the resulting color fully transparent
+and 255 makes it entirely opaque. A transparency value somewhere in between
+will allow underlying colors to be blended with the specified RGB values
+into the final color output.</p>
+
<p>You may also represent a color as hexadecimal values, where the values
of the numbers range from 0-255 for 32 bit depth in RGBA format:</p>
@@ -593,53 +606,12 @@
<pre><code> for (0 .. 500) {
my $y = 425 - rand( 50);
$flower-&gt;draw_xy( $app, rand(500) - 20, $y );
- }
-
- $app-&gt;update();
-
- sleep(1);</code></pre>
+ }</code></pre>
<p>... to make an entire field of flowers.</p>
<p>Probably don't need this.</p>
-<h2>Program</h2>
-
-<p>The final program looks like this:</p>
-
-<pre><code> use SDL;
- use SDLx::App;
- use SDLx::Sprite;
-
- my $app = SDLx::App-&gt;new(
- w =&gt; 500,
- h =&gt; 500,
- d =&gt; 32,
- title =&gt; &#39;Pretty Flowers&#39;
- );
-
- # Draw Code Starts here
- my $flower = SDLx::Sprite-&gt;new( width =&gt; 50, height =&gt; 100 );
-
- $flower-&gt;surface-&gt;draw_rect( [ 0, 0, 50, 100 ], [ 0, 0, 0, 0 ] );
- $flower-&gt;surface-&gt;draw_rect( [ 23, 30, 4, 100 ], [ 0, 255, 0, 255 ] );
- $flower-&gt;surface-&gt;draw_circle_filled( [ 25, 25 ], 10, [ 150, 0, 0, 255 ] );
- $flower-&gt;surface-&gt;draw_circle( [ 25, 25 ], 10, [ 255, 0, 0, 255 ] );
- $flower-&gt;alpha_key(0);
-
- $app-&gt;draw_rect( [ 0, 0, 500, 500 ], [ 20, 50, 170, 255 ] );
- $app-&gt;draw_rect( [ 0, 400, 500, 100 ], [ 50, 170, 20, 100 ] );
-
- for(0..500){
- my $y = 425 - rand( 50);
- $flower-&gt;draw_xy( $app, rand(500) - 20, $y );
- }
- #Draw Code Ends Here
-
- $app-&gt;update();
-
- sleep(2);</code></pre>
-
<h1>Handling Events</h1>
<p></p>
@@ -682,12 +654,10 @@
sub do_key { $quit = 1 }</code></pre>
-<p>Add other types of events.</p>
-
-<p> </p>
+<p> </p>
<p>Every event has an associated type which represents the category of the
-event. The previous example looks for a keypress event (footnote: SDL
+event. The previous example looks for a keypress event (footnote: SDL
separates the event of pressing a key from the event of releasing a key,
which allows you to identify combinations of keypresses, such as Ctrl + P
to print.). The SDL library defines several types of events, and SDL_perl
@@ -703,6 +673,60 @@
handle events. Processing events is a matter of setting up the appropriate
callbacks and letting SDL do the heavy work.</p>
+<blockquote>
+
+<p><b>SDL Events Types</b></p>
+
+<p>Additional Event types that can be captured by SDL are:</p>
+
+<ul>
+
+<li>Keyboard
+
+<p><code>SDL_KEYDOWN</code> <code>SDL_KEYUP</code> - Keyboard button
+pressed</p>
+
+<li>Mouse
+
+<p><code>SDL_MOUSEMOTION</code> - Mouse motion occured</p>
+
+<p><code>SDL_MOUSEBUTTONDOWN</code> <code>SDL_MOUSEBUTTONUP</code> - Mouse
+button pressed</p>
+
+<li>Joystick
+
+<p><code>SDL_JOYAXISMOTION</code> - Joystick axis motion</p>
+
+<p><code>SDL_JOYBALLMOTION</code> - Joystick trackball motion</p>
+
+<p><code>SDL_JOYHATMOTION</code> - Joystick hat position change</p>
+
+<p><code>SDL_JOYBUTTONDOWN</code> <code>SDL_JOYBUTTONUP</code> - Joystick
+button pressed</p>
+
+<li>Window \& System
+
+<p><code>SDL_ACTIVEEVENT</code> - Application visibility</p>
+
+<p><code>SDL_VIDEORESIZE</code> - Window resized</p>
+
+<p><code>SDL_VIDEOEXPOSE</code> - Window exposed</p>
+
+<p><code>SDL_QUIT</code> - Quit requested</p>
+
+<p><code>SDL_USEREVENT</code> - A user-defined event type</p>
+
+<p><code>SDL_SYSWMEVENT</code> - Platform-dependent window manager
+event</p>
+
+</ul>
+
+<p>For more information look at:</p>
+
+<pre><code> perldoc SDL::Event </code></pre>
+
+</blockquote>
+
<h2>Quitting with Grace</h2>
<p>The example applications so far have not exited cleanly. Handling quit
@@ -893,7 +917,7 @@
<ul>
-<li>Around line 259:
+<li>Around line 317:
<p>=end programlisting without matching =begin. (Stack: [empty])</p>
View
BIN  dist/SDL_Manual.pdf
Binary file not shown
View
59 src/03-events.pod
@@ -44,12 +44,6 @@ remove events constantly:
=end programlisting
-=for editor
-
-Add other types of events.
-
-=end for
-
X<C<SDL_ACTIVEEVENT>>
X<C<SDL_KEYDOWN>>
X<C<SDL_KEYUP>>
@@ -66,10 +60,9 @@ X<C<SDL_SYSWMEVENT>>
X<C<SDL_VIDEORESIZE>>
X<C<SDL_VIDEOEXPOSE>>
X<C<SDL_USEREVENT>>
-X<C<SDL_NUMEVENTS>>
Every event has an associated type which represents the category of the event.
-The previous example looks for a keypress eventN<SDL separates the event of
+The previous example looks for a keypress event N<SDL separates the event of
pressing a key from the event of releasing a key, which allows you to identify
combinations of keypresses, such as Ctrl + P to print.>. The SDL library
defines several types of events, and SDL_perl makes them available as constants
@@ -83,6 +76,56 @@ The C<SDLx::Controller> available from the C<SDLx::App> offers the use of event
callbacks with which to handle events. Processing events is a matter of setting
up the appropriate callbacks and letting SDL do the heavy work.
+=for sidebar
+
+B<SDL Events Types>
+
+Additional Event types that can be captured by SDL are:
+
+=over
+
+=item Keyboard
+
+C<SDL_KEYDOWN> C<SDL_KEYUP> - Keyboard button pressed
+
+=item Mouse
+
+C<SDL_MOUSEMOTION> - Mouse motion occured
+
+C<SDL_MOUSEBUTTONDOWN> C<SDL_MOUSEBUTTONUP> - Mouse button pressed
+
+=item Joystick
+
+C<SDL_JOYAXISMOTION> - Joystick axis motion
+
+C<SDL_JOYBALLMOTION> - Joystick trackball motion
+
+C<SDL_JOYHATMOTION> - Joystick hat position change
+
+C<SDL_JOYBUTTONDOWN> C<SDL_JOYBUTTONUP> - Joystick button pressed
+
+=item Window & System
+
+C<SDL_ACTIVEEVENT> - Application visibility
+
+C<SDL_VIDEORESIZE> - Window resized
+
+C<SDL_VIDEOEXPOSE> - Window exposed
+
+C<SDL_QUIT> - Quit requested
+
+C<SDL_USEREVENT> - A user-defined event type
+
+C<SDL_SYSWMEVENT> - Platform-dependent window manager event
+
+=back
+
+For more information look at:
+
+ perldoc SDL::Event
+
+=end
+
=head1 Quitting with Grace
The example applications so far have not exited cleanly. Handling quit events
Please sign in to comment.
Something went wrong with that request. Please try again.