sdl perl-sdlx sprite
use SDL;use SDLx::App;
use SDLx::Sprite;
my $app=SDLx::App->new(w=>400,h=>400,d=>32,t=>"sky");
#画大地
$app->draw_rect(,);
#随机生成大地的麻点
for (my $i = 1; $i < 500; $i++){
$app->=;
}
#画夜空
my $sky=SDLx::Sprite->new(width=>400,height=>200);
$sky->surface->draw_rect(,);
#画树
my $tree=SDLx::Surface->new(width=>400,height=>150);
for (my $i = 1; $i < 30; $i++){
$x=int(20+rand(375));
$y=int(15+rand(100));
$tree->draw_circle_filled([$x,$y],15,);
$tree->draw_rect([$x,$y+15,2,15],);
}
#画月亮
$sky->surface->draw_circle_filled(,25,);
#画星星
for (my $i = 1; $i < 50; $i++)
{
my $x=int(rand(400));
my $y=int(rand(200));
if (not ($x>125 and $x<175and $y >25 and $y<75))
{
$sky->surface->draw_circle_filled([$x,$y],2,);
}
}
$sky->draw_xy($app);
$tree->blit($app,,);
$app->update();
sleep(5);
页:
[1]