Skip to content

Commit 91586c2

Browse files
author
Tobias Leich
committed
redid perltidy
1 parent 369c9c8 commit 91586c2

File tree

197 files changed

+12982
-12796
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+12982
-12796
lines changed

Build.PL

+496-496
Large diffs are not rendered by default.

examples/GFX/script_roto.pl

+14-18
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,36 @@
1111

1212
my $display = SDL::Video::set_video_mode( 640, 480, 32, SDL_SWSURFACE );
1313
my $pixel = SDL::Video::map_RGB( $display->format, 0, 0, 0 );
14-
SDL::Video::fill_rect(
15-
$display,
16-
SDL::Rect->new( 0, 0, $display->w, $display->h ), $pixel
17-
);
14+
SDL::Video::fill_rect( $display,
15+
SDL::Rect->new( 0, 0, $display->w, $display->h ), $pixel );
1816

1917
croak SDL::get_error if !$display;
2018

2119
my $src = SDL::Video::load_BMP('test/data/picture.bmp');
2220
my $temp_surf;
2321

2422
sub draw {
25-
SDL::Video::fill_rect(
26-
$display,
27-
SDL::Rect->new( 0, 0, $display->w, $display->h ), $pixel
28-
);
23+
SDL::Video::fill_rect( $display,
24+
SDL::Rect->new( 0, 0, $display->w, $display->h ), $pixel );
2925

30-
my $surface = $_[0];
31-
SDL::Video::blit_surface(
32-
$surface, SDL::Rect->new( 0, 0, $surface->w, $surface->h ),
33-
$display, SDL::Rect->new( 0, 0, $display->w, $display->w )
34-
);
26+
my $surface = $_[0];
27+
SDL::Video::blit_surface(
28+
$surface, SDL::Rect->new( 0, 0, $surface->w, $surface->h ),
29+
$display, SDL::Rect->new( 0, 0, $display->w, $display->w )
30+
);
3531

36-
SDL::Video::update_rect( $display, 0, 0, 640, 480 );
32+
SDL::Video::update_rect( $display, 0, 0, 640, 480 );
3733

38-
SDL::delay( $_[1] ) if $_[1];
34+
SDL::delay( $_[1] ) if $_[1];
3935

4036
}
4137

4238
# Note: new surface should be less than 16384 in width and height
4339
foreach ( 1 .. 360 ) {
4440

45-
$temp_surf = SDL::GFX::Rotozoom::surface( $src, $_, $_ / 180, 1 );
46-
croak SDL::get_error if !$temp_surf;
47-
draw( $temp_surf, 2 );
41+
$temp_surf = SDL::GFX::Rotozoom::surface( $src, $_, $_ / 180, 1 );
42+
croak SDL::get_error if !$temp_surf;
43+
draw( $temp_surf, 2 );
4844
}
4945

5046
$temp_surf = SDL::GFX::Rotozoom::surface_xy( $src, 1, 1, 1, 1 );

examples/SDLx/SDLx_controller_two_squares.pl

+96-93
Original file line numberDiff line numberDiff line change
@@ -16,124 +16,127 @@
1616
my $app = init();
1717

1818
my $ball = {
19-
x => 0,
20-
y => 0,
21-
w => 20,
22-
h => 20,
23-
vel => 200,
24-
x_vel => 0,
25-
y_vel => 0,
19+
x => 0,
20+
y => 0,
21+
w => 20,
22+
h => 20,
23+
vel => 200,
24+
x_vel => 0,
25+
y_vel => 0,
2626

2727
};
2828

2929
my $r_ball = {
30-
x => 0,
31-
y => 0,
32-
w => 20,
33-
h => 20,
34-
radians => 0,
35-
rot_vel => 50,
36-
radius => 100,
37-
c_x => $app->w / 2,
38-
c_y => $app->h / 2,
30+
x => 0,
31+
y => 0,
32+
w => 20,
33+
h => 20,
34+
radians => 0,
35+
rot_vel => 50,
36+
radius => 100,
37+
c_x => $app->w / 2,
38+
c_y => $app->h / 2,
3939
};
4040

