Skip to content

Commit c953333

Browse files
committed
Cleaned up 03 events
1 parent 79a54f9 commit c953333

File tree

3 files changed

+122
-55
lines changed

3 files changed

+122
-55
lines changed

dist/SDL_Manual.html

+71-47
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,19 @@ <h4>Color</h4>
347347

348348
<pre><code> my $color = [255, 255, 255, 255];</code></pre>
349349

350+
<p>The magnitude of each color value determines how much of that color
351+
component will be mixed into the resulting color. A 0 value specifies that
352+
none of the color channel should be used while 255 specifies a maximum
353+
intensity for a particular channel. The first value corresponds with the
354+
Red channel, so a higher number there means more red will be mixed into the
355+
resulting color. It is a common practice to achieve a grayscale of varying
356+
intensity by specifying the same value for each of the Red, Green, and Blue
357+
color channels. The fourth and final value designates the transparency (or
358+
Alpha channel) where a 0 value makes the resulting color fully transparent
359+
and 255 makes it entirely opaque. A transparency value somewhere in between
360+
will allow underlying colors to be blended with the specified RGB values
361+
into the final color output.</p>
362+
350363
<p>You may also represent a color as hexadecimal values, where the values
351364
of the numbers range from 0-255 for 32 bit depth in RGBA format:</p>
352365

@@ -593,53 +606,12 @@ <h2>Lots of Flowers but One Seed</h2>
593606
<pre><code> for (0 .. 500) {
594607
my $y = 425 - rand( 50);
595608
$flower-&gt;draw_xy( $app, rand(500) - 20, $y );
596-
}
597-
598-
$app-&gt;update();
599-
600-
sleep(1);</code></pre>
609+
}</code></pre>
601610

602611
<p>... to make an entire field of flowers.</p>
603612

604613
<p>Probably don't need this.</p>
605614

606-
<h2>Program</h2>
607-
608-
<p>The final program looks like this:</p>
609-
610-
<pre><code> use SDL;
611-
use SDLx::App;
612-
use SDLx::Sprite;
613-
614-
my $app = SDLx::App-&gt;new(
615-
w =&gt; 500,
616-
h =&gt; 500,
617-
d =&gt; 32,
618-
title =&gt; &#39;Pretty Flowers&#39;
619-
);
620-
621-
# Draw Code Starts here
622-
my $flower = SDLx::Sprite-&gt;new( width =&gt; 50, height =&gt; 100 );
623-
624-
$flower-&gt;surface-&gt;draw_rect( [ 0, 0, 50, 100 ], [ 0, 0, 0, 0 ] );
625-
$flower-&gt;surface-&gt;draw_rect( [ 23, 30, 4, 100 ], [ 0, 255, 0, 255 ] );
626-
$flower-&gt;surface-&gt;draw_circle_filled( [ 25, 25 ], 10, [ 150, 0, 0, 255 ] );
627-
$flower-&gt;surface-&gt;draw_circle( [ 25, 25 ], 10, [ 255, 0, 0, 255 ] );
628-
$flower-&gt;alpha_key(0);
629-
630-
$app-&gt;draw_rect( [ 0, 0, 500, 500 ], [ 20, 50, 170, 255 ] );
631-
$app-&gt;draw_rect( [ 0, 400, 500, 100 ], [ 50, 170, 20, 100 ] );
632-
633-
for(0..500){
634-
my $y = 425 - rand( 50);
635-
$flower-&gt;draw_xy( $app, rand(500) - 20, $y );
636-
}
637-
#Draw Code Ends Here
638-
639-
$app-&gt;update();
640-
641-
sleep(2);</code></pre>
642-
643615
<h1>Handling Events</h1>
644616

645617
<p></p>
@@ -682,12 +654,10 @@ <h1>Handling Events</h1>
682654

683655
sub do_key { $quit = 1 }</code></pre>
684656

685-
<p>Add other types of events.</p>
686-
687-
<p> </p>
657+
<p> </p>
688658

