From: Kartik Thakore Date: Wed, 14 Jul 2010 02:58:07 +0000 (+0000) Subject: update X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=30fd24c26cb4e59a5937d49aa4810269ace3a8b0;p=sdlgit%2FSDL-Site.git update --- diff --git a/pages/SDL-Deprecated.html-inc b/pages/SDL-Deprecated.html-inc new file mode 100644 index 0000000..8131a11 --- /dev/null +++ b/pages/SDL-Deprecated.html-inc @@ -0,0 +1,47 @@ +
+ +

Index

+ +
+ + +

NAME

Top

+
+

SDL::Deprecated - Log of Deprecated items per release

+ +
+

CATEGORY

Top

+
+

Core

+ +
+

RELEASES

Top

+
+ +
+

2.500

+
+ + + + +
+
SDL::App
+
+

SDL::App has migrated to SDLx::App namespace. The reason for this is because it is an extenstion and not a 1:1 XS/Constant Module to the c library.

+
+
SDL::Game::Rect
+
+

SDL::Game::Rect has migrated to SDLx::Rect namespace. Same reasoning as above.

+
+
+ +
+
\ No newline at end of file diff --git a/pages/SDLx-Rect.html-inc b/pages/SDLx-Rect.html-inc new file mode 100644 index 0000000..e3bedfa --- /dev/null +++ b/pages/SDLx-Rect.html-inc @@ -0,0 +1,316 @@ +
+ +

Index

+ +
+ + +

NAME

Top

+
+

SDLx::Rect - SDL extension for storing and manipulating rectangular coordinates

+ +
+

CATEGORY

Top

+
+

Extension

+ +
+

SYNOPSIS

Top

+
+

SDLx::Rect works as a SDL::Rect in the lower layer (SDL::*) but provides more methods to users.

+
	use SDLx::Rect; #instead of SDL::Rect
+
+	my $rect = SDLx::Rect->new( $x, $y, $w, $h); #same as SDL::Rect
+
+	...
+
+	SDL::Video::fill_rect( .. , $rect, ...); # use like SDL::Rect
+
+
+
+
+
+ +
+

DESCRIPTION

Top

+
+

SDLx::Rect object are used to store and manipulate rectangular areas. Rect objects are created from a combination of left (or x), top (or y), width (or w) and height (or h) values, just like raw SDL::Rect objects.

+

All SDLx::Rect methods that change either position or size of a Rect return a new copy of the Rect with the affected changes. The original Rect is not modified. If you wish to modify the current Rect object, you can use the equivalent "in-place" methods that do not return but instead affects the original Rect. These "in-place" methods are denoted with the "ip" suffix. Note that changing a Rect's attribute is always an in-place operation.

+ + + + + +
+

ATTRIBUTES

+
+

All Rect attributes are acessors, meaning you can get them by name, and set them by passing a value:

+
   $rect->left(15);
+   $rect->left;       # 15
+
+
+

The Rect object has several attributes which can be used to resize, move and align the Rect.

+ + + + +
+
* width, w - gets/sets object's width
+
* height, h - gets/sets object's height
+
* left, x - moves the object left position to match the given coordinate
+
* top, y - moves the object top position to match the given coordinate
+
* bottom - moves the object bottom position to match the given coordinate
+
* right - moves the object right position to match the given coordinate
+
* centerx - moves the object's horizontal center to match the given coordinate
+
* centery - moves the object's vertical center to match the given coordinate
+
+

Some of the attributes above can be fetched or set in pairs:

+
  $rect->topleft(10, 15);   # top is now 10, left is now 15
+
+  my ($width, $height) = $rect->size;
+
+
+
+
+
+
+
* size - gets/sets object's size (width, height)
+
* topleft - gets/sets object's top and left positions
+
* midleft - gets/sets object's vertical center and left positions
+
* bottomleft - gets/sets object's bottom and left positions
+
* center - gets/sets object's center (horizontal(x), vertical(y))
+
* topright - gets/sets object's top and right positions
+
* midright - gets/sets object's vertical center and right positions
+
* bottomright - gets/sets object's bottom and right positions
+
* midtop - gets/sets object's horizontal center and top positions
+
* midbottom - gets/sets object's horizontal center and bottom positions
+
+ + + + + +
+

