Meta::Widget::Gtk::Sprite 0.01
Sponsored Links
Meta::Widget::Gtk::Sprite 0.01 Ranking & Summary
File size:
0.008 MB
Platform:
Any Platform
License:
Perl Artistic License
Price:
Downloads:
1201
Date added:
2006-07-11
Publisher:
Jeremy Price
Meta::Widget::Gtk::Sprite 0.01 description
Meta::Widget::Gtk::Sprite is a Perl module to do C64 style sprites.
SYNOPSIS
use Gtk;
use Gnome;
init Gnome "test.pl";
use Meta::Widget::Gtk::Sprite;
my $mw = new Gtk::Window( "toplevel" );
my($canvas) = Gnome::Canvas->new() ;
$mw->add($canvas );
$canvas->show;
my $croot = $canvas->root;
my $sprites = new Meta::Widget::Gtk::Sprite($croot);
my $p1 = $sprites->create("./player1.xpm", 100, 0);
$sprites->slide_to_time($p1,5000, 100, 100);
my $p2 = $sprites->create("./player2.xpm", 0, 0);
$sprites->slide_to_speed($p2,10, 100, 100);
$sprites->set_collision_handler(&Bang);
$mw->show;
Gtk->main;
sub Bang
{
print "Bang!n";
exit;
}
Sprite is a module to bring back the simple graphics programming of the C64 (hopefully without the lookslikearse component). You can declare pictures to be sprites on the canvas, and then move them around and crash them into each other.
NOTE
The canvas is the Gnome::Canvas object. You have to have a Gtk::Canvas object before starting Sprite.
METHODS
new Meta::Widget::Gtk::Sprite( $canvas_root );
The new method takes one argument, the canvas root object for the canvas you want to draw on.
You may obtain the canvas root from your canvas like this:
my $croot = $canvas->root;
$sprite_number = $sprites->create("/path/to/filename", 10, 20);
Create will load an image file (right now, only xpm format) from disk and make a sprite out of it. The two numbers are the x and y position on the canvas.
$sprites->show( $sprite_number );
Makes the sprite appear on the canvas
$sprites->hide( $sprite_number );
Make the sprite picture disappear from the canvas. Note that it can still collide with other sprites. If you dont want it to hit anything, move it out of the way or ignore it in your own collision handler.
$sprites->destroy( $sprite_number );
Completely destroys a sprite.
$sprites->move_to( $sprite_number, 10, 20 );
Teleports the sprite named in $sprite_number to the position given immediately. Contrast slide_to_xxx functions.
$sprites->slide_to_time( $sprite_number, $time, 10, 20 );
Will make the sprite $sprite_number slide across the canvas to the position 10, 20. It will take $time seconds to do so. Slow speeds will appear jerky.
$sprites->slide_to_speed( $sprite_number, $speed, 10, 20);
Will slide the sprite $sprite_number to the position 10, 20. It will move at a speed of $speed pixels per second.
$sprites->pos( $sprite_number);
Returns the x and y coordinates of $sprite_number
$sprites->velocity( $sprite_number, 5, 6);
Sets the speed of $sprite_number. The numbers are the x and y speeds. Negative numbers will make the sprite go backwards.
$sprites->set_collision_handler ( &collision_handler );
Name a function that will be called when two sprites collide. Note that the collision detection system is extremely crappy right now. It turns out that it is very difficult to efficiently detect collisions.
Your function will be called like this:
collision_handler( $sprite_number, $sprite_number);
where the two sprite numbers are the two sprites that collided. Multiple sprites colliding will cause many collision handler callbacks.
Note well that if you set the collision handler Sprite.pm will check every single sprite for collisions every animation loop. I havent optimised this, so you will notice a massive slowdown as you add more sprites.
To switch collisions checking off, set the handler to undef:
$sprites->set_collision_handler ( undef );
SYNOPSIS
use Gtk;
use Gnome;
init Gnome "test.pl";
use Meta::Widget::Gtk::Sprite;
my $mw = new Gtk::Window( "toplevel" );
my($canvas) = Gnome::Canvas->new() ;
$mw->add($canvas );
$canvas->show;
my $croot = $canvas->root;
my $sprites = new Meta::Widget::Gtk::Sprite($croot);
my $p1 = $sprites->create("./player1.xpm", 100, 0);
$sprites->slide_to_time($p1,5000, 100, 100);
my $p2 = $sprites->create("./player2.xpm", 0, 0);
$sprites->slide_to_speed($p2,10, 100, 100);
$sprites->set_collision_handler(&Bang);
$mw->show;
Gtk->main;
sub Bang
{
print "Bang!n";
exit;
}
Sprite is a module to bring back the simple graphics programming of the C64 (hopefully without the lookslikearse component). You can declare pictures to be sprites on the canvas, and then move them around and crash them into each other.
NOTE
The canvas is the Gnome::Canvas object. You have to have a Gtk::Canvas object before starting Sprite.
METHODS
new Meta::Widget::Gtk::Sprite( $canvas_root );
The new method takes one argument, the canvas root object for the canvas you want to draw on.
You may obtain the canvas root from your canvas like this:
my $croot = $canvas->root;
$sprite_number = $sprites->create("/path/to/filename", 10, 20);
Create will load an image file (right now, only xpm format) from disk and make a sprite out of it. The two numbers are the x and y position on the canvas.
$sprites->show( $sprite_number );
Makes the sprite appear on the canvas
$sprites->hide( $sprite_number );
Make the sprite picture disappear from the canvas. Note that it can still collide with other sprites. If you dont want it to hit anything, move it out of the way or ignore it in your own collision handler.
$sprites->destroy( $sprite_number );
Completely destroys a sprite.
$sprites->move_to( $sprite_number, 10, 20 );
Teleports the sprite named in $sprite_number to the position given immediately. Contrast slide_to_xxx functions.
$sprites->slide_to_time( $sprite_number, $time, 10, 20 );
Will make the sprite $sprite_number slide across the canvas to the position 10, 20. It will take $time seconds to do so. Slow speeds will appear jerky.
$sprites->slide_to_speed( $sprite_number, $speed, 10, 20);
Will slide the sprite $sprite_number to the position 10, 20. It will move at a speed of $speed pixels per second.
$sprites->pos( $sprite_number);
Returns the x and y coordinates of $sprite_number
$sprites->velocity( $sprite_number, 5, 6);
Sets the speed of $sprite_number. The numbers are the x and y speeds. Negative numbers will make the sprite go backwards.
$sprites->set_collision_handler ( &collision_handler );
Name a function that will be called when two sprites collide. Note that the collision detection system is extremely crappy right now. It turns out that it is very difficult to efficiently detect collisions.
Your function will be called like this:
collision_handler( $sprite_number, $sprite_number);
where the two sprite numbers are the two sprites that collided. Multiple sprites colliding will cause many collision handler callbacks.
Note well that if you set the collision handler Sprite.pm will check every single sprite for collisions every animation loop. I havent optimised this, so you will notice a massive slowdown as you add more sprites.
To switch collisions checking off, set the handler to undef:
$sprites->set_collision_handler ( undef );
Meta::Widget::Gtk::Sprite 0.01 Screenshot
Advertisements
Meta::Widget::Gtk::Sprite 0.01 Keywords
Sprite 0.01
X and Y
Perl module
sprite
number
canvas
sprites
handler
collision
Meta::Widget::Gtk::Sprite
MetaWidgetGtkSprite
Meta::Widget::Gtk::Sprite 0.01
Libraries
Programming
Bookmark Meta::Widget::Gtk::Sprite 0.01
Meta::Widget::Gtk::Sprite 0.01 Copyright
WareSeeker periodically updates pricing and software information of Meta::Widget::Gtk::Sprite 0.01 full version from the publisher, so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of Meta::Widget::Gtk::Sprite 0.01 Edition. Download links are directly from our publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed
Featured Software
Want to place your software product here?
Please contact us for consideration.
Contact WareSeeker.com
Related Information
game sprites
pokemon sprites
sprite industries
sprite airline
sprites inc
sonic sprites
when was sprite invented
sprite soda
megaman sprites
mario sprites
banned sprite commercial
properties of sprite soda
Fairy
is a sprite bottle a pet bottle
sprite ingredients
video game sprites
sprite sheets
naruto sprites
Related Software
MfGames.Sprite is a library for loading, managing, and rendering sprites from JPEG, PNG, and SVG files. Free Download
Micro Window-Gadgets is a lightweight gadget/windowing toolkit for C and X11. Free Download
Sprite is a Perl module to manipulate text delimited databases using SQL. Free Download
Number::Interval is a Perl module that can implement a representation of a numeric interval. Free Download
gtk-theme-prefs is a simple GTK+ theme manager. Free Download
XMLNews::HTMLTemplate is Perl module for converting NITF to HTML. Free Download
Text::VisualWidth is a Perl module that provides functions to treat half-width and full-width characters. Free Download
λgtk is a cross-platform Lisp interface to the complete GTK+2 family of shared libraries. Free Download
Latest Software
Popular Software
Favourite Software