line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SDLx::Controller::Interface; |
2
|
6
|
|
|
6
|
|
69
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
1435
|
|
3
|
6
|
|
|
6
|
|
37
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
216
|
|
4
|
6
|
|
|
6
|
|
33
|
use Carp qw/confess/; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
315
|
|
5
|
6
|
|
|
6
|
|
36
|
use Scalar::Util 'refaddr'; |
|
6
|
|
|
|
|
28
|
|
|
6
|
|
|
|
|
429
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @ISA = qw(Exporter DynaLoader); |
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
37
|
use SDL::Internal::Loader; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
3056
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my %_controller; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
3
|
|
|
3
|
0
|
6971
|
shift; |
15
|
3
|
|
|
|
|
15
|
my %foo = @_; |
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
|
|
6
|
my @args; |
18
|
3
|
|
100
|
|
|
18
|
push @args, ( $foo{x} || 0 ); |
19
|
3
|
|
100
|
|
|
12
|
push @args, ( $foo{y} || 0 ); |
20
|
3
|
|
100
|
|
|
14
|
push @args, ( $foo{v_x} || 0 ); |
21
|
3
|
|
100
|
|
|
13
|
push @args, ( $foo{v_y} || 0 ); |
22
|
3
|
|
100
|
|
|
12
|
push @args, ( $foo{rot} || 0 ); |
23
|
3
|
|
100
|
|
|
11
|
push @args, ( $foo{ang_v} || 0 ); |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
55
|
return SDLx::Controller::Interface->make(@args); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub attach { |
30
|
1
|
|
|
1
|
0
|
15
|
my ( $self, $controller, $render, @params ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
1
|
50
|
33
|
|
|
20
|
Carp::confess "An SDLx::Controller is needed" unless $controller && $controller->isa('SDLx::Controller'); |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
17
|
$_controller{ refaddr $self } = [ $controller ]; |
35
|
1
|
|
|
2
|
|
6
|
my $move = sub { $self->update( $_[2], $_[1]->dt )}; |
|
2
|
|
|
|
|
20
|
|
36
|
1
|
|
|
|
|
20
|
$_controller{ refaddr $self }->[1] = $controller->add_move_handler($move); |
37
|
|
|
|
|
|
|
|
38
|
1
|
50
|
|
|
|
7
|
if ($render) { |
39
|
1
|
|
|
2
|
|
6
|
my $show = sub { my $state = $self->interpolate( $_[0] ); $render->( $state, @params ); }; |
|
2
|
|
|
|
|
25
|
|
|
2
|
|
|
|
|
10
|
|
40
|
1
|
|
|
|
|
5
|
$_controller{ refaddr $self }->[2] = $controller->add_show_handler($show); |
41
|
|
|
|
|
|
|
} else { |
42
|
0
|
|
|
|
|
0
|
Carp::confess "Render callback not provided"; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub detach { |
48
|
1
|
|
|
1
|
0
|
1841
|
my ( $self) = @_; |
49
|
1
|
|
|
|
|
9
|
my $controller = $_controller{ refaddr $self }; |
50
|
1
|
50
|
|
|
|
5
|
return unless $controller; |
51
|
1
|
|
|
|
|
8
|
$controller->[0]->remove_move_handler($controller->[1]); |
52
|
1
|
|
|
|
|
5
|
$controller->[0]->remove_show_handler($controller->[2]); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
internal_load_dlls(__PACKAGE__); |
56
|
|
|
|
|
|
|
bootstrap SDLx::Controller::Interface; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |