Adds the dancing tux animation

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2131 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat
2011-11-14 17:24:45 +00:00
parent 078d054f3e
commit b10cdc87f2
7 changed files with 29 additions and 14 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -7,7 +7,7 @@ interface
uses uses
Classes, SysUtils, FileUtil, Classes, SysUtils, FileUtil,
// LCL // LCL
ExtCtrls, ExtCtrls, Graphics,
// TappyTux // TappyTux
tappyconfig, tappymodules; tappyconfig, tappymodules;
@@ -27,7 +27,6 @@ type
gameQuestionList : TStringList; gameQuestionList : TStringList;
timerWords: TTimer; timerWords: TTimer;
procedure HandleOnTimer(Sender: TObject); procedure HandleOnTimer(Sender: TObject);
public public
constructor Create; override; constructor Create; override;
destructor Destroy; override; destructor Destroy; override;
@@ -60,8 +59,9 @@ begin
Questions[i].Top:= 24; Questions[i].Top:= 24;
Questions[i].Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; Questions[i].Text := formTappyTuxGame.Test.Lines.Strings[random(71)];
end; end;
end end;
vTappyTuxDrawer.HandleAnimationOnTimer();
end; end;
constructor TTappyWords.Create; constructor TTappyWords.Create;
@@ -72,7 +72,6 @@ begin
timerWords.Enabled := False; timerWords.Enabled := False;
timerWords.Interval := 1000; timerWords.Interval := 1000;
timerWords.OnTimer := @HandleOnTimer; timerWords.OnTimer := @HandleOnTimer;
end; end;
destructor TTappyWords.Destroy; destructor TTappyWords.Destroy;
@@ -97,6 +96,7 @@ end;
procedure TTappyWords.StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer); procedure TTappyWords.StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer);
var var
i: Integer; i: Integer;
lTuxAnimation: TTappySpriteAnimation;
begin begin
timerWords.Enabled := True; timerWords.Enabled := True;
gameScore := 0; gameScore := 0;
@@ -125,8 +125,25 @@ begin
begin begin
//Questions[i].Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; //Questions[i].Text := formTappyTuxGame.Test.Lines.Strings[random(71)];
Questions[i].Text := gameQuestionList[random(gameQuestionList.Count - 1)]; Questions[i].Text := gameQuestionList[random(gameQuestionList.Count - 1)];
end end;
// Adds the Tux animation
lTuxAnimation := TTappySpriteAnimation.Create;
lTuxAnimation.IsInfinite := True;
lTuxAnimation.StartPoint := Point(250, 300);
lTuxAnimation.EndPoint := lTuxAnimation.StartPoint;
SetLength(lTuxAnimation.Bitmaps, 6);
lTuxAnimation.Bitmaps[0] := TPortableNetworkGraphic.Create;
lTuxAnimation.Bitmaps[0].LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images' + PathDelim + 'sprites' + PathDelim + 'tux_1.png');
lTuxAnimation.Bitmaps[1] := TPortableNetworkGraphic.Create;
lTuxAnimation.Bitmaps[1].LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images' + PathDelim + 'sprites' + PathDelim + 'tux_2.png');
lTuxAnimation.Bitmaps[2] := TPortableNetworkGraphic.Create;
lTuxAnimation.Bitmaps[2].LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images' + PathDelim + 'sprites' + PathDelim + 'tux_3.png');
lTuxAnimation.Bitmaps[3] := TPortableNetworkGraphic.Create;
lTuxAnimation.Bitmaps[3].LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images' + PathDelim + 'sprites' + PathDelim + 'tux_4.png');
lTuxAnimation.Bitmaps[4] := lTuxAnimation.Bitmaps[2];
lTuxAnimation.Bitmaps[5] := lTuxAnimation.Bitmaps[1];
vTappyTuxDrawer.AddAnimation(lTuxAnimation);
end; end;
procedure TTappyWords.Answered; procedure TTappyWords.Answered;

View File

@@ -28,7 +28,7 @@ type
TTappySpriteAnimation = class(TTappyTuxAnimation) TTappySpriteAnimation = class(TTappyTuxAnimation)
public public
StartPoint, EndPoint: TPoint; StartPoint, EndPoint: TPoint;
Bitmaps: array of TBitmap; Bitmaps: array of TFPImageBitmap;
procedure DrawToIntfImg(AIntfImage: TLazIntfImage); override; procedure DrawToIntfImg(AIntfImage: TLazIntfImage); override;
procedure ExecuteFinal; override; procedure ExecuteFinal; override;
end; end;
@@ -240,7 +240,6 @@ var
IntfImage: TLazIntfImage; IntfImage: TLazIntfImage;
lDrawWidth, lDrawHeight: Integer; lDrawWidth, lDrawHeight: Integer;
CurColor: TFPColor; CurColor: TFPColor;
lCurColorDiv, lTranspColorDiv: Byte;
begin begin
IntfImage := TLazIntfImage.Create(0,0); IntfImage := TLazIntfImage.Create(0,0);
try try
@@ -259,10 +258,10 @@ begin
// Never draw outside the destination // Never draw outside the destination
if (CurX < 0) or (CurY < 0) then Continue; if (CurX < 0) or (CurY < 0) then Continue;
CurColor := IntfImage.Colors[x, y]; // Good for debugging CurColor := AImage.Canvas.Colors[x, y]; // Good for debugging
lCurColorDiv := CurColor.Green div $FF; if ((CurColor.Green div $FF) <> (AColor.Green div $FF)) or
lTranspColorDiv := AColor.Green div $FF; ((CurColor.Red div $FF) <> (AColor.Red div $FF)) or
if lCurColorDiv <> lTranspColorDiv then ((CurColor.Blue div $FF) <> (AColor.Blue div $FF)) then
ADest.Colors[CurX, CurY] := IntfImage.Colors[x, y]; ADest.Colors[CurX, CurY] := IntfImage.Colors[x, y];
end; end;
end; end;

View File

@@ -91,7 +91,7 @@
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>
<Version Value="10"/> <Version Value="11"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Target> <Target>
<Filename Value="tappytux"/> <Filename Value="tappytux"/>
@@ -102,8 +102,7 @@
</SearchPaths> </SearchPaths>
<Linking> <Linking>
<Debugging> <Debugging>
<GenerateDebugInfo Value="True"/> <DebugInfoType Value="dsDwarf2Set"/>
<GenerateDwarf Value="True"/>
</Debugging> </Debugging>
<Options> <Options>
<Win32> <Win32>