lib/Game/Floppy/Tube.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 48 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::Tube 0.08;
5 class Game::Floppy::Tube {
6 our $VERSION = 0.08;
7 use Raylib::FFI;
8 use Game::Floppy::Sprite;
9 field $x : param;
10 field $y : param;
11 field $width : param;
12 field $height : param;
13 field $top = Game::Floppy::Sprite->new(
14 image => 'resources/pipe-green.png',
15 x => 0,
16 y => 0,
17 rotate => 180,
18 );
19 field $bottom = Game::Floppy::Sprite->new(
20 image => 'resources/pipe-green.png',
21 x => 0,
22 y => 0,
23 );
24 field $active = 1;
25  
26 method width () {
27 $width;
28 }
29  
30 method x (@xx) {
31 $x = $xx[0] if @xx;
32 $x;
33 }
34  
35 method active (@act) {
36 $active = $act[0] if @act;
37 $active;
38 }
39
40 method top_rectangle () {
41 return Raylib::FFI::Rectangle->new(
42 x => $x,
43 y => $y,
44 width => $top->loaded->width,
45 height => $top->loaded->height - $height - 20
46 );
47 }
48  
49 method bottom_rectangle () {
50 return Raylib::FFI::Rectangle->new(
51 x => $x,
52 y => ($y + $top->loaded->height - $height) + 120,
53 width => $bottom->loaded->width,
54 height => $bottom->loaded->height
55 );
56 }
57  
58 method check_collision ($floppy) {
59 return 1 if CheckCollisionCircleRec($floppy->position, $floppy->width, $_->top_rectangle) || CheckCollisionCircleRec($floppy->position, $floppy->width, $_->bottom_rectangle);
60 return 0;
61 }
62  
63 method draw {
64 $top->draw($x + $top->loaded->width, $y + $top->loaded->height - $height, $top->loaded->width, $top->loaded->height);
65 $bottom->draw($x, ($y + $top->loaded->height - $height) + 100, $bottom->loaded->width, $bottom->loaded->height);
66 }
67 }
68  
69 =pod
70  
71 =cut