From: Kartik Thakore SDL::Credits - Authors and contributors of the SDL Perl project Core SDL::Font - a SDL perl extension SDL::Font provides an interface to loading and using SFont style
-fonts with SDL::Surface objects. Use the SDL::Font given as first parameter. David J. Goehrig SDL::Palette - a perl extension SDL::Palette provides an interface to the SDL_Palette structures,
-and can be used to set the color values of an existing palette's indexes. Fetches and sets the blue component of the color at index. Fetches and sets the green component of the color at index. Fetches and sets the red component of the color at index. Fetches and sets the RGB, returns an SDL_Color *. Returns the size of the palette. David J. Goehrig Opens a joystick for use within SDL. The Returns the Returns the Return the number of axes available from a previously opened joystick. See SDL::Joystick::open Return the number of axes available from a previously opened joystick. See SDL::Joystick::newIndex
CATEGORY
+The SDL Perl 2010 Development Team
Index
-
-
-
-
-NAME
-SYNOPSIS
- $font = new Font "Font.png";
- $font->use();
-
-
-
-DESCRIPTION
-METHOD
-use(font)
-AUTHOR
-SEE ALSO
-Index
-
-
-
-
-NAME
-DESCRIPTION
-METHODS
-blue ( index, [value] )
-green ( index, [value] )
-red ( index, [value] )
-color ( index, [ r, g, b ] )
-size
-AUTHOR
-SEE ALSO
-open
- object SDL::Joystick::open( index );
+
new
+ object SDL::Joystick->new( index );
index
refers to the N'th joystick in the system.
@@ -95,7 +95,7 @@ A joystick must be opened before it can be used. int SDL::Joystick::index( object );
-index
of a given SDL_Joystick
structure. See SDL::Joystick::openindex
of a given SDL_Joystick
structure. See SDL::Joystick::newnum_axes
@@ -139,7 +139,7 @@ A joystick must be opened before it can be used.
int SDL::Joystick::num_axes( object );
-num_balls
@@ -147,7 +147,7 @@ A joystick must be opened before it can be used.
int SDL::Joystick::num_balls( object );-
Return the number of trackballs available from a previously opened joystick. See SDL::Joystick::open
+Return the number of trackballs available from a previously opened joystick. See SDL::Joystick::new
int SDL::Joystick::num_hats( object );-
Gets the number of joystick hats from a previously opened joystick. See SDL::Joystick::open
+Gets the number of joystick hats from a previously opened joystick. See SDL::Joystick::new
int SDL::Joystick::num_buttons( object );-
Gets the number of joystick buttons from a previously opened joystick. See SDL::Joystick::open
+Gets the number of joystick buttons from a previously opened joystick. See SDL::Joystick::new
get_axis
is a signed integer (-32768 to 32767
it may be necessary to impose certain tolerances on these values to account for jitter.
Note: Some joysticks use axes 2 and 3 for extra buttons.
Returns a 16-bit signed integer representing the current position of the axis.
-my $joystick = SDL::Joystick::open(0); +my $joystick = SDL::Joystick->new(0); my $x_move = SDL::Joystick::get_axis($joystick, 0); my $y_move = SDL::Joystick::get_axis($joystick, 1); @@ -210,7 +210,7 @@ it may be necessary to impose certain tolerances on these values to account for
SDL_HAT_LEFTDOWN
my $joystick = SDL::Joystick::open(0); +my $joystick = SDL::Joystick->new(0); my $position = SDL::Joystick::get_hat($joystick, 0); @@ -226,7 +226,7 @@ it may be necessary to impose certain tolerances on these values to account for
get_button
returns the current state of the given button on the given joystick.Returns 1 if the button is pressed. Otherwise, 0.
-my $joystick = SDL::Joystick::open(0); +my $joystick = SDL::Joystick->new(0); my $num_buttons = SDL::Joystick::num_buttons($joystick); @@ -250,7 +250,7 @@ it may be necessary to impose certain tolerances on these values to account forReturns 0 on success or -1 on failure
my $delta_x = 0; my $delta_y = 0; - my $joystick = SDL::Joystick::open(0); + my $joystick = SDL::Joystick->new(0); SDL::Joystick::update(); @@ -265,7 +265,7 @@ it may be necessary to impose certain tolerances on these values to account forvoid SDL::Joystick::close( object );-Closes a previously opened joystick. See SDL::Joystick::open
+Closes a previously opened joystick. See SDL::Joystick::new
SDL::Joystick::close($joystick) if SDL::Joystick::opened(0);diff --git a/pages/SDL-MPEG.html-inc b/pages/SDL-MPEG.html-inc index 0633e7c..1dff62b 100644 --- a/pages/SDL-MPEG.html-inc +++ b/pages/SDL-MPEG.html-inc @@ -3,6 +3,7 @@Index
SDL::MPEG - a SDL perl extension
+TODO
+ +$info = SDL::MPEG->new( -from => $mpeg ); diff --git a/pages/SDL-Music.html-inc b/pages/SDL-Music.html-inc deleted file mode 100644 index a913597..0000000 --- a/pages/SDL-Music.html-inc +++ /dev/null @@ -1,41 +0,0 @@ -- -\ No newline at end of file diff --git a/pages/SDL-OpenGL.html-inc b/pages/SDL-OpenGL.html-inc index 8114f34..1f46ad5 100644 --- a/pages/SDL-OpenGL.html-inc +++ b/pages/SDL-OpenGL.html-inc @@ -3,6 +3,7 @@Index
- -
- NAME
-- DESCRIPTION
-- AUTHOR
-- SEE ALSO -
-
- - -NAME
---SDL::Music - a perl extension
- -DESCRIPTION
---SDL::Music is used to load music files for use with SDL::Mixer. -To load a music file one simply creates a new object passing the filename -to the constructor:
-my $music = SDL::Music->new( 'my_song.ogg' ); - - - - -- -AUTHOR
---David J. Goehrig
- -SEE ALSO
-- - --Index
SDL::OpenGL - a perl extension
TODO
+ +SDL::OpenGL is a perl module which when used by your application diff --git a/pages/SDL-SFont.html-inc b/pages/SDL-SFont.html-inc deleted file mode 100644 index d808c88..0000000 --- a/pages/SDL-SFont.html-inc +++ /dev/null @@ -1,46 +0,0 @@ -
SDL::SFont - a perl extension
- -David J. Goehrig
- -SDL::SMPEG - a SDL perl extension
TODO
+ +$video = SDL::SMPEG->new( -name => 'pr0n.mpg' ); diff --git a/pages/SDL-Sound.html-inc b/pages/SDL-Sound.html-inc deleted file mode 100644 index 1886d9e..0000000 --- a/pages/SDL-Sound.html-inc +++ /dev/null @@ -1,58 +0,0 @@ -- -\ No newline at end of file diff --git a/pages/SDL-TTFont.html-inc b/pages/SDL-TTFont.html-inc deleted file mode 100644 index c09dc7b..0000000 --- a/pages/SDL-TTFont.html-inc +++ /dev/null @@ -1,200 +0,0 @@ -Index
- -
- NAME
-- DESCRIPTION
-- METHODS - -
-- AUTHOR
-- SEE ALSO -
-
- - - - - - - - - -NAME
---SDL::Sound - a perl extension
- -DESCRIPTION
---SDL::Sound is a module for loading WAV files for sound effects. -The file can be loaded by creating a new SDL::Sound object by -passing the filename to the constructor;
-my $sound = SDL::Sound->new( 'my_sfx.wav' ); - -- -METHODS
-- --volume ( value )
---Sets the volume of the sample.
- -AUTHOR
---David J. Goehrig
- -SEE ALSO
-- - --- -\ No newline at end of file diff --git a/pages/SDL-Timer.html-inc b/pages/SDL-Timer.html-inc deleted file mode 100644 index dcd6f98..0000000 --- a/pages/SDL-Timer.html-inc +++ /dev/null @@ -1,124 +0,0 @@ -Index
- -
- NAME
-- SYNOPSIS
-- DESCRIPTION
-- METHODS -
--
- new -
--
- -name
-- -n
-- -size
-- -s
-- -foreground
-- -fg
-- -background
-- -bg
-- -mode
-- -m
-- Text Modes
-- Text Style
-- Ascent/Descent values
-- height
-- width(@text)
-- print ($surface, $top, $left, @text)
-- AUTHOR
-- SEE ALSO -
-
- - -NAME
---SDL::TTFont - a SDL perl extension
- -SYNOPSIS
---$font = SDL::TTFont->new( -name => "Utopia.ttf", -size => 18 ); - -- -DESCRIPTION
---SDL::TTFont is a module for applying true type fonts to SDL::Surface.
- -METHODS
-- --new
---Instanciates a new font surface. It accepts the following parameters:
- --name
-- ---n
---The font filename (possibly with proper path) to be used. This options is mandatory.
- --size
-- ---s
---The font size (height, in pixels) to be used. This option is mandatory.
- --foreground
-- ---fg
---Foreground color for the font surface (i.e. the actual font color). It expects a -SDL::Color value. If omitted, black is used as font color.
- --background
-- ---bg
---Background color for the font surface (i.e. the font background color). It expects -a SDL::Color value. If omitted , white is used for the background.
- --mode
-- ---m
---Font mode. If omitted, SDL::TEXT_SHADED is used. Note that this class provides -human friendly accessors for setting different modes, so you should probably use -them instead. See below for further details.
- -Text Modes
---The SDL::TTFont accepts three different types (shaded, solid, blended) for -three different encodings (text, utf8, unicode).
-$font->text_shaded; # sets mode to SDL::TEXT_SHADED - $font->text_solid; # sets mode to SDL::TEXT_SOLID - $font->text_blended; # sets mode to SDL::TEXT_BLENDED - - $font->utf8_shaded; # sets mode to SDL::UTF8_SHADED - $font->utf8_solid; # sets mode to SDL::UTF8_SOLID - $font->utf8_blended; # sets mode to SDL::UTF8_BLENDED - - $font->unicode_shaded; # sets mode to SDL::UNICODE_SHADED - $font->unicode_solid; # sets mode to SDL::UNICODE_SOLID - $font->unicode_blended; # sets mode to SDL::UNICODE_BLENDED - -- -Text Style
---You may also smoothly change your font style by calling any of the following -methods:
-$font->normal; # resets font styling, making text "normal" - $font->bold; # sets bold style for font - $font->italic; # sets italic style for font - $font->underline; # sets underline style for font - - - - -- -Ascent/Descent values
---Ascent is the number of pixels from the font baseline to the top of the font, while -descent is the number of pixels from the font baseline to the bottom of the font.
-$font->ascent; # height in pixels of the font ascent - $font->descent; # height in pixels of the font descent - -- -height
---my $height = $font->height; - --Returns the height, in pixels, of the actual rendered text. This is the -average size for each glyph in the font.
- -width(@text)
---my $width = $font->width("Choose your destiny"); - --Returns the dimensions needed to render the text. This can be used to help -determine the positioning needed for text before it is rendered. It can also -be used for wordwrapping and other layout effects.
-Be aware that most fonts - notably, non-monospaced ("ms") ones - use kerning -which adjusts the widths for specific letter pairs. For example, the width -for "ae" will not always match the width for "a" + "e".
- -print ($surface, $top, $left, @text)
---Directly draws text to an existing surface. Receives the target SDL::Surface -object and the relative top (y) and left (x) coordinates to put the text in. -The last parameter may be a string or an array or strings with the text to be -written.
- - - - - -AUTHOR
---David J. Goehrig
- -SEE ALSO
---perl, SDL, SDL::Surface -
- -- -\ No newline at end of file diff --git a/pages/SDL-Tool-Font.html-inc b/pages/SDL-Tool-Font.html-inc deleted file mode 100644 index 0934d05..0000000 --- a/pages/SDL-Tool-Font.html-inc +++ /dev/null @@ -1,48 +0,0 @@ -Index
- -
- - -NAME
---SDL::Time - a SDL perl extension for managing timers.
- - - - - -SYNOPSIS
-- - - - - - - - - - - --METHODS
-- - - - - --get_ticks()
---Returns the number of milliseconds since SDL library initialization. This value wraps around if the program runs for more than 49.7 days
- - - - - -delay(ms)
---This function waits a specified number of milliseconds before returning. It waits at least the specified time, but possible longer due to OS scheduling. The delay granularity is at least 10 ms. Some platforms have shorter clock ticks but this is the most common. -SDL::delay doesn't returns anything.
- -add_timer(interval,callback,param)
---Adds a callback function to be run after the specified number of milliseconds has elapsed. -The callback function is passed the current timer interval and the user supplied parameter from the SDL::add_timer call and returns the next timer interval. -If the returned value from the callback is the same as the one passed in, the timer continues at the same rate. -If the returned value from the callback is 0, the timer is cancelled.
-Another way to cancel a currently-running timer is by calling SDL::remove_timer with the timer's ID (which was returned from SDL::add_timer).
-The timer callback function may run in a different thread than your main program, and so shouldn't call any functions from within itself. -However, you may always call SDL::push_event.
-SDL::add_timer returns the identifier value of the generated timer or undef on error.
-Note : If you use this function, you need to pass SDL_INIT_TIMER to SDL::init.
- -Parameters
---interval [in] The desired interval of the timer, in milliseconds. - The granularity of the timer is platform-dependent, but you should count on it being at least 10 ms as this is the most common number. - This means that if you request a 16 ms timer, your callback will run approximately 20 ms later on an unloaded system. - If you wanted to set a flag signaling a frame update at 30 frames per second (every 33 ms), you might set a timer for 30 ms (see example below). - - callback [in] The SDL timer callback function which is called when the specified interval elapses. - - param [in] The user parameter which is passed to the callback function - - - - -- -remove_timer( id )
---Removes a timer callback previously added with SDL::add_timer. -It returns 0 on succés or -1 on error.
- -set_timer( interval,callback )
---Set a callback to run after the specified number of milliseconds has elapsed. -The callback function is passed the current timer interval and returns the next timer interval. -If the returned value is the same as the one passed in, the periodic alarm continues, otherwise a new alarm is scheduled.
-To cancel a currently running timer, call SDL::set_timer(0, NULL);
-The timer callback function may run in a different thread than your main constant, and so shouldn't call any functions from within itself.
-The maximum resolution of this timer is 10 ms, which means that if you request a 16 ms timer, your callback will run approximately 20 ms later on an unloaded system. If you wanted to set a flag signaling a frame update at 30 frames per second (every 33 ms), you might set a timer for 30 ms (see example below).
-If you use this function, you need to pass SDL_INIT_TIMER to SDL::init(). -Note: This function is kept for compatibility but has been superseded by the new timer functions SDL::add_timer and SDL::remove_timer which support multiple timers.
- - - - - -- -\ No newline at end of file diff --git a/pages/SDL-Tool-Graphic.html-inc b/pages/SDL-Tool-Graphic.html-inc deleted file mode 100644 index 8f81125..0000000 --- a/pages/SDL-Tool-Graphic.html-inc +++ /dev/null @@ -1,75 +0,0 @@ -Index
- -
- NAME
-- DESCRIPTION
-- METHODS - -
-- AUTHOR
-- SEE ALSO -
-
- - -NAME
---SDL::Tool::Font - a perl extension
- -DESCRIPTION
---SDL::Tool::Font provides a unified interface for applying -True Type and SFont fonts to various surfaces.
- -METHODS
-- --print ( surface, x, y, text ... )
---- -
SDL::Tool::Font::print
print the given text on the supplied surface -with the upper left hand corner starting at the specified coordinates.AUTHOR
---David J. Goehrig
- -SEE ALSO
- -- -\ No newline at end of file diff --git a/pages/SDL-Tutorial-Images.html-inc b/pages/SDL-Tutorial-Images.html-inc deleted file mode 100644 index c639db8..0000000 --- a/pages/SDL-Tutorial-Images.html-inc +++ /dev/null @@ -1,232 +0,0 @@ -Index
- -
- NAME
-- DESCRIPTION
-- METHODS - -
-- AUTHOR
-- SEE ALSO -
-
- - - - - - - - - -NAME
---SDL::Tool::Graphic
- -DESCRIPTION
---SDL::Tool::Graphic is a module for zooming and rotating SDL::Surface objects.
- -METHODS
-- --zoom ( surface, xzoom, yzoom, smooth )
---- -
SDL::Tool::Graphic::zoom
scales a SDL::Surface along the two axis independently.rotoZoom ( surface, angle, zoom, smooth )
---- -
SDL::Tool::Graphic::rotoZoom
rotates and fixed axis zooms a SDL::Surface.grayScale ( surface )
---- -
SDL::Tool::Graphic::grayScale
rotates and fixed axis zooms a SDL::Surface.invertColor ( surface )
---- - - - - -
SDL::Tool::Graphic::invertColor
inverts the color of a <SDL::Surface>.AUTHOR
---Russell E. Valentine
- -SEE ALSO
-- - --- -\ No newline at end of file diff --git a/pages/SDL-Tutorial-Pong.html-inc b/pages/SDL-Tutorial-Pong.html-inc deleted file mode 100644 index 718320d..0000000 --- a/pages/SDL-Tutorial-Pong.html-inc +++ /dev/null @@ -1,178 +0,0 @@ -Index
- -
-
- -NAME
---SDL::Tutorial::Images
- -CATEGORY
---Tutorials
- -SYNOPSIS
---# to read this tutorial - $ perldoc SDL::Tutorial::Images - - # to create a demo animation program based on this tutorial - $ perl -MSDL::Tutorial::Images=sdl_images.pl -e 1 - -- -ANIMATING IMAGES
---Since you're already familiar with the concepts behind animation, it's time to -learn how to work with images. As usual, the important point is that computer animation is just simulating motion by painting several slightly different frames to the screen every second.
-There are two ways to vary an image on screen. One is to change its -coordinates so it's at a slightly different position. This is very easy to do; -it's just like animating a rectangle. The other way is to change the image -itself so it's slightly different. This is a little more difficult, as you'll -need to draw the alternate image beforehand somehow.
- -Loading Images
---As usual, start with an SDL::App object representing the image window. Then -preload the image file. This is easy; just pass the
-name
parameter to the -SDL::Surface constructor:-
use SDL::Surface; - - my $frame = SDL::Surface->new( -name => 'frame1.png' ); - ---
Note: you'll need to have compiled SDL Perl (and probably SDL) to support -JPEG and PNG files for this to work.
-That's it; now you have an SDL::Surface object containing the image. You can -use the
- -height()
,width()
, andbpp()
methods to retrieve its height, -width, and bits per pixel, if you need them.Displaying Images
---Drawing an image onto the screen requires blitting it from one surface to -another. (Remember, "blitting" means copying bits in memory.) The
-blit()
-method of SDL::Surface objects comes in handy. Its arguments are a little odd, -though. Assuming$app
is the SDL::App object, as usual:-
use SDL::Rect; - - my $frame_rect = SDL::Rect->new( - -height => $frame->height(), - -width => $frame->width(), - -x => 0, - -y => 0, - ); - - my $dest_rect = SDL::Rect->new( - -height => $frame->height(), - -width => $frame->width(), - -x => 0, - -y => 0, - ); - - $frame->blit( $frame_rect, $app, $dest_rect ); - $app->update( $dest_rect ); - ---
Here we have two SDL::Rect objects which represent rectangular regions of a -Surface.
-$frame_rect
represents the entire area of$frame
, while -$dest_rect
represents the area of the main window in which to blit the -frame. This may be clearer with more descriptive variable names:-
$source_surface->blit( - $area_of_source_to_blit, - $destination_surface, - $destination_area - ); - ---
As usual, call
-update()
on$app
to see the change.Requiring the source and destination Rect objects may seem tedious in this -simple example, but it's highly useful for copying only part of surface to part -of another. For example, animating this image is a matter of changing the
-x
-andy
coordinates of$dest_rect
:-
for my $x ( 1 .. 100 ) - { - $dest_rect->x( $x ); - $frame->blit( $frame_rect, $app, $dest_rect ); - $app->update( $dest_rect ); - } - ---
Of course, you'll have to redraw all or part of the screen to avoid artifacts, -as discussed in the previous tutorial.
- -Multi-Image Animation
---That covers moving a single image around the screen. What if you want -something more? For example, what if you want to animate a stick figure -walking?
-You'll need several frames, just as in a flip-book. Each frame should be slightly different than the one before it. It's probably handy to encapsulate all of this in a
-Walker
class:-
package Walker; - - use SDL::Surface; - - sub new - { - my ($class, @images) = @_; - my $self = [ map { SDL::Surface->new( -name => $_ ) } @images ]; - - bless $self, $class; - } - - sub next_frame - { - my $self = shift; - my $frame = shift @$self; - - push @$self, $frame; - return $frame; - } - ---
To use this class, instantiate an object:
--
my $walker = Walker->new( 'frame1.png', 'frame2.png', 'frame3.png' ); - ---
Then call
-next_frame()
within the loop:-
for my $x ( 1 .. 100 ) - { - my $frame = $walker->next_frame(); - - $dest_rect->x( $x ); - $frame->blit( $frame_rect, $app, $dest_rect ); - $app->update( $dest_rect ); - } - ---
Again, the rest of the frame drawing is missing from this example so as not to -distract from this technique. You'll probably want to abstract the undrawing -and redrawing into a separate subroutine so you don't have to worry about it -every time.
-It'd be easy to make
-next_frame()
much smarter, selecting an image -appropriate to the direction of travel, using a bored animation when the -character is no longer moving, or adding other characteristics to the -character. As you can see, the hard part of this technique is generating the -images beforehand. That can add up to a tremendous amount of art and that's -one reason for the popularity of 3D models... but that's another tutorial much -further down the road.More importantly, it's time to discuss how to make these animations run more -smoothly. More on that next time.
- -SEE ALSO
----
- -- SDL::Tutorial
-- -
-basic SDL tutorial
-- SDL::Tutorial::Animation
-- -
-non-image animation
-AUTHOR
---chromatic, <chromatic@wgz.org>
-Written for and maintained by the Perl SDL project, http://sdl.perl.org/.
- -BUGS
---No known bugs.
- -COPYRIGHT
---Copyright (c) 2004, chromatic. All rights reserved. This module is -distributed under the same terms as Perl itself, in the hope that it is useful -but certainly under no guarantee. -
- -- -\ No newline at end of file diff --git a/pages/SDL-Tutorial-Tetris.html-inc b/pages/SDL-Tutorial-Tetris.html-inc deleted file mode 100644 index 16d9466..0000000 --- a/pages/SDL-Tutorial-Tetris.html-inc +++ /dev/null @@ -1,71 +0,0 @@ -Index
- -
- NAME
-- PONG TUTORIAL -
--
- CATEGORY
-- Part 1: We start with a Rect
-- Part 0: "The Screen" - -
-- Part 1 (cont.) - Drawing our Rect on the screen
-- Part 2 - Our first event: tracking user movement - -
-- Part 3 - Enter "the Ball" - -
-- Part 4 - Collision Detection
-- Part 5 - Our hero's nemesis appears - -
-- Part 6 - Counting (and showing) the score -
-
- - -NAME
---SDL::Tutorial::Pong -- Get started pong
- -PONG TUTORIAL
---This tutorial is intended to help you build your very own version of the Pong game and/or variations of it, using SDL Perl.
-Just in case you live under a rock, Pong is one of the earliest arcade games, a true classic by Atari Inc. The game has two simple rectangles scrolling up and down trying to hit a (square) ball that bounces around, and could be thought of as a table tennis simulation.
- -CATEGORY
---Tutorials
- -Part 1: We start with a Rect
---In Pong, the player controls a rectangle that moves up and down, so creating the rectangle looks like a good place to start:
--
my $player = SDL::Game::Rect->new({ - -top => 10, - -left => 20, - -width => 6, - -height => 32, - }); - ---
That creates a new SDL::Game::Rect object, a rectangle, with the given width/height dimensions and in the given top/left position of the screen.
-Wait. Did I say... <screen>?
- -Part 0: "The Screen"
---In SDL Perl, creating a window screen is very easy and straightforward:
--
use SDL; - use SDL::App; - - my $app = SDL::App->new( - -title => 'Pong', # set window title - -width => 640, # window width - -height => 480, # window height - ); - ---
That's it. If you run this code, you'll see a window appear and disappear almost instantly. Why doesn't it stay up? Well, the code is processed linearly, like usual programs are, and with no hidden magic. So, you basically said "create a window" and then the program ended - destroying the window. In order to keep it up and running, listening for events, you need an event loop.
- -Creating an (empty) event loop
---An event loop is a simple infinite loop that captures events (like a key pressed or released from the keyboard, mouse movement, etc) and either does something about it or dispatches it to any object that might.
-For this simple game we don't need a very sofisticated event loop, so let's create a simple one.
--
event_loop() while 1; - ---
Yay, an infinite loop! Now we are free to define our very own event loop any way we want. Let's make it an empty sub for starters:
--
sub event_loop { - } - ---
Ok. If you run it, you'll see your
- -$app
window displayed until you force to shutdown the program by typingCtrl-C
or something. Other than that, our event loop doesn't do anything,Part 1 (cont.) - Drawing our Rect on the screen
---# TODO
- -Part 2 - Our first event: tracking user movement
---# TODO
-Now let's query some events!
-First, we need to use the SDL::Event module. Add this to the beginning of our code:
--
use SDL::Event; - my $event = SDL::Event->new; - --- - - - -
Now let's rewrite the
-event_loop
subroutine to take advantage of our event object. The new subroutine should look like this:-
sub event_loop { - # first we poll if an event occurred... - while ($event->poll) { - - # if there is an event, we check its type - my $type = $event->type - - # handle window closing - exit if $type == SDL_QUIT; - } - } - ---
#TODO
- -Hey, don't move away from the court! Our first collision detection.
-- --Part 3 - Enter "the Ball"
---#TODO
- -Some vetorial background
---#TODO
- -Part 4 - Collision Detection
---#TODO
- -Part 5 - Our hero's nemesis appears
---#TODO
- -(really) basic IA
---#TODO
- -Part 6 - Counting (and showing) the score
---#TODO -
- -- -\ No newline at end of file diff --git a/pages/SDL-old-cdrom.html-inc b/pages/SDL-old-cdrom.html-inc deleted file mode 100644 index 2298646..0000000 --- a/pages/SDL-old-cdrom.html-inc +++ /dev/null @@ -1,151 +0,0 @@ -Index
- -
- NAME -
--
- CATEGORY
-- The Overall view - -
-
- - -NAME
---SDL::Tutorial::Tetris -- Let's Make Tetris
- -CATEGORY
---Tutorials
- -The Overall view
---All games are a while loop. So we will have something like this.
- -The Game Loop
---package Tetris; - - sub run_game_fun_times - { - while(1) - { - #game logic here - } - } - --You need more code you say? Ok well, a game does two things more.
- -The Game Logic
----
-- Input Events
-- -
-A game essentially move objects (boxes, monsters so on) in time.
--
-
- -- Time
-- -
-In SDL time is measured in ticks.
-- User Input
-- Draw Everything
---Kartik -
- -- -\ No newline at end of file diff --git a/pages/Time.html-inc b/pages/Time.html-inc deleted file mode 100644 index dcd6f98..0000000 --- a/pages/Time.html-inc +++ /dev/null @@ -1,124 +0,0 @@ -Index
- -
- - -NAME
---SDL::Cdrom - a SDL perl extension for managing CD-ROM drives
- -SYNOPSIS
---use SDL::Cdrom; - $cdrom = SDL::Cdrom->new(0); - $cdrom->play(); - -- -EXPORTS
----
- - -- -
cd_num_drives
.DESCRIPTION
---Create a new SDL::Cdrom object. The passed $id is the number of the drive, -whereas 0 is the first drive etc.
-use SDL::Cdrom; - my $drive => SDL::Cdrom->new($id); - -- -METHODS
-- --cd_num_drives()
---Returns the number of CD-ROM drives present.
- -name(cd)
---Returns the system dependent name of the CD-ROM device. -It takes a SDL::Cdrom as first parameter.
- -status(cd)
---Return the status of the drive. -It takes a SDL::Cdrom as first parameter.
- -play(cd,start,length,fs,fl)
---Play a track from the SDL::Cdrom given as first parameter, second parameter is the frame to start, the third is the lenght to play. -It returns 1 on succés 0 on error.
- -pause(cd)
---Pause the playing of the SDL::Cdrom given as first parameter. -It returns 1 on succés 0 on error.
- -resume(cd)
---Resume the playing of the SDL::Cdrom given as first parameter. -It returns 1 on succés 0 on error.
- -stop(cd)
---Stop the playing of the SDL::Cdrom given as first parameter. -It returns 1 on succés 0 on error.
- -eject(cd)
---Eject the medium in the SDL::Cdrom given as first parameter. -It returns 1 on succés 0 on error.
- -id(cd)
---Return the ID of the drive given as first parameter.
- -num_tracks(cd)
---Return the number of tracks on the SDL::Cdrom given as first parameter.
- -track(cd,number)
---Returns the track description of the track given as second parameter. -the first parameter is a SDL:Cdrom.
- -current(cd)
---Return the current played track number given as first parameter.
- -current_frame(cd)
---Return the current frame given as first parameter.
- -AUTHORS
---David J. Goehrig -Documentation by Tels <http://bloodgate.com/>.
- -SEE ALSO
-- - --- -\ No newline at end of file diff --git a/pages/about.html-inc b/pages/about.html-inc deleted file mode 100644 index 56c9639..0000000 --- a/pages/about.html-inc +++ /dev/null @@ -1,95 +0,0 @@ -Index
- -
- - -NAME
---SDL::Time - a SDL perl extension for managing timers.
- - - - - -SYNOPSIS
-- - - - - - - - - - - --METHODS
-- - - - - --get_ticks()
---Returns the number of milliseconds since SDL library initialization. This value wraps around if the program runs for more than 49.7 days
- - - - - -delay(ms)
---This function waits a specified number of milliseconds before returning. It waits at least the specified time, but possible longer due to OS scheduling. The delay granularity is at least 10 ms. Some platforms have shorter clock ticks but this is the most common. -SDL::delay doesn't returns anything.
- -add_timer(interval,callback,param)
---Adds a callback function to be run after the specified number of milliseconds has elapsed. -The callback function is passed the current timer interval and the user supplied parameter from the SDL::add_timer call and returns the next timer interval. -If the returned value from the callback is the same as the one passed in, the timer continues at the same rate. -If the returned value from the callback is 0, the timer is cancelled.
-Another way to cancel a currently-running timer is by calling SDL::remove_timer with the timer's ID (which was returned from SDL::add_timer).
-The timer callback function may run in a different thread than your main program, and so shouldn't call any functions from within itself. -However, you may always call SDL::push_event.
-SDL::add_timer returns the identifier value of the generated timer or undef on error.
-Note : If you use this function, you need to pass SDL_INIT_TIMER to SDL::init.
- -Parameters
---interval [in] The desired interval of the timer, in milliseconds. - The granularity of the timer is platform-dependent, but you should count on it being at least 10 ms as this is the most common number. - This means that if you request a 16 ms timer, your callback will run approximately 20 ms later on an unloaded system. - If you wanted to set a flag signaling a frame update at 30 frames per second (every 33 ms), you might set a timer for 30 ms (see example below). - - callback [in] The SDL timer callback function which is called when the specified interval elapses. - - param [in] The user parameter which is passed to the callback function - - - - -- -remove_timer( id )
---Removes a timer callback previously added with SDL::add_timer. -It returns 0 on succés or -1 on error.
- -set_timer( interval,callback )
---Set a callback to run after the specified number of milliseconds has elapsed. -The callback function is passed the current timer interval and returns the next timer interval. -If the returned value is the same as the one passed in, the periodic alarm continues, otherwise a new alarm is scheduled.
-To cancel a currently running timer, call SDL::set_timer(0, NULL);
-The timer callback function may run in a different thread than your main constant, and so shouldn't call any functions from within itself.
-The maximum resolution of this timer is 10 ms, which means that if you request a 16 ms timer, your callback will run approximately 20 ms later on an unloaded system. If you wanted to set a flag signaling a frame update at 30 frames per second (every 33 ms), you might set a timer for 30 ms (see example below).
-If you use this function, you need to pass SDL_INIT_TIMER to SDL::init(). -Note: This function is kept for compatibility but has been superseded by the new timer functions SDL::add_timer and SDL::remove_timer which support multiple timers.
- - - - - -- -\ No newline at end of file diff --git a/pages/blog-0000.html-inc b/pages/blog-0000.html-inc index d4d9828..ccb4504 100644 --- a/pages/blog-0000.html-inc +++ b/pages/blog-0000.html-inc @@ -1,2 +1,2 @@Index
- -
- THE SECOND WAVE - -
-- COMRADES IN ARMS - -
-
- - -THE SECOND WAVE
-- --Teh Handy MAn Plumber ( kthakore )
---You may mistaken this guy for the project lead, but he just goes around duct taping stuff together. Sometimes it works some times it doesn't ...
- -Teh Web Guy ( FROGGS )
---He breaks things and does web stuff.
- -Frenching Monk ( magnet )
---Likes doing docs for some reason.
- -Bellowing Brazilian ( garu )
---Oddly enough he sells onions.
- -Tipsy Orange ( acme )
---He is tipsy and fast.
- -The artsy dadio ( ruoso )
---He is an artist and a hacker. What more do ya want?
- -COMRADES IN ARMS
-- --El 'Loco' Jefe ( David J Goehrig )
---SDL Perl has been around for a while and the crazy hacker to start this was David J Goehrig. So here is a picture of him with some lasers ...
- -Mysterious Ninja ( TELS )
---So surfing the mailing list of SDL Perl we found a pretty active SDL Perl developer till 2005. He goes by the name Tels. We would put his picture up but he is a ninja.
- -Evil French Genuis ( Guillaume Cottenceau )
---After using his evil frozen bubble game to take of the minds of the worlds leaders, he has mostly disappeared (most likely to come up with his next evil plan).
- -The Windower ( Wayne Keenan )
---The windower turns you blue. You don't know why.
- -mAd Yankee ( Chromatic)
---He is a yankee, but he likes parrots for some reason.
- -Evil Horde
---The horde is large, they have been identified on this super secret list.
- -+Articles
-Release SDL 2.4: Frozen-Bubble begins to go to CPAN
Tuesday, 06 April 2010
Tags: [Frozen Bubble] [Perl] [SDL]
SDL 2.4 is released!
After 8 months of work this picture begins to sum it up:
[more]A summer of possibilities (SDL_perl and GSOC 2010 )
Tuesday, 30 March 2010
Tags: [GSOC] [Perl] [SDL]
GSOC 2010
As many of the readers must know The Perl Foundation has been accepted for the GSOC 2010 program. There are several SDL_perl mentors involved in it too. Right now we are accepting student applications.
Process to Apply
[more]SDL Perl Showcase
Friday, 12 March 2010
Tags: [EyeCandy] [Perl] [SDL Perl] [Showcase]
SDL_Mixer and Effects
[more]Quick Game for Toronto Perl Mongers
Thursday, 11 February 2010
Tags: [Game] [SDL] [TPM]
Beep ... Boop
[more]SDL_perl 2.3_5 is out!
Monday, 01 February 2010
Tags: [Releases] [SDL]
We keep on rolling,
rolling,
waiting on the world to turn.
[more]Threaded XS callback finally gets solved.
Wednesday, 06 January 2010
Tags: [Perl] [SDL] [Updates] [XS]
Dragged down from the lofty isles,
into the guts and gore of the monster,
[more]SDL Alpha 2: A sneak preview
Sunday, 06 December 2009
Tags: [Perl] [Releases] [SDL]
Pretty or Ugly,
Code is Code
New or Old,
[more]Developer Release of SDL 2.3_1
Monday, 30 November 2009
Tags: [Perl] [Releases] [SDL]
The city of Rome was built,
with the first brick.
[more]SDL Perl Documentation: Reviewers need
Thursday, 26 November 2009
Tags: [Docs] [Perl] [SDL]
The written word,
survives;
[more]Migrating Sol's Tutorial of SDL to SDL_Perl
Sunday, 15 November 2009
Tags: [Example] [Perl] [SDL]
If I have seen further it is only by standing on the shoulders of giants. --Newton
[more]Once in a while .... (set_event_filter)
Friday, 13 November 2009
Tags: [Perl] [SDL] [XS]
Once in a while
Things just work!
[more]Hello Mouse? An Example of the New Event Code
Wednesday, 11 November 2009
Tags: [Perl] [SDL] [Sneak Preview]
Any code that is not marketed is dead code
--mst
[more]Development Update
Monday, 09 November 2009
Tags: [Perl] [SDL] [Updates]
Short and Sweet
Had an exam on the weekend so I am a bit late. Here is the progress so far.
[more]Development Update
Monday, 02 November 2009
Tags: [Perl] [SDL] [Updates]
A stoic stone will sit idle,
but will some effort,
[more]The Future and Beyond!
Saturday, 24 October 2009
Tags: [Design] [SDL] [Updates] [games]
I do not think about awesomeness...
I just am awesomeness
n.n
[more]The beginnings of modular design for SDL Perl
Sunday, 11 October 2009
Tags: [Design] [SDL] [Updates]
âDo or do not... there is no try.â
--yoda
The design before
[more]Why and How Frozen Bubble is going to CPAN
Friday, 02 October 2009
Tags: [Frozen Bubble] [Perl] [SDL]
A single drop,
causes the ocean to swell
[more]HackFest: Results
Monday, 28 September 2009
Tags: [HackFest] [Perl] [SDL]
The beautiful sunset,
is no match for,
the ugly sunrise
[more]Updates, Falling Block Game, and Hack Fest
Wednesday, 23 September 2009
Tags: [Docs] [Perl] [SDL]
Silent but active,
Small but deadly.
[more]Thanks nothingmuch, and updates
Friday, 18 September 2009
Tags: [Design] [Perl] [SDL] [Tutorial]
struggle,
live,
cease,
[more]Design of SDL::Rect
Saturday, 12 September 2009
Tags: [Design] [Perl] [SDL]
you say things,
I hear,
[more]Updates and Design Decisions
Wednesday, 09 September 2009
Tags: [Design] [Perl] [SDL] [Updates]
Storm clouds loom,
Thunder cracks,
[more]Why I will be sticking to CPAN
Sunday, 06 September 2009
Tags: [CPAN] [Perl] [SDL]
sculpted in clay, then fired to glass.
[more]Getting people to use SDL Perl: Docs, API, and Distribution
Friday, 07 May 2010
Tags: [API] [Design] [Docs] [Perl] [SDL]
The road so far
Things have been busy but fruitful. Our two core modules are getting to be a bit more stable. Alien::SDL 1.405 is behaving well. This foundational stability will start to show results in SDL too I believe. Most excitingly the main developer of frozen-bubble is reviewing our Games::FrozenBubble port to CPAN. All good and well, but to keep this project going we need to improve.
Getting people to use SDL Perl
After a long chat with a new SDL user on #sdl today, I realize we still have some way to go. Currently it seems we are lacking in a few areas. We can definitely use some feedback and help in these areas.
Tutorials/Documentation
We have more docs now on http://sdl.perl.org but they suck
What type of tutorials do you think will be good for beginners?
A project start to finish?
Individual tutorials for various topics?
What needs to go in SDL::CookBook?
API sweetness
SDL Perl depends on distinct C libraries
This makes naming conventions, data formats different the SDL:: namespaces
How do people design this stuff?
We are hackers and we just go do stuff but I think this needs some prior thought
Any takers?
Distribution
If SDL scripts can be packaged up simply for game developers to distribute their games it will be a big plus
One way is a Wx::Perl::Packer clone
Another is a CPAN/Steam clone that game devs can upload games too and people can point and click download games?
If anyone wants to help in these areas please talk to us on sdl-devel@perl.org.
[more]Games::FrozenBubble: It is a start!
Monday, 12 April 2010
Tags: [Frozen Bubble] [Perl] [SDL]
We released a playable (client) frozen bubble on CPAN . There is more work to be done but it is a great start! It currently works on Windows and Linux.
[more]Release SDL 2.4: Frozen-Bubble begins to go to CPAN
Tuesday, 06 April 2010
Tags: [Frozen Bubble] [Perl] [SDL]
SDL 2.4 is released!
After 8 months of work this picture begins to sum it up:
[more]A summer of possibilities (SDL_perl and GSOC 2010 )
Tuesday, 30 March 2010
Tags: [GSOC] [Perl] [SDL]
GSOC 2010
As many of the readers must know The Perl Foundation has been accepted for the GSOC 2010 program. There are several SDL_perl mentors involved in it too. Right now we are accepting student applications.
Process to Apply
[more]SDL Perl Showcase
Friday, 12 March 2010
Tags: [EyeCandy] [Perl] [SDL Perl] [Showcase]
SDL_Mixer and Effects
[more]Quick Game for Toronto Perl Mongers
Thursday, 11 February 2010
Tags: [Game] [SDL] [TPM]
Beep ... Boop
[more]SDL_perl 2.3_5 is out!
Monday, 01 February 2010
Tags: [Releases] [SDL]
We keep on rolling,
rolling,
waiting on the world to turn.
[more]Threaded XS callback finally gets solved.
Wednesday, 06 January 2010
Tags: [Perl] [SDL] [Updates] [XS]
Dragged down from the lofty isles,
into the guts and gore of the monster,
[more]SDL Alpha 2: A sneak preview
Sunday, 06 December 2009
Tags: [Perl] [Releases] [SDL]
Pretty or Ugly,
Code is Code
New or Old,
[more]Developer Release of SDL 2.3_1
Monday, 30 November 2009
Tags: [Perl] [Releases] [SDL]
The city of Rome was built,
with the first brick.
[more]SDL Perl Documentation: Reviewers need
Thursday, 26 November 2009
Tags: [Docs] [Perl] [SDL]
The written word,
survives;
[more]Migrating Sol's Tutorial of SDL to SDL_Perl
Sunday, 15 November 2009
Tags: [Example] [Perl] [SDL]
If I have seen further it is only by standing on the shoulders of giants. --Newton
[more]Once in a while .... (set_event_filter)
Friday, 13 November 2009
Tags: [Perl] [SDL] [XS]
Once in a while
Things just work!
[more]Hello Mouse? An Example of the New Event Code
Wednesday, 11 November 2009
Tags: [Perl] [SDL] [Sneak Preview]
Any code that is not marketed is dead code
--mst
[more]Development Update
Monday, 09 November 2009
Tags: [Perl] [SDL] [Updates]
Short and Sweet
Had an exam on the weekend so I am a bit late. Here is the progress so far.
[more]Development Update
Monday, 02 November 2009
Tags: [Perl] [SDL] [Updates]
A stoic stone will sit idle,
but will some effort,
[more]The Future and Beyond!
Saturday, 24 October 2009
Tags: [Design] [SDL] [Updates] [games]
I do not think about awesomeness...
I just am awesomeness
n.n
[more]The beginnings of modular design for SDL Perl
Sunday, 11 October 2009
Tags: [Design] [SDL] [Updates]
âDo or do not... there is no try.â
--yoda
The design before
[more]Why and How Frozen Bubble is going to CPAN
Friday, 02 October 2009
Tags: [Frozen Bubble] [Perl] [SDL]
A single drop,
causes the ocean to swell
[more]HackFest: Results
Monday, 28 September 2009
Tags: [HackFest] [Perl] [SDL]
The beautiful sunset,
is no match for,
the ugly sunrise
[more]Updates, Falling Block Game, and Hack Fest
Wednesday, 23 September 2009
Tags: [Docs] [Perl] [SDL]
Silent but active,
Small but deadly.
[more]Thanks nothingmuch, and updates
Friday, 18 September 2009
Tags: [Design] [Perl] [SDL] [Tutorial]
struggle,
live,
cease,
[more]Design of SDL::Rect
Saturday, 12 September 2009
Tags: [Design] [Perl] [SDL]
you say things,
I hear,
[more]
If you cannot wait then grab SDL 2.4 and Alien::SDL 1.2 (pick PANGO support) from CPAN and grab the toolchain branch from the repo. Disclaimer the branch will be volatile for a bit.
As many of the readers must know The Perl Foundation has been accepted for the GSOC 2010 program. There are several SDL_perl mentors involved in it too. Right now we are accepting student applications.
+We released a playable (client) frozen bubble on CPAN. There is more work to be done but it is a great start! It currently works on Windows and Linux.
-Process to Apply
-
Here are some ideas for SDL perl but we happily accepted student ideas.
- Make a student wiki page on this site of your ideas! We look forward to helping you guys with your ideas :)
If you cannot wait then grab SDL 2.4 and Alien::SDL 1.2 (pick PANGO support) from CPAN and grab the toolchain branch from the repo. Disclaimer the branch will be volatile for a bit.
As many of the readers must know The Perl Foundation has been accepted for the GSOC 2010 program. There are several SDL_perl mentors involved in it too. Right now we are accepting student applications.
+Process to Apply
+
Here are some ideas for SDL perl but we happily accepted student ideas.
+ Make a student wiki page on this site of your ideas! We look forward to helping you guys with your ideas :)
In an effort to learn from past versions of SDL Perl and improve. We have been writing lots of documentation for our users. Of course since this is the first time we have been providing documentation we need your help. Please review our docs, at sdl.perl.org and give us some feed back. Send us the feeback at sdl-devel@mail.org or join us at #sdl irc.perl.org
When I was struggling with SDL C a while ago, someone recommended Sol's Tutorial to me. It had not only help me understand video in SDL, but I believe my code has improved using Sol's code style. I would like to pass these along to fellow SDL_Perl users too. So here is the Ch 02 code of Sol's Tutorial in SDL_Perl. It will be getting more and more Perly as our team hacks on it. There is more to come!
-
To use this code you need the new Redesigned SDL_Perl Library
$ sudo apt-get install libsdl-net1.2-dev libsdl-mixer1.2-dev libsmpeg-dev libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev
$ cpan Alien::SDL** Add sudo to this for Linux
$ cpan .** The dot is needed
$ perl examples/sols/ch02.pl-
1 #!/usr/bin/perl -w - 2 use strict; - 3 use warnings; - 4 use SDL v2.3; #Require the redesign branch - 5 use SDL::Video; - 6 use SDL::Event; - 7 use SDL::Events; - 8 - 9 SDL::init(SDL_INIT_VIDEO); -10 my $display = SDL::Video::set_video_mode(640,480,32, SDL_SWSURFACE ); -11 my $event = SDL::Event->new(); -12 -13 #This filters out all ActiveEvents -14 my $filter = sub { -15 my ($e, $type) = ($_[0], $_[0]->type); -16 if($type == SDL_ACTIVEEVENT){ return 0 } -17 elsif($type == SDL_MOUSEBUTTONDOWN && $e->button_button == 1){ return 0 } -18 else { return 1; } -19 }; -20 -21 SDL::Events::set_event_filter($filter); -22 -23 while(1) -24 { -25 -26 SDL::Events::pump_events(); -27 if(SDL::Events::poll_event($event)) -28 { -29 -30 if( $event->type == SDL_ACTIVEEVENT) -31 { -32 print "Hello Mouse!!!\n" if ($event->active_gain && ($event->active_state == SDL_APPMOUSEFOCUS) ); -33 print "Bye Mouse!!!\n" if (!$event->active_gain && ($event->active_state == SDL_APPMOUSEFOCUS) ); -34 } -35 if( $event->type == SDL_MOUSEBUTTONDOWN) -36 { -37 my ($x, $y, $but ) = ($event->button_x, $event->button_y, $event->button_button); -38 warn "$but CLICK!!! at $x and $y \n"; -39 } -40 -41 last if($event->type == SDL_QUIT); -42 } -43 } -44 SDL::quit();
Tinker with $filter and look at perldoc lib/SDL/pods/Event.pod.
Have fun,
--yapgh-
In an effort to learn from past versions of SDL Perl and improve. We have been writing lots of documentation for our users. Of course since this is the first time we have been providing documentation we need your help. Please review our docs, at sdl.perl.org and give us some feed back. Send us the feeback at sdl-devel@mail.org or join us at #sdl irc.perl.org
When I was struggling with SDL C a while ago, someone recommended Sol's Tutorial to me. It had not only help me understand video in SDL, but I believe my code has improved using Sol's code style. I would like to pass these along to fellow SDL_Perl users too. So here is the Ch 02 code of Sol's Tutorial in SDL_Perl. It will be getting more and more Perly as our team hacks on it. There is more to come!
+
To use this code you need the new Redesigned SDL_Perl Library
$ sudo apt-get install libsdl-net1.2-dev libsdl-mixer1.2-dev libsmpeg-dev libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev
$ cpan Alien::SDL** Add sudo to this for Linux
$ cpan .** The dot is needed
#!/usr/bin/env perl - -use SDL; -use SDL::Events; -use SDL::Event; -use SDL::Video; - -SDL::init(SDL_INIT_VIDEO); - -my $display = SDL::Video::set_video_mode(640,480,32, SDL_SWSURFACE ); -my $event = SDL::Event->new(); - -while(1) -{ - SDL::Events::pump_events(); - - if(SDL::Events::poll_event($event) && $event->type == SDL_ACTIVEEVENT) - { - print "Hello Mouse!!!\n" if ($event->active_gain && ($event->active_state == SDL_APPMOUSEFOCUS) ); - print "Bye Mouse!!!\n" if (!$event->active_gain && ($event->active_state == SDL_APPMOUSEFOCUS) ); - } - - exit if($event->type == SDL_QUIT); -}-
$ perl examples/sols/ch02.pl+
1 #!/usr/bin/perl -w + 2 use strict; + 3 use warnings; + 4 use SDL v2.3; #Require the redesign branch + 5 use SDL::Video; + 6 use SDL::Event; + 7 use SDL::Events; + 8 + 9 SDL::init(SDL_INIT_VIDEO); +10 my $display = SDL::Video::set_video_mode(640,480,32, SDL_SWSURFACE ); +11 my $event = SDL::Event->new(); +12 +13 #This filters out all ActiveEvents +14 my $filter = sub { +15 my ($e, $type) = ($_[0], $_[0]->type); +16 if($type == SDL_ACTIVEEVENT){ return 0 } +17 elsif($type == SDL_MOUSEBUTTONDOWN && $e->button_button == 1){ return 0 } +18 else { return 1; } +19 }; +20 +21 SDL::Events::set_event_filter($filter); +22 +23 while(1) +24 { +25 +26 SDL::Events::pump_events(); +27 if(SDL::Events::poll_event($event)) +28 { +29 +30 if( $event->type == SDL_ACTIVEEVENT) +31 { +32 print "Hello Mouse!!!\n" if ($event->active_gain && ($event->active_state == SDL_APPMOUSEFOCUS) ); +33 print "Bye Mouse!!!\n" if (!$event->active_gain && ($event->active_state == SDL_APPMOUSEFOCUS) ); +34 } +35 if( $event->type == SDL_MOUSEBUTTONDOWN) +36 { +37 my ($x, $y, $but ) = ($event->button_x, $event->button_y, $event->button_button); +38 warn "$but CLICK!!! at $x and $y \n"; +39 } +40 +41 last if($event->type == SDL_QUIT); +42 } +43 } +44 SDL::quit();
Tinker with $filter and look at perldoc lib/SDL/pods/Event.pod.
Have fun,
--yapgh+
#!/usr/bin/env perl + +use SDL; +use SDL::Events; +use SDL::Event; +use SDL::Video; + +SDL::init(SDL_INIT_VIDEO); + +my $display = SDL::Video::set_video_mode(640,480,32, SDL_SWSURFACE ); +my $event = SDL::Event->new(); + +while(1) +{ + SDL::Events::pump_events(); + + if(SDL::Events::poll_event($event) && $event->type == SDL_ACTIVEEVENT) + { + print "Hello Mouse!!!\n" if ($event->active_gain && ($event->active_state == SDL_APPMOUSEFOCUS) ); + print "Bye Mouse!!!\n" if (!$event->active_gain && ($event->active_state == SDL_APPMOUSEFOCUS) ); + } + + exit if($event->type == SDL_QUIT); +}+
mkdir SDL
-cd SDL
-git init .
git pull git://github.com/kthakore/SDL_perl.git experimental-
mkdir SDL
+cd SDL
+git init .
git pull git://github.com/kthakore/SDL_perl.git experimental+
Core | ||
SDL | - Simple DirectMedia Layer for Perl | |
SDL::Time | - a SDL perl extension for managing timers. |
Audio | ||
SDL::Audio | - SDL Bindings for Audio |
Structure | ||
SDL::AudioCVT | - Audio Conversion Structure | |
SDL::AudioSpec | - SDL Bindings for structure SDL::AudioSpec |
CDROM | ||
SDL::CDROM | - SDL Bindings for the CDROM device |
Structure | ||
SDL::CD | - SDL Bindings for structure SDL_CD | |
SDL::CDTrack | - SDL Bindings for structure SDL_CDTrack |
Events | ||
SDL::Events | - Bindings to the Events Category in SDL API |
Structure | ||
SDL::Event | - General event structure |
Joystick | ||
SDL::Joystick | - SDL Bindings for the Joystick device |
Mouse | ||
SDL::Mouse | - SDL Bindings for the Mouse device |
Structure | ||
SDL::Cursor | - Mouse cursor structure |
Structure | ||
SDL::Version | - SDL Bindings for structure SDL_Version |
Video | ||
SDL::Video | - Bindings to the video category in SDL API |
Structure | ||
SDL::Color | - Format independent color description | |
SDL::Overlay | - YUV Video overlay | |
SDL::Palette | - Color palette for 8-bit pixel formats | |
SDL::PixelFormat | - Stores surface format information | |
SDL::Rect | - Defines a rectangular area | |
SDL::Surface | - Graphic surface structure. | |
SDL::VideoInfo | - Video Target Information |
Cookbook | ||
SDL::Cookbook | ||
SDL::Cookbook::PDL |
Extension | ||
SDL::App | - a SDL perl extension |
GFX | ||
SDL::GFX::Framerate | - framerate calculating functions | |
SDL::GFX::Primitives | - basic drawing functions |
Structure | ||
SDL::GFX::FPSManager | - data structure used by SDL::GFX::Framerate |
Image | ||
SDL::Image | - Bindings for the SDL_Image library |
Mixer | ||
SDL::Mixer | - Sound and music functions | |
SDL::Mixer::Channels | - SDL::Mixer channel functions and bindings | |
SDL::Mixer::Effects | - sound effect functions | |
SDL::Mixer::Groups | - Audio channel group functions | |
SDL::Mixer::Music | - functions for music | |
SDL::Mixer::Samples | - functions for loading sound samples |
Structure | ||
SDL::Mixer::MixChunk | - SDL Bindings for structure SDL_MixChunk | |
SDL::Mixer::MixMusic | - SDL Bindings for structure SDL_MixMusic |
Pango | ||
SDL::Pango | - Text rendering engine |
Structure | ||
SDL::Pango::Context | - Context object for SDL::Pango |
TODO |
Core |
MultiThread | ||
SDL::MultiThread | - Bindings to the MultiThread category in SDL API |
Structure | ||
SDL::RWOps | - SDL Bindings to SDL_RWOPs |
GFX | ||
SDL::GFX::BlitFunc | - blitting functions | |
SDL::GFX::ImageFilter | - image filtering functions | |
SDL::GFX::Rotozoom | - rotation and zooming functions for surfaces |
TTF | ||
SDL::TTF | - True Type Font functions (libfreetype) |
Structure | ||
SDL::TTF::Font | - Font object type for SDL_ttf |
Tutorials | ||
SDL::Tutorial | - introduction to Perl SDL | |
SDL::Tutorial::Animation | ||
SDL::Tutorial::LunarLander | - a small tutorial on Perl SDL |
UNCATEGORIZED | ||
SDL::Credits | - Authors and contributors of the SDL Perl project | |
SDL::Game::Palette | - a perl extension | |
SDL::MPEG | - a SDL perl extension | |
SDL::Music | - a perl extension | |
SDL::OpenGL | - a perl extension | |
SDL::SMPEG | - a SDL perl extension | |
SDL::Sound | - a perl extension | |
SDL::Tool::Font | - a perl extension | |
SDL::Tool::Graphic |
Core | ||
SDL | - Simple DirectMedia Layer for Perl | |
SDL::Credits | - Authors and contributors of the SDL Perl project | |
SDL::Time | - a SDL perl extension for managing timers. |
Audio | ||
SDL::Audio | - SDL Bindings for Audio |
Structure | ||
SDL::AudioCVT | - Audio Conversion Structure | |
SDL::AudioSpec | - SDL Bindings for structure SDL::AudioSpec |
CDROM | ||
SDL::CDROM | - SDL Bindings for the CDROM device |
Structure | ||
SDL::CD | - SDL Bindings for structure SDL_CD | |
SDL::CDTrack | - SDL Bindings for structure SDL_CDTrack |
Events | ||
SDL::Events | - Bindings to the Events Category in SDL API |
Structure | ||
SDL::Event | - General event structure |
Joystick | ||
SDL::Joystick | - SDL Bindings for the Joystick device |
Mouse | ||
SDL::Mouse | - SDL Bindings for the Mouse device |
Structure | ||
SDL::Cursor | - Mouse cursor structure |
Structure | ||
SDL::Version | - SDL Bindings for structure SDL_Version |
Video | ||
SDL::Video | - Bindings to the video category in SDL API |
Structure | ||
SDL::Color | - Format independent color description | |
SDL::Overlay | - YUV Video overlay | |
SDL::Palette | - Color palette for 8-bit pixel formats | |
SDL::PixelFormat | - Stores surface format information | |
SDL::Rect | - Defines a rectangular area | |
SDL::Surface | - Graphic surface structure. | |
SDL::VideoInfo | - Video Target Information |
Cookbook | ||
SDL::Cookbook | ||
SDL::Cookbook::PDL |
Extension | ||
SDL::App | - a SDL perl extension |
GFX | ||
SDL::GFX::Framerate | - framerate calculating functions | |
SDL::GFX::Primitives | - basic drawing functions |
Structure | ||
SDL::GFX::FPSManager | - data structure used by SDL::GFX::Framerate |
Image | ||
SDL::Image | - Bindings for the SDL_Image library |
Mixer | ||
SDL::Mixer | - Sound and music functions | |
SDL::Mixer::Channels | - SDL::Mixer channel functions and bindings | |
SDL::Mixer::Effects | - sound effect functions | |
SDL::Mixer::Groups | - Audio channel group functions | |
SDL::Mixer::Music | - functions for music | |
SDL::Mixer::Samples | - functions for loading sound samples |
Structure | ||
SDL::Mixer::MixChunk | - SDL Bindings for structure SDL_MixChunk | |
SDL::Mixer::MixMusic | - SDL Bindings for structure SDL_MixMusic |
Pango | ||
SDL::Pango | - Text rendering engine |
Structure | ||
SDL::Pango::Context | - Context object for SDL::Pango |
TODO | ||
SDL::MPEG | - a SDL perl extension | |
SDL::OpenGL | - a perl extension | |
SDL::SMPEG | - a SDL perl extension |
MultiThread | ||
SDL::MultiThread | - Bindings to the MultiThread category in SDL API |
Structure | ||
SDL::RWOps | - SDL Bindings to SDL_RWOPs |
GFX | ||
SDL::GFX::BlitFunc | - blitting functions | |
SDL::GFX::ImageFilter | - image filtering functions | |
SDL::GFX::Rotozoom | - rotation and zooming functions for surfaces |
TTF | ||
SDL::TTF | - True Type Font functions (libfreetype) |
Structure | ||
SDL::TTF::Font | - Font object type for SDL_ttf |
Tutorials | ||
SDL::Tutorial | - introduction to Perl SDL | |
SDL::Tutorial::Animation | ||
SDL::Tutorial::LunarLander | - a small tutorial on Perl SDL |
cpan Games::FrozenBubble + +