METHODS

+
+

Methods denoted as receiving Rect objects can receive either <SDLx::Rect> or raw <SDL::Rect> objects.

+ +
+

new ($left, $top, $width, $height)

+
+

Returns a new Rect object with the given coordinates. If any value is omitted (by passing undef), 0 is used instead.

+ +
+

copy

+
+ +
+

duplicate

+
+

Returns a new Rect object having the same position and size as the original

+ +
+

move(x, y)

+
+

Returns a new Rect that is moved by the given offset. The x and y arguments can be any integer value, positive or negative.

+ +
+

move_ip(x, y)

+
+

Same as <move> above, but moves the current Rect in place and returns nothing.

+ +
+

inflate(x, y)

+
+

Grows or shrinks the rectangle. Returns a new Rect with the size changed by the given offset. The rectangle remains centered around its current center. Negative values will return a shrinked rectangle instead.

+ +
+

inflate_ip(x, y)

+
+

Same as <inflate> above, but grows/shrinks the current Rect in place and returns nothing.

+ +
+

clamp($rect)

+
+

Returns a new Rect moved to be completely inside the Rect object passed as an argument. If the current Rect is too large to fit inside the passed Rect, it is centered inside it, but its size is not changed.

+ +
+

clamp_ip($rect)

+
+

Same as <clamp> above, but moves the current Rect in place and returns nothing.

+ +
+

clip($rect)

+
+

Returns a new Rect with the intersection between the two Rect objects, that is, returns a new Rect cropped to be completely inside the Rect object passed as an argument. If the two rectangles do not overlap to begin with, a Rect with 0 size is returned, in the original Rect's (x,y) coordinates.

+ +
+

clip_ip($rect)

+
+

Same as <clip> above, but crops the current Rect in place and returns nothing. As the original method, the Rect becomes zero-sized if the two rectangles do not overlap to begin with, retaining its (x, y) coordinates.

+ +
+

union($rect)

+
+

Returns a new rectangle that completely covers the area of the current Rect and the one passed as an argument. There may be area inside the new Rect that is not covered by the originals.

+ +
+

union_ip($rect)

+
+

Same as <union> above, but resizes the current Rect in place and returns nothing.

+ +
+

unionall( [$rect1, $rect2, ...] )

+
+

Returns the union of one rectangle with a sequence of many rectangles, passed as an ARRAY REF.

+ +
+

unionall_ip( [$rect1, $rect2, ...] )

+
+

Same as <unionall> above, but resizes the current Rect in place and returns nothing.

+ +
+

fit($rect)

+
+

Returns a new Rect moved and resized to fit the Rect object passed as an argument. The aspect ratio of the original Rect is preserved, so the new rectangle may be smaller than the target in either width or height.

+ +
+

fit_ip($rect)

+
+

Same as <fit> above, but moves/resizes the current Rect in place and returns nothing.

+ +
+

normalize

+
+

Corrects negative sizes, flipping width/height of the Rect if they have a negative size. No repositioning is made so the rectangle will remain in the same place, but the negative sides will be swapped. This method returns nothing.

+ +
+

contains($rect)

+
+

Returns true (non-zero) when the argument is completely inside the Rect. Otherwise returns undef.

+ +
+

collidepoint(x, y)

+
+

Returns true (non-zero) if the given point is inside the Rect, otherwise returns undef. A point along the right or bottom edge is not considered to be inside the rectangle.

+ +
+

colliderect($rect)

+
+

Returns true (non-zero) if any portion of either rectangles overlap (except for the top+bottom or left+right edges).

+ +
+

collidelist( [$rect1, $rect2, ...] )

+
+

Test whether the rectangle collides with any in a sequence of rectangles, passed as an ARRAY REF. The index of the first collision found is returned. Returns undef if no collisions are found.

+ +
+

collidelistall( [$rect1, $rect2, ...] )

+
+

Returns an ARRAY REF of all the indices that contain rectangles that collide with the Rect. If no intersecting rectangles are found, an empty list ref is returned.