4141
sub init {
4242

43-
# Initing video
44-
# Die here if we cannot make video init
45-
croak 'Cannot init ' . SDL::get_error()
46-
if ( SDL::init(SDL_INIT_VIDEO) == -1 );
43+
# Initing video
44+
# Die here if we cannot make video init
45+
croak 'Cannot init ' . SDL::get_error()
46+
if ( SDL::init(SDL_INIT_VIDEO) == -1 );
4747

48-
# Create our display window
49-
# This is our actual SDL application window
50-
my $a = SDL::Video::set_video_mode(
51-
800, 600, 32,
52-
SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL
53-
);
48+
# Create our display window
49+
# This is our actual SDL application window
50+
my $a = SDL::Video::set_video_mode( 800, 600, 32,
51+
SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL );
5452

55-
croak 'Cannot init video mode 800x600x32: ' . SDL::get_error()
56-
unless $a;
53+
croak 'Cannot init video mode 800x600x32: ' . SDL::get_error()
54+
unless $a;
5755

58-
return $a;
56+
return $a;
5957
}
6058

6159
my $game = SDLx::Controller->new();
6260

6361
sub on_move {
64-
my $dt = shift;
65-
$dt = $dt / 1000;
66-
$ball->{x} += $ball->{x_vel} * $dt;
62+
my $dt = shift;
63+
$dt = $dt / 1000;
64+
$ball->{x} += $ball->{x_vel} * $dt;
6765

68-
$ball->{y} += $ball->{y_vel} * $dt;
66+
$ball->{y} += $ball->{y_vel} * $dt;
6967

70-
# Period = $r_ball->{vel}
71-
# cc_speed = 2 * pi * r / T
72-
$r_ball->{radians} += $r_ball->{rot_vel} * $dt;
73-
$r_ball->{x} = $r_ball->{c_x} + sin( $r_ball->{radians} * pi / 180 ) * $r_ball->{radius};
74-
$r_ball->{y} = $r_ball->{c_y} + cos( $r_ball->{radians} * pi / 180 ) * $r_ball->{radius};
68+
# Period = $r_ball->{vel}
69+
# cc_speed = 2 * pi * r / T
70+
$r_ball->{radians} += $r_ball->{rot_vel} * $dt;
71+
$r_ball->{x} =
72+
$r_ball->{c_x} + sin( $r_ball->{radians} * pi / 180 ) * $r_ball->{radius};
73+
$r_ball->{y} =
74+
$r_ball->{c_y} + cos( $r_ball->{radians} * pi / 180 ) * $r_ball->{radius};
7575

76-
return 1;
76+
return 1;
7777
}
7878