689659
<p>Every event has an associated type which represents the category of the
690-
event. The previous example looks for a keypress event (footnote: SDL
660+
event. The previous example looks for a keypress event (footnote: SDL
691661
separates the event of pressing a key from the event of releasing a key,
692662
which allows you to identify combinations of keypresses, such as Ctrl + P
693663
to print.). The SDL library defines several types of events, and SDL_perl
@@ -703,6 +673,60 @@ <h1>Handling Events</h1>
703673
handle events. Processing events is a matter of setting up the appropriate
704674
callbacks and letting SDL do the heavy work.</p>
705675

676+
<blockquote>
677+
678+
<p><b>SDL Events Types</b></p>
679+
680+
<p>Additional Event types that can be captured by SDL are:</p>
681+
682+
<ul>
683+
684+
<li>Keyboard
685+
686+
<p><code>SDL_KEYDOWN</code> <code>SDL_KEYUP</code> - Keyboard button
687+
pressed</p>
688+
689+
<li>Mouse
690+
691+
<p><code>SDL_MOUSEMOTION</code> - Mouse motion occured</p>
692+
693+
<p><code>SDL_MOUSEBUTTONDOWN</code> <code>SDL_MOUSEBUTTONUP</code> - Mouse
694+
button pressed</p>
695+
696+
<li>Joystick
697+
698+
<p><code>SDL_JOYAXISMOTION</code> - Joystick axis motion</p>
699+
700+
<p><code>SDL_JOYBALLMOTION</code> - Joystick trackball motion</p>
701+
702+
<p><code>SDL_JOYHATMOTION</code> - Joystick hat position change</p>
703+
704+
<p><code>SDL_JOYBUTTONDOWN</code> <code>SDL_JOYBUTTONUP</code> - Joystick
705+
button pressed</p>
706+
707+
<li>Window \& System
708+
709+
<p><code>SDL_ACTIVEEVENT</code> - Application visibility</p>
710+
711+
<p><code>SDL_VIDEORESIZE</code> - Window resized</p>
712+
713+
<p><code>SDL_VIDEOEXPOSE</code> - Window exposed</p>
714+
715+
<p><code>SDL_QUIT</code> - Quit requested</p>
716+
717+
<p><code>SDL_USEREVENT</code> - A user-defined event type</p>
718+
719+
<p><code>SDL_SYSWMEVENT</code> - Platform-dependent window manager
720+
event</p>
721+
722+
</ul>
723+
724+
<p>For more information look at:</p>
725+
726+
<pre><code> perldoc SDL::Event </code></pre>
727+
728+
</blockquote>
729+
706730
<h2>Quitting with Grace</h2>
707731

708732
<p>The example applications so far have not exited cleanly. Handling quit
@@ -893,7 +917,7 @@ <h2>POD ERRORS</h2>
893917

894918
<ul>
895919

896-
<li>Around line 259:
920+
<li>Around line 317:
897921

898922
<p>=end programlisting without matching =begin. (Stack: [empty])</p>
899923

dist/SDL_Manual.pdf

6.09 KB
Binary file not shown.

src/03-events.pod

+51-8
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ remove events constantly:
4444

4545
=end programlisting
4646

47-
=for editor
48-
49-
Add other types of events.
50-
51-
=end for
52-
5347
X<C<SDL_ACTIVEEVENT>>
5448
X<C<SDL_KEYDOWN>>
5549
X<C<SDL_KEYUP>>
@@ -66,10 +60,9 @@ X<C<SDL_SYSWMEVENT>>
6660
X<C<SDL_VIDEORESIZE>>
6761
X<C<SDL_VIDEOEXPOSE>>
6862
X<C<SDL_USEREVENT>>
69-
X<C<SDL_NUMEVENTS>>
7063

7164
Every event has an associated type which represents the category of the event.
72-
The previous example looks for a keypress eventN<SDL separates the event of
65+
The previous example looks for a keypress event N<SDL separates the event of
7366
pressing a key from the event of releasing a key, which allows you to identify
7467
combinations of keypresses, such as Ctrl + P to print.>. The SDL library
7568
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
8376
callbacks with which to handle events. Processing events is a matter of setting
8477
up the appropriate callbacks and letting SDL do the heavy work.
8578

79+
=for sidebar
80+
81+
B<SDL Events Types>
82+
83+
Additional Event types that can be captured by SDL are:
84+
85+
=over
86+
87+
=item Keyboard
88+
89+
C<SDL_KEYDOWN> C<SDL_KEYUP> - Keyboard button pressed
90+
91+
=item Mouse
92+
93+
C<SDL_MOUSEMOTION> - Mouse motion occured
94+
95+
C<SDL_MOUSEBUTTONDOWN> C<SDL_MOUSEBUTTONUP> - Mouse button pressed
96+
97+
=item Joystick
98+
99+
C<SDL_JOYAXISMOTION> - Joystick axis motion
100+
101+
C<SDL_JOYBALLMOTION> - Joystick trackball motion
102+
103+
C<SDL_JOYHATMOTION> - Joystick hat position change
104+
105+
C<SDL_JOYBUTTONDOWN> C<SDL_JOYBUTTONUP> - Joystick button pressed
106+
107+
=item Window & System
108+
109+
C<SDL_ACTIVEEVENT> - Application visibility
110+
111+
C<SDL_VIDEORESIZE> - Window resized
112+
113+
C<SDL_VIDEOEXPOSE> - Window exposed
114+
115+
C<SDL_QUIT> - Quit requested
116+
117+
C<SDL_USEREVENT> - A user-defined event type
118+
119+
C<SDL_SYSWMEVENT> - Platform-dependent window manager event
120+
121+
=back
122+
123+
For more information look at:
124+
125+
perldoc SDL::Event
126+
127+
=end
128+
86129
=head1 Quitting with Grace
87130

88131
The example applications so far have not exited cleanly. Handling quit events

0 commit comments

Comments
 (0)