+ +
+

collidehash( {key1 => $rect1, key2 => $rect2, ...} )

+
+

Receives a HASH REF and returns the a (key, value) list with the key and value of the first hash item that collides with the Rect. If no collisions are found, returns (undef, undef).

+ +
+

collidehashall( {key1 => $rect1, key2 => $rect2, ...} )

+
+

Returns a HASH REF of all the key and value pairs that intersect with the Rect. If no collisions are found an empty hash ref is returned.

+ + + + + +
+

AUTHOR

Top

+
+

Breno G. de Oliveira, <garu at cpan.org>

+ +
+

BUGS

Top

+
+

Please report any bugs or feature requests to the bug tracker. I will be notified, and then you'll automatically be notified of progress on your bug as we make changes.

+ + + + + +
+

SUPPORT

Top

+
+

You can find documentation for this module with the perldoc command.

+
    perldoc SDLx::Rect
+
+
+
+
+
+ +
+

ACKNOWLEDGEMENTS

Top

+
+

Many thanks to all SDL_Perl contributors, and to the authors of pygame.rect, in which this particular module is heavily based.

+ +
+

COPYRIGHT & LICENSE

Top

+ +

SEE ALSO

Top

+
+

perl, SDL, SDL::Rect, SDL::Game +

+ +
+
\ No newline at end of file diff --git a/pages/SDLx-SFont.html-inc b/pages/SDLx-SFont.html-inc new file mode 100644 index 0000000..4e753c4 --- /dev/null +++ b/pages/SDLx-SFont.html-inc @@ -0,0 +1,109 @@ +
+ +

Index

+ +
+ + +

NAME

Top

+
+

SDLx::SFont - Extension making fonts out of images and printing them

+ +
+

CATEGORY

Top

+
+

Extension

+ +
+

SYNOPSIS

Top

+
+
  use SDLx::SFont;
+  use SDLx::App;
+
+   #Make a surface
+   #Select a font
+   my $d = SDLx::App->new( -title => 'app', -width => 200, -height => 200, -depth => 32 );
+
+   my $font = SDLx::SFont->new('t/font.png');
+
+   #print using $font
+
+   SDLx::SFont::print_text( $d, 10, 10, 'Huh' );
+
+   my $font2 = SDLx::SFont->new('t/font2.png');
+
+   #print using font2
+
+   SDLx::SFont::print_text( $d, 10, 10, 'Huh' );
+
+   $font->use();
+
+   #print using $font
+
+   SDLx::SFont::print_text( $d, 10, 10, 'Huh' );
+
+   #that is it folks ..
+
+
+ +
+

DESCRIPTION

Top

+
+

a simpler print function for old SDL::SFont dependency on Frozen-Bubble and Pangzero.

+ +
+

USAGE

Top

+
+

see synopsis

+ +
+

BUGS

Top

+
+

You tell me! at sdlperl.ath.cx

+ +
+

SUPPORT

Top

+
+

#sdl irc.perl.org

+ +
+

AUTHOR

Top

+
+
    Kartik Thakore
+    CPAN ID: KTHAKORE
+    ---
+    kthakore@cpan.org
+    http://sdl.perl.org
+
+
+ +
+

COPYRIGHT

Top

+ +

SEE ALSO

Top

+
+

perl(1), SDL(2).

+ +
+
\ No newline at end of file diff --git a/pages/SDLx-Sprite.html-inc b/pages/SDLx-Sprite.html-inc new file mode 100644 index 0000000..9f50564 --- /dev/null +++ b/pages/SDLx-Sprite.html-inc @@ -0,0 +1,343 @@ +
+ +

Index

+ +
+ + +

NAME

Top

+
+

SDLx::Sprite - interact with images quick and easily in SDL

+ +
+

CATEGORY

Top

+
+

Extension

+ +
+

SYNOPSIS

Top

+
+
    use SDLx::Sprite;