7979
sub on_event {
80-
my $event = shift;
81-
82-
if ( $event->type == SDL_KEYDOWN ) {
83-
my $key = $event->key_sym;
84-
if ( $key == SDLK_PRINT ) {
85-
my $screen_shot_index = 1;
86-
map { $screen_shot_index = $1 + 1 if $_ =~ /Shot(\d+)\.bmp/ && $1 >= $screen_shot_index }
87-
<Shot*\.bmp>;
88-
SDL::Video::save_BMP(
89-
$app,
90-
sprintf( "Shot%04d.bmp", $screen_shot_index )
91-
);
92-
}
93-
$ball->{y_vel} -= $ball->{vel} if $key == SDLK_UP;
94-
$ball->{y_vel} += $ball->{vel} if $key == SDLK_DOWN;
95-
$ball->{x_vel} -= $ball->{vel} if $key == SDLK_LEFT;
96-
$ball->{x_vel} += $ball->{vel} if $key == SDLK_RIGHT;
97-
$r_ball->{rot_vel} += 50 if $key == SDLK_SPACE;
98-
99-
} elsif ( $event->type == SDL_KEYUP ) {
100-
my $key = $event->key_sym;
101-
$ball->{y_vel} += $ball->{vel} if $key == SDLK_UP;
102-
$ball->{y_vel} -= $ball->{vel} if $key == SDLK_DOWN;
103-
$ball->{x_vel} += $ball->{vel} if $key == SDLK_LEFT;
104-
$ball->{x_vel} -= $ball->{vel} if $key == SDLK_RIGHT;
105-
106-
} elsif ( $event->type == SDL_QUIT ) {
107-
return 0;
108-
}
109-
110-
return 1;
80+
my $event = shift;
81+
82+
if ( $event->type == SDL_KEYDOWN ) {
83+
my $key = $event->key_sym;
84+
if ( $key == SDLK_PRINT ) {
85+
my $screen_shot_index = 1;
86+
map {
87+
$screen_shot_index = $1 + 1
88+
if $_ =~ /Shot(\d+)\.bmp/
89+
&& $1 >= $screen_shot_index
90+
} <Shot*\.bmp>;
91+
SDL::Video::save_BMP( $app,
92+
sprintf( "Shot%04d.bmp", $screen_shot_index ) );
93+
}
94+
$ball->{y_vel} -= $ball->{vel} if $key == SDLK_UP;
95+
$ball->{y_vel} += $ball->{vel} if $key == SDLK_DOWN;
96+
$ball->{x_vel} -= $ball->{vel} if $key == SDLK_LEFT;
97+
$ball->{x_vel} += $ball->{vel} if $key == SDLK_RIGHT;
98+
$r_ball->{rot_vel} += 50 if $key == SDLK_SPACE;
99+
100+
}
101+
elsif ( $event->type == SDL_KEYUP ) {
102+
my $key = $event->key_sym;
103+
$ball->{y_vel} += $ball->{vel} if $key == SDLK_UP;
104+
$ball->{y_vel} -= $ball->{vel} if $key == SDLK_DOWN;
105+
$ball->{x_vel} += $ball->{vel} if $key == SDLK_LEFT;
106+
$ball->{x_vel} -= $ball->{vel} if $key == SDLK_RIGHT;
107+
108+
}
109+
elsif ( $event->type == SDL_QUIT ) {
110+
return 0;
111+
}
112+
113+
return 1;
111114
}
112115

113116
sub on_show {
114-
SDL::Video::fill_rect(
115-
$app,
116-
SDL::Rect->new( 0, 0, $app->w, $app->h ),
117-
SDL::Video::map_RGB( $app->format, 0, 0, 0 )
118-
);
119-
120-
SDL::Video::fill_rect(
121-
$app,
122-
SDL::Rect->new( $ball->{x}, $ball->{y}, $ball->{w}, $ball->{h} ),
123-
SDL::Video::map_RGB( $app->format, 0, 0, 255 )
124-
);
125-
126-
SDL::Video::fill_rect(
127-
$app,
128-
SDL::Rect->new(
129-
$r_ball->{x}, $r_ball->{y}, $r_ball->{w}, $r_ball->{h}
130-
),
131-
SDL::Video::map_RGB( $app->format, 255, 0, 0 )
132-
);
133-
134-
SDL::Video::flip($app);
135-
136-
return 0;
117+
SDL::Video::fill_rect(
118+
$app,
119+
SDL::Rect->new( 0, 0, $app->w, $app->h ),
120+
SDL::Video::map_RGB( $app->format, 0, 0, 0 )
121+
);
122+
123+
SDL::Video::fill_rect(
124+
$app,
125+
SDL::Rect->new( $ball->{x}, $ball->{y}, $ball->{w}, $ball->{h} ),
126+
SDL::Video::map_RGB( $app->format, 0, 0, 255 )
127+
);
128+
129+
SDL::Video::fill_rect(
130+
$app,
131+
SDL::Rect->new(
132+
$r_ball->{x}, $r_ball->{y}, $r_ball->{w}, $r_ball->{h}
133+
),
134+
SDL::Video::map_RGB( $app->format, 255, 0, 0 )
135+
);
136+
137+
SDL::Video::flip($app);
138+
139+
return 0;
137140
}
138141

139142
my $move_id = $game->add_move_handler( \&on_move );

examples/SDLx/SDLx_sprite.pl

+15-18
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212

1313
my $disp = SDL::Video::set_video_mode( 300, 300, 32, SDL_ANYFORMAT );
1414

