Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Cleaned up 03 events

  • Loading branch information...
commit c95333374df5bfe47ca8c680933095120573ae4d 1 parent 79a54f9
Kartik Thakore kthakore authored
118 dist/SDL_Manual.html
@@ -347,6 +347,19 @@
347 347
348 348 <pre><code> my $color = [255, 255, 255, 255];</code></pre>
349 349
  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 +
350 363 <p>You may also represent a color as hexadecimal values, where the values
351 364 of the numbers range from 0-255 for 32 bit depth in RGBA format:</p>
352 365
@@ -593,53 +606,12 @@
593 606 <pre><code> for (0 .. 500) {
594 607 my $y = 425 - rand( 50);
595 608 $flower-&gt;draw_xy( $app, rand(500) - 20, $y );
596   - }
597   -
598   - $app-&gt;update();
599   -
600   - sleep(1);</code></pre>
  609 + }</code></pre>
601 610
602 611 <p>... to make an entire field of flowers.</p>
603 612
604 613 <p>Probably don't need this.</p>
605 614
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   -
643 615 <h1>Handling Events</h1>
644 616
645 617 <p></p>
@@ -682,12 +654,10 @@
682 654
683 655 sub do_key { $quit = 1 }</code></pre>
684 656
685   -<p>Add other types of events.</p>
686   -
687   -<p> </p>
  657 +<p> </p>
688 658
689 659 <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
691 661 separates the event of pressing a key from the event of releasing a key,
692 662 which allows you to identify combinations of keypresses, such as Ctrl + P
693 663 to print.). The SDL library defines several types of events, and SDL_perl
@@ -703,6 +673,60 @@
703 673 handle events. Processing events is a matter of setting up the appropriate
704 674 callbacks and letting SDL do the heavy work.</p>
705 675
  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 +
706 730 <h2>Quitting with Grace</h2>
707 731
708 732 <p>The example applications so far have not exited cleanly. Handling quit
@@ -893,7 +917,7 @@
893 917
894 918 <ul>
895 919
896   -<li>Around line 259:
  920 +<li>Around line 317:
897 921
898 922 <p>=end programlisting without matching =begin. (Stack: [empty])</p>
899 923
BIN  dist/SDL_Manual.pdf
Binary file not shown
59 src/03-events.pod
Source Rendered
@@ -44,12 +44,6 @@ remove events constantly:
44 44
45 45 =end programlisting
46 46
47   -=for editor
48   -
49   -Add other types of events.
50   -
51   -=end for
52   -
53 47 X<C<SDL_ACTIVEEVENT>>
54 48 X<C<SDL_KEYDOWN>>
55 49 X<C<SDL_KEYUP>>
@@ -66,10 +60,9 @@ X<C<SDL_SYSWMEVENT>>
66 60 X<C<SDL_VIDEORESIZE>>
67 61 X<C<SDL_VIDEOEXPOSE>>
68 62 X<C<SDL_USEREVENT>>
69   -X<C<SDL_NUMEVENTS>>
70 63
71 64 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
73 66 pressing a key from the event of releasing a key, which allows you to identify
74 67 combinations of keypresses, such as Ctrl + P to print.>. The SDL library
75 68 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
83 76 callbacks with which to handle events. Processing events is a matter of setting
84 77 up the appropriate callbacks and letting SDL do the heavy work.
85 78
  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 +
86 129 =head1 Quitting with Grace
87 130
88 131 The example applications so far have not exited cleanly. Handling quit events

0 comments on commit c953333

Please sign in to comment.
Something went wrong with that request. Please try again.