+
+    my $sprite = SDLx::Sprite->new;
+
+    # loads image file into a SDL::Surface and
+    # automatically sets a SDL::Rect inside with
+    # that image's dimensions.
+    $sprite->load('hero.png');
+
+    # set sprite image transparency
+    $sprite->alpha_key( $color );
+    $sprite->alpha(0.5);
+
+    # you can set and check the sprite position anytime
+    say $sprite->x;   # rect->x shortcut accessor
+    $sprite->y(30);   # rect->y shortcut accessor
+
+    # read-only surface dimensions
+    $sprite->w;   # width
+    $sprite->h;   # height
+
+    # you can also fetch the full rect
+    # (think destination coordinates for ->draw)
+    my $rect = $sprite->rect;
+
+    # you can get the surface object too if you need it
+    my $surface = $sprite->surface;
+
+    # rotation() 
+
+    # if your SDL has gfx, rotation is also straightforward:
+    $sprite->rotation( $degrees );
+    $sprite->rotation( $degrees, $smooth );
+
+
+
+
+    # add() / remove() NOT YET IMPLEMENTED
+    # you can also attach other sprites to it
+    $sprite->add( armor => $other_sprite );
+    $sprite->remove('armor');
+
+    # blits $sprite (and attached sprites) into $screen,
+    # in the (x,y) coordinates of the sprite
+    $sprite->draw($screen);
+
+    # if you need to clip the original image/surface
+    # before drawing it
+    $sprite->clip->x(10);
+    $sprite->clip->y(3);
+    $sprite->clip->w(5);
+    $sprite->clip->h(5);
+
+    # ...or all at once:
+    $sprite->clip($x,$y,$w,$h);
+
+    # spawning can include almost all of the above:
+    my $sprite = SDLx::Sprite->new(
+              image   => 'hero.png',   # or surface => SDL::Surface
+              rect    => SDL::Rect,    # or x => $x, y => $y
+              clip    => SDL::Rect,
+              alpha_key => SDL::Color, # or [$r, $g, $b]
+              alpha     => 1,
+              rotation  => 45, # degrees
+         );
+
+
+
+
+
+ +
+

DESCRIPTION

Top

+
+

SDLx::Sprite is a SDL::Surface on steroids! It let's you quickly +load, setup and interact with images in your SDL application, abstracting +all the drudge code and letting you concentrate on your app's logic instead.

+

This module automatically creates and holds SDL::Rect objects for the source +and destination surfaces, and provides several surface manipulation options +like alpha blending and rotation.

+ +
+

WARNING! VOLATILE CODE AHEAD

Top

+
+

This is a new module and the API is subject to change without notice. +If you care, please join the discussion on the #sdl IRC channel in +irc.perl.org. All thoughts on further improving the API are welcome.

+

You have been warned :)

+ +
+

METHODS

Top

+
+ +
+

new

+
+ +
+

new( %options )

+
+

Creates a new SDLx::Sprite object. No option is mandatory. +Available options are:

+
+
* image => $filename
+
+

Uses $filename as source image for the Sprite's surface. See suported +formats in SDL::Image. This option cannot be used together +with the 'surface' option (see below).

+
+
* surface => SDL::Surface
+
+

Uses the provided SDL::Surface object as source surface for this +sprite, instead of creating one automatically. This option cannot be +used together with the 'image' option (see above).

+
+
* clip => SDL::Rect
+
+

Uses the provided SDL::Rect object as clipping rect for the source +surface. This means the object will only blit that particular area from +the surface.

+
+
* rect => SDL::Rect
+
+

Uses the provided SDL::Rect object as destination coordinates to +whatever surface you call draw() on. You cannot use this option together +with 'x' and 'y' (see below)

+
+
* x => $x
+
+

Uses $x as the x-axis (left-to-right, 0 being leftmost) positioning of +the Sprite into the destination you call draw() upon. This option cannot +be used together with 'rect' (see above).

+
+
* y => $y
+
+

Uses $y as the y-axis (top-to-bottom, 0 being topmost) positioning of +the Sprite into the destination you call draw() upon. This option cannot +be used together with 'rect' (see above).

+
+
* draw_xy => $surface, $x, $y
+
+

A shortcut to draw at coordinates quickly. Calles x() , y() and draw()

+
+
* rotation => $degrees, [$smooth]
+
+

