Support for animated sayer sprites

This commit is contained in:
Ryan Shepherd 2018-10-01 14:37:17 -04:00
parent 7a31c1fc55
commit 61fb64c10a
3 changed files with 14 additions and 12 deletions

View File

@ -19,17 +19,19 @@ use vars qw/@ISA @EXPORT @EXPORT_OK %VisibleSprites/;
# FIXME - This should be exported already? # FIXME - This should be exported already?
*GetOption = \&PerlRPG::Game::GetOption; *GetOption = \&PerlRPG::Game::GetOption;
# FIXME - This should be a setable option
my $speech_border = 5; my $speech_border = 5;
sub DrawSpeech { sub DrawSpeech {
my($sayer, $text)=@_; my($sayer, $text)=@_;
my $app = GetOption('App'); my $app = GetOption('App');
my $sprite = GetAsset($sayer->{'Sprite'}); my $sprite = GetAsset($sayer->{'Sprite'});
my $sprite_x = $app->width() - $sprite->w(); my $sprite_x = $app->width() - $sprite->clip()->w();
my $sprite_y = $app->height() - $sprite->h(); my $sprite_y = $app->height() - $sprite->clip()->h();
my $sprite_h = $sprite->h(); my $sprite_h = $sprite->clip()->h();
$sprite = undef; # ShowSprite may unload this, we don't want to keep a handle to it $sprite = undef; # ShowSprite may unload this, we don't want to keep a handle to it
ShowSprite('_SayerSprite', $sayer->{'Sprite'}, $sprite_x, $sprite_y, 254); ShowSprite('_SayerSprite', $sayer->{'Sprite'}, $sprite_x, $sprite_y, 254, @{ $sayer->{'SpriteOpts'} });
my $text_obj = SDLx::Text->new(); my $text_obj = SDLx::Text->new();
$text_obj->color( $sayer->{'TextColor'} ); $text_obj->color( $sayer->{'TextColor'} );

View File

@ -170,16 +170,17 @@ sub RunScriptLine {
} }
sub AddSayer { sub AddSayer {
my($name, $displayname, $sprite, @textcolor)=@_; my($name, $displayname, $sprite, $r, $g, $b, $a, @opts)=@_;
if(@textcolor < 4) {
$textcolor[3] = 255; my @textcolor=($r, $g, $b, $a);
} $textcolor[3] = 255 unless(defined $a);
$sayers{$name} = { $sayers{$name} = {
'Name' => $name, 'Name' => $name,
'DisplayName' => StringSubst($displayname), 'DisplayName' => StringSubst($displayname),
'Sprite' => $sprite, 'Sprite' => $sprite,
'TextColor' => \@textcolor 'TextColor' => \@textcolor,
'SpriteOpts' => \@opts,
}; };
} }

View File

@ -8,9 +8,9 @@ __init__:
Show aka2 spritesheet.png 100 0 2 Reverse Show aka2 spritesheet.png 100 0 2 Reverse
Show aka3 spritesheet.png 200 0 3 max_loops=10 Show aka3 spritesheet.png 200 0 3 max_loops=10
AddSayer h "Hermione" aka01.png 200 200 200 255 AddSayer h "Hermione" aka01.png 200 200 200 255 flip
AddSayer h2 "Topless\ Hermione" aka05.png 255 0 0 255 AddSayer h2 "Topless\ Hermione" aka05.png 255 0 0 255
AddSayer h3 "Stripping\ Hermione" spritesheet.png 255 0 0 255 AddSayer h3 "Stripping\ Hermione" spritesheet.png 255 0 0 255 Reverse
Jump donothing Jump donothing
@ -22,5 +22,4 @@ donothing:
h2 "TestVar [TestVar]" h2 "TestVar [TestVar]"
TestVar = uc("[TestVar]") TestVar = uc("[TestVar]")
h3 "TestVar2 [TestVar]" h3 "TestVar2 [TestVar]"
ExitGame
Jump donothing Jump donothing