Term::Caca::Sprite - an OO-interface to caca_sprite


Term-Caca documentation Contained in the Term-Caca distribution.

Index


Code Index:

NAME

Top

Term::Caca::Sprite - an OO-interface to caca_sprite

SYNOPSIS

Top

Basic usage

  use Term::Caca::Sprite;
  eval {
    my $sprite = Term::Caca::Sprite->new('/tmp/sprite.txt');
    my ($x, $y, $frame) = (8, 20, 0);
    $sprite->draw($x, $y, $frame);
  };
  # The destructor will take care of releasing memory.

DESCRIPTION

Top

a brief summary of the module written with users in mind.

METHODS

Top

new

...

Example:

load

The load() method is a synonym for new() and they can be used interchangably.

get_frames

...

Example:

get_width

...

Example:

get_height

...

Example:

get_dx

...

Example:

get_dy

...

Example:

draw

...

Example:

DESTROY

...

Example:

CLASS VARIABLES

Top

cvars

DIAGNOSTICS

Top

no errors

AUTHOR

Top

John BEPPU <beppu@cpan.org>

SEE ALSO

Top

perl(1)


Term-Caca documentation Contained in the Term-Caca distribution.

package Term::Caca::Sprite;

use strict;
use warnings;
use Term::Caca;

sub new {
  my ($class, $file) = @_;
  my $self = Term::Caca::_load_sprite($file);
  return bless($self => $class);
}

*load = \*new;

sub get_frames {
  my ($self) = @_;
  return Term::Caca::_get_sprite_frames($self);
}

sub get_width {
  my ($self, $frame) = @_;
  return Term::Caca::_get_sprite_width($self, $frame);
}

sub get_height {
  my ($self, $frame) = @_;
  return Term::Caca::_get_sprite_height($self, $frame);
}

sub get_dx {
  my ($self, $frame) = @_;
  return Term::Caca::_get_sprite_dx($self, $frame);
}

sub get_dy {
  my ($self, $frame) = @_;
  return Term::Caca::_get_sprite_dy($self, $frame);
}

sub draw {
  my ($self, $x, $y, $frame) = @_;
  Term::Caca::_draw_sprite($x, $y, $self, $frame);
}

sub DESTROY {
  my ($self) = @_;
  Term::Caca::_free_sprite($self);
}

1;

__END__

# $Id$