Uses $degrees as the angle to rotate the surface to, in degrees +(0..360, remember? :). This option is only available if your compiled SDL +library has support for GFX (see Alien::SDL for details).

+

if $smooth is set the spirte is antialiased. This may mess with your alpha_key.

+
+
* alpha_key => SDL::Color
+
+

MUST CALL SDL::Video::get_video_mode prior to this.

+

Uses the provided SDL::Color object (or an array reference with red, +green and blue values) as the color to be turned into transparent +(see 'alpha' below).

+
+
* alpha => $percentage or $integer
+
+ + + + +

Uses $percentage (0 <-> 1 ) or $integer ( 0x01 - 0xff) as how much transparency to add to the surface. If you use +this, it is mandatory that you also provide the alpha_key (see above).

+
+
+ +
+

load( $filename )

+
+

Loads the given image file into the object's internal surface. A new surface +is always created, so whatever you had on the previous surface will be +lost. Croaks on errors such as no support built for the image or a file +reading error (the error message is SDL::get_error and should give more +details).

+

Returns the own Sprite object, to allow method chaining.

+ +
+

surface()

+
+ +
+

surface( SDL::Surface )

+
+

Returns the object's internal surface, or undef if there is none.

+

If you pass a SDL::Surface to it, it will overwrite the original surface +with it, while returning the old (previous) surface. Note that, as such, +it will return undef if you use it without having previously loaded +either an image or a previous surface. It will croak if you pass anything +that's not an SDL::Surface object (or SDL::Surface subclassed objects).

+ +
+

rect()

+
+ +
+

rect( SDL::Rect )

+
+

Returns the destination SDL::Rect object used when you call draw().

+

If you haven't explicitly set it, it will be a SDL::Rect with the same +dimensions as the object's internal surface. If no surface was set yet, +it will be an empty SDL::Rect (dimensions 0,0,0,0).

+

If you pass it a SDL::Rect object, it will set rect() to that object +before returning, but it will overwrite any width and height values, as +those are read only and set to the size of the underlying surface.

+

If you want to clip the source surface, set clip() instead.

+ +
+

clip()

+
+ +
+

clip( SDL::Rect )

+
+

Returns the source SDL::Rect object used when you call draw().

+

You can use this method to choose only a small subset of the object's +internal surface to be used on calls to draw().

+

If you haven't explicitly set it, it will be a SDL::Rect with the same +dimensions as the object's internal surface. If no surface was set yet, +it will be an empty SDL::Rect (dimensions 0,0,0,0).

+

If you pass it a SDL::Rect object, it will set clip() to that object +before returning.

+ +
+

x()

+
+ +
+

x( $int )

+
+

Gets/sets the x-axis (left-to-right, 0 being leftmost) positioning of +the Sprite into the destination you call draw() upon.

+

It is a shortcut to $sprite->rect->x.

+ + + + + +
+

y()

+
+ +
+

y( $int )

+
+

Gets/sets the y-axis (top-to-bottom, 0 being topmost) positioning of +the Sprite into the destination you call draw() upon.

+

It is a shortcut to $sprite->rect->y.

+ + + + + +
+

w()

+
+

Returns the Sprite surface's width. This method is read-only.

+

It is a shortcut to $sprite->surface->w.

+ + + + + +
+

h()

+
+

Returns the Sprite surface's height. This method is read-only.

+

It is a shortcut to $sprite->surface->h.

+ + + + + +
+

draw( SDL::Surface )

+
+

Draws the Sprite on the provided SDL::Surface object - usually the screen - +using the blit_surface SDL function, using the source rect from clip() and the +destination rect (position) from rect().

+

Returns the own Sprite object, to allow method chaining.

+ +
+

AUTHORS

Top

+
+

Dustin Mays, <dork.fish.wat@gmail.com>

+

Breno G. de Oliveira, <garu at cpan.org>

+

Kartik thakore <kthakore at cpan.org>

+ +
+

SEE ALSO

Top

+
+

SDL::Surface, SDL +

