lib/Game/Floppy/Sprite.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 65 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 use 5.38.0;
2 use experimental 'class';
3  
4 package Game::Floppy::Sprite 0.08;
5 class Game::Floppy::Sprite {
6 our $VERSION = 0.08;
7 use Raylib::FFI;
8 use Raylib::Color;
9  
10 field $image : param;
11 field $width : param = undef;
12 field $height : param = undef;
13 field $x : param;
14 field $y : param;
15 field $rotate : param = 0;
16 field $total_frames : param = 0;
17  
18 field $frame = 0;
19 field $loaded;
20  
21 ADJUST {
22 my $base_path = __FILE__;
23 $base_path =~ s/(.*Floppy[\/\\])(.*)/$1/;
24 $loaded = LoadTexture($base_path . $image);
25 }
26  
27 method loaded () {
28 $loaded;
29 }
30  
31 method x (@xx) {
32 $x = $xx[0] if @xx;
33 $x;
34 }
35  
36 method y (@yy) {
37 $y = $yy[0] if @yy;
38 $y;
39 }
40  
41 method width (@ww) {
42 $width = $ww[0] if @ww;
43 $width;
44 }
45  
46 method height (@hh) {
47 $height = $hh[0] if @hh;
48 $height;
49 }
50  
51 method rotate (@rr) {
52 $rotate = $rr[0] if @rr;
53 $rotate;
54 }
55  
56 method draw ($x_pos, $y_pos, $w_pos, $h_pos) {
57 my $image = Raylib::FFI::Rectangle->new(
58 x => $x + (($width || 0) * $frame),
59 y => $y,
60 width => defined $width ? $width : $loaded->width,
61 height => defined $height ? $height : $loaded->height
62 );
63 my $viewport = Raylib::FFI::Rectangle->new(
64 x => $x_pos,
65 y => $y_pos,
66 width => $w_pos,
67 height => $h_pos,
68 );
69 my $vector = Raylib::FFI::Vector2D->new(
70 x => 0,
71 y => 0
72 );
73 DrawTexturePro($loaded, $image, $viewport, $vector, $rotate, Raylib::Color::WHITE);
74 $frame++;
75 if ($frame >= $total_frames) {
76 $frame = 0;
77 }
78  
79 }
80 }
81  
82 =pod
83  
84 =cut