/usr/lib/perl5/SDLx/Controller/Timer.pm is in libsdl-perl 2.540-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | package SDLx::Controller::Timer;
# Implementation of lesson 13 and 14 from http://lazyfoo.net/SDL_tutorials/index.php
#
use strict;
use warnings;
use SDL;
sub new {
my $class = shift;
my $self = bless {@_}, $class;
$self->{started_ticks} = 0;
$self->{paused_ticks} = 0;
$self->{started} = 0;
$self->{paused} = 0;
return $self;
}
sub start {
my $self = shift;
$self->{started} = 1;
$self->{started_ticks} = SDL::get_ticks();
}
sub stop {
my $self = shift;
$self->{started} = 0;
$self->{paused} = 0;
}
sub pause {
my $self = shift;
if ( $self->{started} && !$self->{paused} ) {
$self->{paused} = 1;
$self->{paused_ticks} = SDL::get_ticks() - $self->{started_ticks};
}
}
sub unpause {
my $self = shift;
if ( $self->{paused} ) {
$self->{paused} = 0;
$self->{started_ticks} = SDL::get_ticks() - $self->{started_ticks};
$self->{paused_ticks} = 0;
}
}
sub get_ticks {
my $self = shift;
if ( $self->{started} ) {
if ( $self->{paused} ) {
return $self->{paused_ticks};
} else {
my $update = SDL::get_ticks();
my $diff = $update - $self->{started_ticks};
return $diff;
}
}
return 0;
}
sub is_started {
my $self = shift;
return $self->{started};
}
sub is_paused {
my $self = shift;
return $self->{paused};
}
1;
|