lib/Game/Floppy/Bird.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 42 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::Bird 0.08;
5 class Game::Floppy::Bird {
6 our $VERSION = 0.08;
7 use Raylib::FFI;
8 use Raylib::Color;
9 use Game::Floppy::Sprite;
10  
11 field $x : param;
12 field $y : param;
13 field $width : param;
14 field $height : param;
15 field $sprite = Game::Floppy::Sprite->new(
16 image => 'resources/bluebird.png',
17 x => 0,
18 y => 0,
19 width => 34,
20 height => 24,
21 total_frames => 4
22 );
23  
24 method x (@xx) {
25 $x = $xx[0] if @xx;
26 $x;
27 }
28  
29 method y (@yy) {
30 $y = $yy[0] if @yy;
31 $y;
32 }
33  
34 method width () {
35 $width
36 }
37  
38 method sprite () {
39 $sprite;
40 }
41  
42 method position () {
43 return Raylib::FFI::Vector2D->new( x => $x, y => $y);
44 }
45  
46 method draw {
47 my $rotate = $sprite->rotate;
48 if ($rotate < 45) {
49 $rotate++;
50 $sprite->rotate($rotate);
51 }
52 $sprite->draw($x, $y, $width, $height);
53 }
54 }
55  
56 1;
57  
58 =pod
59  
60 =cut