| 1 | package Term::Caca::Sprite; | ||
| 2 | our $AUTHORITY = 'cpan:YANICK'; | ||
| 3 | #ABSTRACT: an OO-interface to caca_sprite | ||
| 4 | $Term::Caca::Sprite::VERSION = '3.1.0'; | ||
| 5 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 0 | ▶ | use Term::Caca; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 8 | |||
| 9 | sub new { | ||
| 10 | my ($class, $file) = @_; | ||
| 11 | my $self = Term::Caca::_load_sprite($file); | ||
| 12 | return bless($self => $class); | ||
| 13 | } | ||
| 14 | |||
| 15 | *load = \*new; | ||
| 16 | |||
| 17 | sub get_frames { | ||
| 18 | my ($self) = @_; | ||
| 19 | return Term::Caca::_get_sprite_frames($self); | ||
| 20 | } | ||
| 21 | |||
| 22 | sub get_width { | ||
| 23 | my ($self, $frame) = @_; | ||
| 24 | return Term::Caca::_get_sprite_width($self, $frame); | ||
| 25 | } | ||
| 26 | |||
| 27 | sub get_height { | ||
| 28 | my ($self, $frame) = @_; | ||
| 29 | return Term::Caca::_get_sprite_height($self, $frame); | ||
| 30 | } | ||
| 31 | |||
| 32 | sub get_dx { | ||
| 33 | my ($self, $frame) = @_; | ||
| 34 | return Term::Caca::_get_sprite_dx($self, $frame); | ||
| 35 | } | ||
| 36 | |||
| 37 | sub get_dy { | ||
| 38 | my ($self, $frame) = @_; | ||
| 39 | return Term::Caca::_get_sprite_dy($self, $frame); | ||
| 40 | } | ||
| 41 | |||
| 42 | sub draw { | ||
| 43 | my ($self, $x, $y, $frame) = @_; | ||
| 44 | Term::Caca::_draw_sprite($x, $y, $self, $frame); | ||
| 45 | } | ||
| 46 | |||
| 47 | sub DESTROY { | ||
| 48 | my ($self) = @_; | ||
| 49 | Term::Caca::_free_sprite($self); | ||
| 50 | } | ||
| 51 | |||
| 52 | 1; | ||
| 53 | |||
| 54 | =pod | ||
| 55 | |||
| 56 | =encoding UTF-8 | ||
| 57 | |||
| 58 | =head1 NAME | ||
| 59 | |||
| 60 | Term::Caca::Sprite - an OO-interface to caca_sprite | ||
| 61 | |||
| 62 | =head1 VERSION | ||
| 63 | |||
| 64 | version 3.1.0 | ||
| 65 | |||
| 66 | =head1 SYNOPSIS | ||
| 67 | |||
| 68 | Basic usage | ||
| 69 | |||
| 70 | use Term::Caca::Sprite; | ||
| 71 | eval { | ||
| 72 | my $sprite = Term::Caca::Sprite->new('/tmp/sprite.txt'); | ||
| 73 | my ($x, $y, $frame) = (8, 20, 0); | ||
| 74 | $sprite->draw($x, $y, $frame); | ||
| 75 | }; | ||
| 76 | # The destructor will take care of releasing memory. | ||
| 77 | |||
| 78 | =head1 DESCRIPTION | ||
| 79 | |||
| 80 | a brief summary of the module written with users in mind. | ||
| 81 | |||
| 82 | =head1 METHODS | ||
| 83 | |||
| 84 | =head2 new | ||
| 85 | |||
| 86 | ... | ||
| 87 | |||
| 88 | B<Example>: | ||
| 89 | |||
| 90 | =head2 load | ||
| 91 | |||
| 92 | The load() method is a synonym for new() and they | ||
| 93 | can be used interchangably. | ||
| 94 | |||
| 95 | =head2 get_frames | ||
| 96 | |||
| 97 | ... | ||
| 98 | |||
| 99 | B<Example>: | ||
| 100 | |||
| 101 | =head2 get_width | ||
| 102 | |||
| 103 | ... | ||
| 104 | |||
| 105 | B<Example>: | ||
| 106 | |||
| 107 | =head2 get_height | ||
| 108 | |||
| 109 | ... | ||
| 110 | |||
| 111 | B<Example>: | ||
| 112 | |||
| 113 | =head2 get_dx | ||
| 114 | |||
| 115 | ... | ||
| 116 | |||
| 117 | B<Example>: | ||
| 118 | |||
| 119 | =head2 get_dy | ||
| 120 | |||
| 121 | ... | ||
| 122 | |||
| 123 | B<Example>: | ||
| 124 | |||
| 125 | =head2 draw | ||
| 126 | |||
| 127 | ... | ||
| 128 | |||
| 129 | B<Example>: | ||
| 130 | |||
| 131 | =head2 DESTROY | ||
| 132 | |||
| 133 | ... | ||
| 134 | |||
| 135 | B<Example>: | ||
| 136 | |||
| 137 | =head1 CLASS VARIABLES | ||
| 138 | |||
| 139 | cvars | ||
| 140 | |||
| 141 | =head1 DIAGNOSTICS | ||
| 142 | |||
| 143 | no errors | ||
| 144 | |||
| 145 | =head1 AUTHOR | ||
| 146 | |||
| 147 | John BEPPU E<lt>beppu@cpan.orgE<gt> | ||
| 148 | |||
| 149 | =head1 SEE ALSO | ||
| 150 | |||
| 151 | perl(1) | ||
| 152 | |||
| 153 | =head1 AUTHORS | ||
| 154 | |||
| 155 | =over 4 | ||
| 156 | |||
| 157 | =item * | ||
| 158 | |||
| 159 | John Beppu <beppu@cpan.org> | ||
| 160 | |||
| 161 | =item * | ||
| 162 | |||
| 163 | Yanick Champoux <yanick@cpan.org> | ||
| 164 | |||
| 165 | =back | ||
| 166 | |||
| 167 | =head1 COPYRIGHT AND LICENSE | ||
| 168 | |||
| 169 | This software is Copyright (c) 2019, 2018, 2013, 2011 by John Beppu. | ||
| 170 | |||
| 171 | This is free software, licensed under: | ||
| 172 | |||
| 173 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE, Version 2, December 2004 | ||
| 174 | |||
| 175 | =cut | ||
| 176 | |||
| 177 | __END__ | ||