PangZero/GamePause.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 40 CC 4 SCAR 19.1
CC
4
Cov
0%
Advance
12.0
Show
6.0
new
2.0
CRAP 6.8
1 ##########################################################################
2 package Games::PangZero::GamePause;
3 ##########################################################################
4  
5 @ISA = qw(Games::PangZero::GameObject);
6  
7 sub Show {
8 foreach my $gameObject (@Games::PangZero::GameObjects) {
9 return if (ref $gameObject eq 'Games::PangZero::GamePause');
10 }
11 push @Games::PangZero::GameObjects, Games::PangZero::GamePause->new();
12 }
13  
14 sub new {
15 my ($class) = @_;
16 my $self = Games::PangZero::GameObject->new();
17 my $width = Games::PangZero::Graphics::TextWidth("Time left: 9.999");
18 %{$self} = ( %{$self},
19 'x' => ($Games::PangZero::PhysicalScreenWidth - $width) / 2,
20 'y' => 100,
21 'w' => $width,
22 'h' => 32,
23 );
24 $self->TransferRect();
25 bless $self, $class;
26 }
27  
28 sub BringToFront {
29 my $self = shift;
30  
31 @Games::PangZero::GameObjects = grep { $_ ne $self } @Games::PangZero::GameObjects;
32 push @Games::PangZero::GameObjects, ($self);
33 }
34  
35 sub Advance {
36 my $self = shift;
37  
38 if ($Games::PangZero::GamePause <= 0) {
39 $self->Delete;
40 return;
41 }
42 unless ($Games::PangZero::GameObjects[$#Games::PangZero::GameObjects] eq $self) {
43 $self->BringToFront();
44 }
45 }
46  
47 sub Draw {
48 my $self = shift;
49  
50 SDLx::SFont::print_text( $Games::PangZero::App, $self->{rect}->x, $self->{rect}->y, "Time left: " . ($Games::PangZero::GamePause / 100) );
51  
52 }
53  
54 1;