15-
my $pixel = SDL::Video::map_RGB( $disp->format, rand(255), rand(255), rand(255) );
16-
SDL::Video::fill_rect(
17-
$disp, SDL::Rect->new( 0, 0, $disp->w, $disp->h ),
18-
$pixel
19-
);
15+
my $pixel =
16+
SDL::Video::map_RGB( $disp->format, rand(255), rand(255), rand(255) );
17+
SDL::Video::fill_rect( $disp, SDL::Rect->new( 0, 0, $disp->w, $disp->h ),
18+
$pixel );
2019

2120
my $sprite = SDLx::Sprite->new( image => 'test/data/chest.png' );
2221

@@ -25,22 +24,20 @@
2524

2625
my $angle = 0;
2726
while ( $angle++ < 360 ) {
28-
SDL::Video::fill_rect(
29-
$disp, SDL::Rect->new( 0, 0, $disp->w, $disp->h ),
30-
$pixel
31-
);
27+
SDL::Video::fill_rect( $disp, SDL::Rect->new( 0, 0, $disp->w, $disp->h ),
28+
$pixel );
3229

33-
$sprite->rotation($angle);
30+
$sprite->rotation($angle);
3431

35-
#
36-
$sprite->draw_xy(
37-
$disp,
38-
$disp->w / 2 - ( $sprite->w / 2 ),
39-
$disp->h / 2 - ( $sprite->h / 2 )
40-
);
32+
#
33+
$sprite->draw_xy(
34+
$disp,
35+
$disp->w / 2 - ( $sprite->w / 2 ),
36+
$disp->h / 2 - ( $sprite->h / 2 )
37+
);
4138

42-
SDL::Video::update_rect( $disp, 0, 0, 300, 300 );
39+
SDL::Video::update_rect( $disp, 0, 0, 300, 300 );
4340

44-
SDL::delay(2);
41+
SDL::delay(2);
4542
}
4643
SDL::delay(2000);

examples/SDLx/SDLx_sprite_animated.pl

+12-16
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@
1111
my $disp = SDL::Video::set_video_mode( 300, 300, 32, SDL_ANYFORMAT );
1212

1313
my $pixel = SDL::Video::map_RGB( $disp->format, 0, 0, 0 );
14-
SDL::Video::fill_rect(
15-
$disp, SDL::Rect->new( 0, 0, $disp->w, $disp->h ),
16-
$pixel
17-
);
14+
SDL::Video::fill_rect( $disp, SDL::Rect->new( 0, 0, $disp->w, $disp->h ),
15+
$pixel );
1816

1917
my $sprite = SDLx::Sprite::Animated->new(
20-
image => 'test/data/hero.png',
21-
rect => SDL::Rect->new( 48, 0, 48, 48 ),
22-
ticks_per_frame => 6,
18+
image => 'test/data/hero.png',
19+
rect => SDL::Rect->new( 48, 0, 48, 48 ),
20+
ticks_per_frame => 6,
2321
);
2422
$sprite->set_sequences( left => [ [ 1, 0 ], [ 1, 1 ], [ 1, 2 ] ], );
2523
$sprite->alpha_key( SDL::Color->new( 0xfc, 0x00, 0xff ) );
@@ -29,17 +27,15 @@
2927
my $ticks = 0;
3028

3129
while ( $x++ < 30 ) {
32-
SDL::Video::fill_rect(
33-
$disp, SDL::Rect->new( 0, 0, $disp->w, $disp->h ),
34-
$pixel
35-
);
30+
SDL::Video::fill_rect( $disp, SDL::Rect->new( 0, 0, $disp->w, $disp->h ),
31+
$pixel );
3632

37-
$sprite->x( $x * 10 );
38-
$sprite->next();
39-
$sprite->draw($disp);
33+
$sprite->x( $x * 10 );
34+
$sprite->next();
35+
$sprite->draw($disp);
4036

41-
SDL::Video::update_rect( $disp, 0, 0, 0, 0 );
37+
SDL::Video::update_rect( $disp, 0, 0, 0, 0 );
4238

43-
SDL::delay(100);
39+
SDL::delay(100);
4440
}
4541

0 commit comments

Comments
 (0)