lib/Game/Snake/Sprite.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 44 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 package Game::Snake::Sprite 0.11;
4 class Game::Snake::Sprite {
5 our $VERSION = 0.11;
6 use Raylib::FFI;
7 use Raylib::Color;
8  
9 field $image : param;
10 field $width : param;
11 field $height : param;
12 field $x : param;
13 field $y : param;
14
15 field $loaded;
16  
17 ADJUST {
18 my $base_path = __FILE__;
19 $base_path =~ s/(.*Snake[\/\\])(.*)/$1/;
20 $loaded = LoadTexture($base_path . $image);
21 }
22  
23 method x (@xx) {
24 $x = $xx[0] if @xx;
25 $x;
26 }
27  
28 method y (@yy) {
29 $y = $yy[0] if @yy;
30 $y;
31 }
32  
33 method width (@ww) {
34 $width = $ww[0] if @ww;
35 $width;
36 }
37  
38 method height (@hh) {
39 $height = $hh[0] if @hh;
40 $height;
41 }
42  
43 method draw ($x_pos, $y_pos, $w_pos, $h_pos) {
44 my $image = Raylib::FFI::Rectangle->new(
45 x => $x,
46 y => $y,
47 width => $width,
48 height => $height
49 );
50 my $viewport = Raylib::FFI::Rectangle->new(
51 x => $x_pos,
52 y => $y_pos,
53 width => $w_pos,
54 height => $h_pos,
55 );
56 my $vector = Raylib::FFI::Vector2D->new(
57 x => 0,
58 y => 0
59 );
60  
61 DrawTexturePro($loaded, $image, $viewport, $vector, 0, Raylib::Color::WHITE);
62 }
63 }
64  
65 =pod
66  
67 =cut