From: Tobias Leich
Date: Tue, 6 Apr 2010 20:16:59 +0000 (+0200)
Subject: updated old docs
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1f5d808215c3e475e7d752ba28a3f2c3d6f468ad;p=sdlgit%2FSDL-Site.git
updated old docs
---
diff --git a/pages/SDL-Cookbook-PDL.html-inc b/pages/SDL-Cookbook-PDL.html-inc
index b0bd609..5d4c847 100644
--- a/pages/SDL-Cookbook-PDL.html-inc
+++ b/pages/SDL-Cookbook-PDL.html-inc
@@ -6,7 +6,6 @@
-Old SDL interface
Perl's SDL in a nutshell
SDL - power through simplicity
Example 1: Model of a 2-D Noninteracting Gas
@@ -49,11 +48,6 @@ Some of the particles can drift off the screen. This is no good. What's causing
Cookbook
-Old SDL interface
Top
-
-
Please be aware that much of the code in this example uses SDL Perl v 2.2.4. The SDL Perl developers are hard at work rewriting SDL, to be released as SDL 3.0 soon. The new version of SDL is not backwards compatible. Check back with this page after SDL 3.0 has been released to get the updated commands.
-
-
Perl's SDL in a nutshell
Top
SDL stands for Simple DirectMedia Layer. It's a cross-platform library written in C that's meant to handle all of the low-level graphics and sound stuff. You can read more about SDL here: http://www.libsdl.org/. Because SDL is focused on game programming, it has a raw but clean feel to it. We will focus for now on using SDL to handle images for us. Handling sound may some day be the focus of another chapter.
@@ -73,6 +67,7 @@ Some of the particles can drift off the screen. This is no good. What's causing
use SDL::App;
use SDL::Rect;
use SDL::Color;
+ use SDL::Video;
# User defined pen-nib size.
my $nib_size = 3;
@@ -87,18 +82,19 @@ Some of the particles can drift off the screen. This is no good. What's causing
# our nib will be white
my $nib_color = SDL::Color->new(
- -r => 0xff,
- -g => 0xff,
- -b => 0xff,
+ 0xff, #r
+ 0xff, #b
+ 0xff, #g
);
# and our nib will be represented by a rectangle
# (Alternatively, you could use an image, which would allow
# for pretty anti-aliasing if you created it in GIMP with
# antialiasing)
- my $nib = SDL::Rect->new(
- -height => $nib_size,
- -width => $nib_size,
+ my $nib = SDL::Rect->new(
+ 0 , 0, #x, y
+ $nib_size, #w
+ $nib_size, #h
);
# now draw a sine wave (wthout covering up previously drawn rectangles)
@@ -108,12 +104,12 @@ Some of the particles can drift off the screen. This is no good. What's causing
$nib->x( $t * 8 );
$nib->y( sin($t) * 80 + 240 );
- $app->fill( $nib, $nib_color );
+ SDL::Video::fill_rect($app, $nib, $nib_color );
}
# Generally use the update command, but if you want to update the whole
# surface, use flip
- $app->flip()
+ SDL::Video::fill_rect($app,)
sleep 5;
@@ -162,18 +158,19 @@ Some of the particles can drift off the screen. This is no good. What's causing
use SDL::App;
use SDL::Rect;
use SDL::Color;
+ use SDL::Video;
# Create the SDL App
my $app = SDL::App->new( -width => $side_length, -height => $side_length,
-title => "Simple Simulation!", -depth => 16, );
# white particles on a black background
- my $particle_color = SDL::Color->new( -r => 0xff, -g => 0xff, -b => 0xff, );
- my $bg_color = SDL::Color->new( -r => 0x00, -g => 0x00, -b => 0x00, );
+ my $particle_color = SDL::Color->new( 0xff, 0xff, 0xff, );
+ my $bg_color = SDL::Color->new( 0x00, 0x00, 0x00 );
# rectangles for the particles and the background
- my $particle = SDL::Rect->new( -height => 5, -width => 5, );
- my $bg = SDL::Rect->new( -height => $side_length, -width => $side_length, );
+ my $particle = SDL::Rect->new( 0,0, 5, 5);
+ my $bg = SDL::Rect->new( 0,0,$side_length, $side_length, );
Hopefully this is straightforward code. We pull in our library dependencies and then create a few objects with the necessary properties. Finally, we get to the actual application loop:
@@ -183,13 +180,13 @@ Some of the particles can drift off the screen. This is no good. What's causing
compute();
# Clean the canvas
- $app->fill( $bg, $bg_color);
+ SDL::Video::fill_rect($app, $bg, $bg_color);
for(my $i = 0; $i < $numb_of_atoms; $i++) {
$particle->x( $positions->at(0,$i) );
$particle->y( $positions->at(1,$i) );
- $app->fill( $particle, $particle_color );
+ SDL::Video::fill_rect($app, $particle, $particle_color );
}
- $app->flip();
+ SDL::Video::flip($app);
$app->delay(10);
}
@@ -246,9 +243,9 @@ Some of the particles can drift off the screen. This is no good. What's causing
for(my $i = 0; $i < $numb_of_atoms; $i++) {
$particle->x( $positions->at(0,$i) );
$particle->y( $positions->at(1,$i) );
- $particle->height( $particle_size );
- $particle->width( $particle_size );
- $app->fill( $particle, $particle_color );
+ $particle->h( $particle_size );
+ $particle->w( $particle_size );
+ SDL::Video::fill_rect($app, $particle, $particle_color );
}
@@ -386,31 +383,32 @@ Some of the particles can drift off the screen. This is no good. What's causing
use SDL::App;
use SDL::Rect;
use SDL::Color;
+ use SDL::Video;
# Create the SDL App
my $app = SDL::App->new( -width => $side_length, -height => $side_length,
-title => "Simple Simulation!", -depth => 16, );
# white particles on a black background
- my $particle_color = SDL::Color->new( -r => 0xff, -g => 0xff, -b => 0xff, );
- my $bg_color = SDL::Color->new( -r => 0x00, -g => 0x00, -b => 0x00, );
+ my $particle_color = SDL::Color->new( 0xff, 0xff, 0xff, );
+ my $bg_color = SDL::Color->new( 0x00, 0x00, 0x00 );
# rectangles for the particles and the background
- my $particle = SDL::Rect->new( -height => 5, -width => 5, );
- my $bg = SDL::Rect->new( -height => $side_length, -width => $side_length, );
+ my $particle = SDL::Rect->new( 0,0, 5, 5);
+ my $bg = SDL::Rect->new( 0,0,$side_length, $side_length, );
# Run the simulation
for(my $t = 0; $t < 20; $t += $d_t) {
MyCompute::compute();
# Clean the canvas
- $app->fill( $bg, $bg_color);
+ SDL::Video::fill_rect($app, $bg, $bg_color);
for(my $i = 0; $i < $numb_of_atoms; $i++) {
$particle->x( $positions->at(0,$i) );
$particle->y( $positions->at(1,$i) );
- $app->fill( $particle, $particle_color );
+ SDL::Video::fill_rect($app, $particle, $particle_color );
}
- $app->flip();
+ SDL::Video::flip($app);
$app->delay(10);
}
@@ -421,7 +419,8 @@ Some of the particles can drift off the screen. This is no good. What's causing
Listening to Events
To respond to user interactions, we have to listen to user events using an SDL::Event object. So first, add this line with our other use statements:
-
use SDL::Event;
+ use SDL::Event;
+ use SDL::Events;
and then be sure to create an event object amongst the animation initialization code:
@@ -434,14 +433,14 @@ Some of the particles can drift off the screen. This is no good. What's causing
MyCompute::compute();
# Clean the canvas
- $app->fill( $bg, $bg_color);
+ SDL::Video::fill_rect($app, $bg, $bg_color);
for(my $i = 0; $i < $numb_of_atoms; $i++) {
$particle->x( $positions->at(0,$i) );
$particle->y( $positions->at(1,$i) );
- $app->fill( $particle, $particle_col10);
+ SDL::Video::fill_rect($app, $particle, $particle_col10);
- while($event->poll()) {
- if($event->type() =head1 SDL_QUIT) {
+ while(SDL::Events::poll_event($event) ) {
+ if($event->type() == SDL_QUIT) {
exit;
}
}
@@ -467,14 +466,14 @@ Some of the particles can drift off the screen. This is no good. What's causing
sub incr_particle_size {
$particle_size++;
- $particle->height($particle_size);
- $particle->width($particle_size);
+ $particle->h($particle_size);
+ $particle->w($particle_size);
}
sub decr_particle_size {
$particle_size-- if $particle_size > 1;
- $particle->height($particle_size);
- $particle->width($particle_size);
+ $particle->h($particle_size);
+ $particle->w($particle_size);
}
@@ -485,21 +484,21 @@ Some of the particles can drift off the screen. This is no good. What's causing
MyCompute::compute();
# Clean the canvas
- $app->fill( $bg, $bg_color);
+ SDL::Video::fill_rect($app, $bg, $bg_color);
for(my $i = 0; $i < $numb_of_atoms; $i++) {
$particle->x( $positions->at(0,$i) );
$particle->y( $positions->at(1,$i) );
- $app->fill( $particle, $particle_color );
+ SDL::Video::fill_rect($app, $particle, $particle_color );
}
- $app->flip();
+ SDL::Video::flip($app);
$app->delay(10);
- while($event->poll()) {
- if($event->type() =head1 SDL_QUIT) {
+ while(SDL::Events::poll_event($event) ) {
+ if($event->type() == SDL_QUIT) {
exit;
- } elsif($event->type() =head1 SDL_KEYDOWN) {
- if(exists $keyname_dispatch_table->{$event->key_name()}) {
- $keyname_dispatch_table->{$event->key_name()}->();
+ } elsif($event->type() == SDL_QUIT) {
+ if(exists $keyname_dispatch_table->{$event->keysym_name()}) {
+ $keyname_dispatch_table->{$event->keysym_name()}->();
}
}
}
@@ -563,22 +562,24 @@ Some of the particles can drift off the screen. This is no good. What's causing
use SDL::App;
use SDL::Rect;
use SDL::Color;
- use SDL::Event;
+ use SDL::Video;
+ use SDL::Event;
+ use SDL::Events;
# Create the SDL App
my $app = SDL::App->new( -width => $side_length, -height => $side_length,
-title => "Simple Simulation!", -depth => 16, );
# white particles on a black background
- my $particle_color = SDL::Color->new( -r => 0xff, -g => 0xff, -b => 0xff, );
- my $bg_color = SDL::Color->new( -r => 0x00, -g => 0x00, -b => 0x00, );
+ my $particle_color = SDL::Color->new( 0xff, 0xff, 0xff, );
+ my $bg_color = SDL::Color->new( 0x00, 0x00, 0x00 );
# rectangles for the particles and the background
- my $particle = SDL::Rect->new( -height => 5, -width => 5, );
- my $bg = SDL::Rect->new( -height => $side_length, -width => $side_length, );
+ my $particle = SDL::Rect->new( 0,0, 5, 5);
+ my $bg = SDL::Rect->new( 0,0,$side_length, $side_length, );
# event listener
- my $event = new SDL::Event;
+ my $event = new SDL::Event->new();
# event dispatch table
my $keyname_dispatch_table = {
@@ -592,14 +593,14 @@ Some of the particles can drift off the screen. This is no good. What's causing
sub incr_particle_size {
$particle_size++;
- $particle->height($particle_size);
- $particle->width($particle_size);
+ $particle->h($particle_size);
+ $particle->w($particle_size);
}
sub decr_particle_size {
$particle_size-- if $particle_size > 1;
- $particle->height($particle_size);
- $particle->width($particle_size);
+ $particle->h($particle_size);
+ $particle->w($particle_size);
}
@@ -610,21 +611,21 @@ Some of the particles can drift off the screen. This is no good. What's causing
MyCompute::compute();
# Clean the canvas
- $app->fill( $bg, $bg_color);
+ SDL::Video::fill_rect($app, $bg, $bg_color);
for(my $i = 0; $i < $numb_of_atoms; $i++) {
$particle->x( $positions->at(0,$i) );
$particle->y( $positions->at(1,$i) );
- $app->fill( $particle, $particle_color );
+ SDL::Video::fill_rect($app, $particle, $particle_color );
}
- $app->flip();
+ SDL::Video::flip($app);
$app->delay(10);
- while($event->poll()) {
- if($event->type() =head1 SDL_QUIT) {
+ while(SDL::Events::poll_event($event) ) {
+ if($event->type() == SDL_QUIT) {
exit;
- } elsif($event->type() =head1 SDL_KEYDOWN) {
- if(exists $keyname_dispatch_table->{$event->key_name()}) {
- $keyname_dispatch_table->{$event->key_name()}->();
+ } elsif($event->type() == SDL_QUIT) {
+ if(exists $keyname_dispatch_table->{$event->keysym_name()}) {
+ $keyname_dispatch_table->{$event->keysym_name()}->();
}
}
}
diff --git a/pages/SDL-Cookbook.html-inc b/pages/SDL-Cookbook.html-inc
index 0c17238..409930d 100644
--- a/pages/SDL-Cookbook.html-inc
+++ b/pages/SDL-Cookbook.html-inc
@@ -5,35 +5,6 @@
First Steps
-
-
-
Overview
-
-
-
-
Installation
-
-
-
-
Tutorial
-
-
-
-
Core SDL Layer
-
-
-
-
Video
-
-
-
-
Events
-
-
-
-
Audio
-
-
-
-
Mixer
-
-
-
-
Images
-
-
-
-
BMP
-
-
-
-
Image extensions
-
-
-
-
Text
-
-
-
-
TTF
-
-
-
-
Pango
-
-
-
-
-
-
GFX
-
-
-
-
OpenGL
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
see SDL::Tutorial
+
\ No newline at end of file
diff --git a/pages/SDL-Tutorial-Animation.html-inc b/pages/SDL-Tutorial-Animation.html-inc
index a9da727..de815d6 100644
--- a/pages/SDL-Tutorial-Animation.html-inc
+++ b/pages/SDL-Tutorial-Animation.html-inc
@@ -69,9 +69,9 @@ representing the whole of the background surface and a new SDL::Color
{
my ($app, %args) = @_;
- $app->fill( $args{ bg }, $args{ bg_color } );
- $app->fill( $args{rect}, $args{rect_color} );
- $app->update( $args{bg} );
+ SDL::Video::fill_rect($app, $args{bg}, $args{bg_color} );
+ SDL::Video::fill_rect($app, $args{rect}, $args{rect_color} );
+ SDL::Video::update_rects($app, $args{bg} );
}
@@ -118,9 +118,10 @@ figure out the rectangle of the correct size to update()
. No thank
{
my ($app, %args) = @_;
- $app->fill( $args{old_rect}, $args{bg_color} );
- $app->fill( $args{rect], $args{rect_color} );
- $app->update( $args{old_rect}, $args{rect} );
+ SDL::Video::fill_rect($app, $args{old_rect}, $args{bg_color} );
+ SDL::Video::fill_rect($app, $args{rect}, $args{rect_color} );
+ SDL::Video::update_rects($app, $args{old_rect} );
+ SDL::Video::update_rects($app, $args{rect} );
}
@@ -169,6 +170,7 @@ them soon.
AUTHOR
Top
chromatic, <chromatic@wgz.org>
+
updated by kthakore, <kthakore@cpan.org>
Written for and maintained by the Perl SDL project, http://sdl.perl.org/.
diff --git a/pages/SDL-Tutorial-LunarLander.html-inc b/pages/SDL-Tutorial-LunarLander.html-inc
index a20a1fd..3d8d77e 100644
--- a/pages/SDL-Tutorial-LunarLander.html-inc
+++ b/pages/SDL-Tutorial-LunarLander.html-inc
@@ -214,10 +214,12 @@ this tutorial; Save these images in a subdirectory called "images":
First step: use the required libraries:
-
use SDL; #needed to get all constants
- use SDL::App;
- use SDL::Surface;
- use SDL::Rect;
+ use SDL; #needed to get all constants
+ use SDL::Video;
+ use SDL::App;
+ use SDL::Surface;
+ use SDL::Rect;
+ use SDL::Image;
@@ -234,44 +236,41 @@ this tutorial; Save these images in a subdirectory called "images":
Third step: load the images and create the necessary "rectangles":
- my $background = SDL::Surface->new( -name => 'images/background.jpg', );
- my $ship = SDL::Surface->new( -name => 'images/ship.png', );
+ my $background = SDL::Image::load('images/background.jpg');
+ my $ship = SDL::Image::load('images/ship.jpg');
- my $background_rect = SDL::Rect->new(
- -height => $background->height(),
- -width => $background->width(),
- );
+ my $background_rect = SDL::Rect->new(0,0,
+ $background->w,
+ $background->h,
+ );
- my $ship_rect = SDL::Rect->new(
- -height => $ship->height(),
- -width => $ship->width(),
- );
+ my $ship_rect = SDL::Rect->new(0,0,
+ $ship->w,
+ $ship->h,
+ );
Fourth step: create a sub to draw the spaceship and background:
- sub draw {
- my ( $x, $y ) = @_; # spaceship position
+ sub draw {
+ my ( $x, $y ) = @_; # spaceship position
- # fix $y for screen resolution
- $y = 450 * ( 1000 - $y ) / 1000;
+ # fix $y for screen resolution
+ $y = 450 * ( 1000 - $y ) / 1000;
- # background
- $background->blit( $background_rect, $app, $background_rect );
+ # background
+ SDL::Video::blit_surface($background, $background_rect, $app, $background_rect );
- # ship
- my $ship_dest_rect = SDL::Rect->new(
- -height => $ship->height(),
- -width => $ship->width(),
- -x => $x,
- -y => $y,
- );
+ # ship
+ my $ship_dest_rect = SDL::Rect->new(
+ $x, $y, $ship->w, $ship->h,
+ );
- $ship->blit( $ship_rect, $app, $ship_dest_rect );
+ SDL::Video::blit_surface($ship, $ship_rect, $app, $ship_dest_rect );
- $app->update($background_rect);
- }
+ SDL::Video::update_rects($app, $background_rect);
+ }
diff --git a/pages/SDL-Tutorial.html-inc b/pages/SDL-Tutorial.html-inc
index a5b8dcf..d996720 100644
--- a/pages/SDL-Tutorial.html-inc
+++ b/pages/SDL-Tutorial.html-inc
@@ -106,30 +106,28 @@ them there, then update
the $app
.
SEE ALSO
Top
- - SDL::Tutorial::Drawing
+ - SDL::Animation
-
-
basic drawing with rectangles
+ basic rectangle drawing and animation
- - SDL::Tutorial::Animation
+ - SDL::Tutorial::LunarLander
-
-
basic rectangle animation
-
- - SDL::Tutorial::Images
- -
-
image loading and animation
+ basic image loading and animation
AUTHOR
Top
-
chromatic, <chromatic@wgz.org>.
+
chromatic, <chromatic@wgz.org>.
+
nelson ferraz, <nferraz@cpan.org>.
+
Updated by kthakore and garu.
Written for and maintained by the Perl SDL project, http://sdl.perl.org/.
COPYRIGHT
Top
-
Copyright (c) 2003 - 2004, chromatic. All rights reserved. This module is
+
Copyright (c) 2003 - 2004, chromatic. 2009 - 2010, kthakore. 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.
diff --git a/pages/documentation.html-inc b/pages/documentation.html-inc
index 092f910..4892dde 100644
--- a/pages/documentation.html-inc
+++ b/pages/documentation.html-inc
@@ -1,2 +1,2 @@