+ +
+
\ No newline at end of file diff --git a/pages/SDLx-Surface.html-inc b/pages/SDLx-Surface.html-inc new file mode 100644 index 0000000..195a24d --- /dev/null +++ b/pages/SDLx-Surface.html-inc @@ -0,0 +1,148 @@ +
+ +

Index

+ +
+ + +

NAME

Top

+
+

SDLx::Surface - Graphic surface matrix extension

+ +
+

CATEGORY

Top

+
+

Extension

+ +
+

SYNOPSIS

Top

+
+
 use SDL;
+ use SDL::Video;
+ use SDLx::Surface;
+
+ # Create the main surface (display)
+ SDL::init(SDL_INIT_VIDEO);
+ my $display = SDL::Video::set_video_mode(640, 480, 16, SDL_SWSURFACE);
+
+ my $surf_matrix = SDLx::Surface->new( surface => $display);
+
+ $surf__matrix->[10][10] = 0xFFFF; #for 16bpp write white at x = 10 and y=10
+
+ $surf_matrix->surface( $new_surface );
+
+ my $orig_surface = $surf_matrix->surface();
+
+
+ +
+

DESCRIPTION

Top

+
+

An SDLx::Surface allows matrix read and write to a surface, safely.

+ +
+

METHODS

Top

+
+ +
+

new

+
+

Takes a SDL::Surface in hash format.

+

If a surface is passed to 'surface =>' that is loaded. Otherwise you can define at least a width and a height.

+
	SDLx::Surface->new(  surface => $surface) # The $surface is loaded
+
+	SDLx::Surface->new( width=> 400, height=>200) 
+		# A SDL::Surface->new( SDL_ANYFORMAT, 400, 200, 32) is loaded
+
+	SDLx::Surface->new( width=> 400, height=>200, flags=> SDL_SWSURFACE, depth=>24 ) 
+	  	# A SDL::Surface->new( SDL_SWSURFACE, 400, 200, 24) is loaded 
+
+	SDLx::Surface->new( width=> 400, height=>200, flags=> SDL_SWSURFACE, depth=>32, greenmask=>0xFF000000 )
+		# A SDL::Surface->new( SDL_ANYFORMAT, 400, 200, 32, 0, 0xFF000000,0, 0, 0 ) is loaded
+
+
+ +
+

surface

+
+

If a SDL::Surface is passed it is attached to the matrix. Returns the SDL::Surface that is currently attached to this SDLx::Surface

+ +
+

get_display

+
+

If SDLx::App::new or SDL::Video::get_video_mode called before then:

+
 my $appx = SDLx::Surface::get_display(); 
+
+
+

gets the display if it is already made. Passed options are ignored. Otherwise you can quickly make the display with :

+
 SDLx::Surface::get_display( width => 20, height => 20) #depth => 32 and SDL_ANYFORMAT used
+
+
+

or you can also pass flags and depth.

+
 SDLx::Surface::get_display( width => 20, height => 20, flags=> SDL_HWSURFACE, depth=>24) 
+
+
+

Get or create the main display surface and attach to a SDLx::Surface.

+ +
+

EXTENSIONS

Top

+
+ +
+

blit

+
+
 $sdlx_surface->blit( $dest, $src_rect, $dest_rect );
+
+
+

Blits SDLx::Surface onto $dest surface. +$src_rect or $dest_rect are optional. $src_rect or $dest_rect can be array refs or SDL::Rect. $dest can be SDLx::Surface or SDL::Surface.

+

Returns $self

+ +
+

flip

+
+

Applies SDL::Video::flip to the Surface, with error checking.

+

Returns $self

+ +
+

update

+
+
 $sdlx_surface->update(); # whole surface is updated
+ $sdlx_surface->update([0,0,1,1]); # only that area (0,0,1,1) is updated
+
+ $sdlx_surface->update( [ SDL::Rect->new(0,0,1,2) ... ]); # defined rects are updated
+
+
+

Applies SDL::Video::update_rect for no rect or 1 array ref. Applies SDL::Video::update_rects for array of SDL::Rects.

+

Returns $self

+ +
+

AUTHOR

Top

+
+
 kthakore 
+
+
+
+
+
+ +
+
\ No newline at end of file