- Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathSDLx_sprite.pl
46 lines (36 loc) · 923 Bytes
/
SDLx_sprite.pl
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
use strict;
use SDL;
use SDL::Video;
use SDL::Color;
use SDL::Rect;
use SDL::Surface;
use SDL::GFX::Rotozoom;
use lib '../lib';
use SDLx::Sprite;
SDL::init(SDL_INIT_VIDEO);
my$disp = SDL::Video::set_video_mode( 300, 300, 32, SDL_ANYFORMAT );
my$pixel = SDL::Video::map_RGB( $disp->format, rand(255), rand(255), rand(255) );
SDL::Video::fill_rect(
$disp, SDL::Rect->new( 0, 0, $disp->w, $disp->h ),
$pixel
);
my$sprite = SDLx::Sprite->new( image=>'test/data/chest.png' );
$sprite->alpha_key( SDL::Color->new( 0xfc, 0x00, 0xff ) );
$sprite->alpha(0.8);
my$angle = 0;
while ( $angle++ < 360 ) {
SDL::Video::fill_rect(
$disp, SDL::Rect->new( 0, 0, $disp->w, $disp->h ),
$pixel
);
$sprite->rotation($angle);
#
$sprite->draw_xy(
$disp,
$disp->w / 2 - ( $sprite->w / 2 ),
$disp->h / 2 - ( $sprite->h / 2 )
);
SDL::Video::update_rect( $disp, 0, 0, 300, 300 );
SDL::delay(2);
}
SDL::delay(2000);