New animation class created.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2134 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
51c54f54ac
commit
63775e2439
@ -1,7 +1,7 @@
|
||||
object formTappyTuxGame: TformTappyTuxGame
|
||||
Left = 626
|
||||
Left = 76
|
||||
Height = 425
|
||||
Top = 277
|
||||
Top = 292
|
||||
Width = 621
|
||||
Caption = 'Tappy Tux'
|
||||
ClientHeight = 425
|
||||
@ -9,7 +9,6 @@ object formTappyTuxGame: TformTappyTuxGame
|
||||
OnCreate = FormCreate
|
||||
OnShow = FormShow
|
||||
LCLVersion = '0.9.31'
|
||||
Visible = True
|
||||
object btnExit: TButton
|
||||
Left = 8
|
||||
Height = 31
|
||||
@ -248,7 +247,7 @@ object formTappyTuxGame: TformTappyTuxGame
|
||||
object Yes: TButton
|
||||
Left = 240
|
||||
Height = 30
|
||||
Top = 219
|
||||
Top = 216
|
||||
Width = 80
|
||||
Caption = 'Yes'
|
||||
Color = clRed
|
||||
|
@ -9,7 +9,7 @@ uses
|
||||
// LCL
|
||||
ExtCtrls,
|
||||
// TappyTux
|
||||
tappymodules;
|
||||
tappyconfig, tappydrawer, tappymodules;
|
||||
|
||||
type
|
||||
|
||||
@ -35,6 +35,7 @@ type
|
||||
procedure TranslateTextsToEnglish; override;
|
||||
procedure TranslateTextsToPortuguese; override;
|
||||
procedure StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer); override;
|
||||
procedure CreateQuestion(); override;
|
||||
procedure Answered(); override;
|
||||
procedure EndGame(); override;
|
||||
procedure QuestionGenerator(qNumber : Integer);
|
||||
@ -42,7 +43,7 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
uses tappydrawer, gameplayform;
|
||||
uses gameplayform;
|
||||
|
||||
{ TTappyMath }
|
||||
|
||||
@ -126,6 +127,11 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TTappyMath.CreateQuestion;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TTappyMath.Answered;
|
||||
var
|
||||
i: Integer;
|
||||
|
@ -5,11 +5,11 @@ unit mod_tappywords;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil,
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
||||
// LCL
|
||||
ExtCtrls, Graphics,
|
||||
ExtCtrls,
|
||||
// TappyTux
|
||||
tappyconfig, tappymodules;
|
||||
tappyconfig, tappydrawer, tappymodules;
|
||||
|
||||
type
|
||||
|
||||
@ -33,14 +33,14 @@ type
|
||||
procedure TranslateTextsToEnglish; override;
|
||||
procedure TranslateTextsToPortuguese; override;
|
||||
procedure StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer); override;
|
||||
procedure createQuestion(); override;
|
||||
procedure Answered(); override;
|
||||
procedure EndGame(); override;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
uses tappydrawer, gameplayform;
|
||||
uses gameplayform;
|
||||
|
||||
{ TTappyWords }
|
||||
|
||||
@ -48,6 +48,15 @@ procedure TTappyWords.HandleOnTimer(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
{for i:= 1 to vTappyTuxDrawer.GetAnimationCount do
|
||||
begin
|
||||
if vTappyTuxDrawer.GetAnimation(i).InheritsFrom(TFallingText) then
|
||||
begin
|
||||
vTappyTuxDrawer.GetAnimation(i).;
|
||||
end;
|
||||
|
||||
end;}
|
||||
|
||||
for i:= 1 to 5 do
|
||||
begin
|
||||
Questions[i].Top := Questions[i].Top + (5*gameLevel);
|
||||
@ -110,7 +119,8 @@ begin
|
||||
gameSLevel := gameLevel;
|
||||
|
||||
gameQuestionList := TStringList.Create;
|
||||
gameQuestionList.LoadFromFile(vTappyTuxConfig.GetResourcesDir()+ 'images'+PathDelim+'modules'+PathDelim+'tappywords'+PathDelim+'0.txt');
|
||||
//gameQuestionList.LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images'+PathDelim+'modules'+PathDelim+'tappywords'+PathDelim+'0.txt');
|
||||
//gameQuestionList.LoadFromFile('C:/Users/User/Lazarus/Arquivos/Repositorio/applications/tappytux/images/modules/tappywords/0.txt');
|
||||
//gameQuestionList.LoadFromFile('C:/0.txt');
|
||||
|
||||
formTappyTuxGame.Answer.ReadOnly := false;
|
||||
@ -123,11 +133,11 @@ begin
|
||||
|
||||
for i:= 1 to 5 do
|
||||
begin
|
||||
//Questions[i].Text := formTappyTuxGame.Test.Lines.Strings[random(71)];
|
||||
Questions[i].Text := gameQuestionList[random(gameQuestionList.Count - 1)];
|
||||
Questions[i].Text := formTappyTuxGame.Test.Lines.Strings[random(71)];
|
||||
//Questions[i].Text := gameQuestionList[random(gameQuestionList.Count - 1)];
|
||||
end;
|
||||
|
||||
// Adds the Tux animation
|
||||
// Animations Creation
|
||||
lTuxAnimation := TTappySpriteAnimation.Create;
|
||||
lTuxAnimation.IsInfinite := True;
|
||||
lTuxAnimation.StartPoint := Point(250, 300);
|
||||
@ -144,6 +154,74 @@ begin
|
||||
lTuxAnimation.Bitmaps[4] := lTuxAnimation.Bitmaps[2];
|
||||
lTuxAnimation.Bitmaps[5] := lTuxAnimation.Bitmaps[1];
|
||||
vTappyTuxDrawer.AddAnimation(lTuxAnimation);
|
||||
|
||||
for i:= 1 to 5 do
|
||||
begin
|
||||
CreateQuestion();
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure TTappyWords.CreateQuestion();
|
||||
var
|
||||
i: Integer;
|
||||
xAux: Integer;
|
||||
yAux: Integer;
|
||||
snowmanAnimation: TFallingText;
|
||||
existenceAux1, existenceAux2, existenceAux3, existenceAux4, existenceAux5: boolean;
|
||||
|
||||
begin
|
||||
existenceAux1:= false;
|
||||
existenceAux2:= false;
|
||||
existenceAux3:= false;
|
||||
existenceAux4:= false;
|
||||
existenceAux5:= false;
|
||||
xAux:=5;
|
||||
yAux:=5;
|
||||
snowmanAnimation := TFallingText.Create;
|
||||
snowmanAnimation.IsInfinite := True;
|
||||
|
||||
for i:= 0 to vTappyTuxDrawer.GetAnimationCount - 1 do
|
||||
begin
|
||||
if vTappyTuxDrawer.GetAnimation(i).InheritsFrom(TFallingText) then
|
||||
begin
|
||||
if vTappyTuxDrawer.GetAnimation(i).StartPoint.x = 5 then existenceAux1 := True;
|
||||
if vTappyTuxDrawer.GetAnimation(i).StartPoint.x = 108 then existenceAux2 := True;
|
||||
if vTappyTuxDrawer.GetAnimation(i).StartPoint.x = 211 then existenceAux3 := True;
|
||||
if vTappyTuxDrawer.GetAnimation(i).StartPoint.x = 314 then existenceAux4 := True;
|
||||
if vTappyTuxDrawer.GetAnimation(i).StartPoint.x = 427 then existenceAux5 := True;
|
||||
if vTappyTuxDrawer.GetAnimation(i).StartPoint.y > yAux then
|
||||
begin
|
||||
xAux := vTappyTuxDrawer.GetAnimation(i).StartPoint.x;
|
||||
yAux := vTappyTuxDrawer.GetAnimation(i).StartPoint.y;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
if existenceAux1 = false then xAux := 5
|
||||
else
|
||||
begin
|
||||
if existenceAux2 = false then xAux := 108
|
||||
else
|
||||
begin
|
||||
if existenceAux3 = false then xAux := 211
|
||||
else
|
||||
begin
|
||||
if existenceAux4 = false then xAux := 314
|
||||
else
|
||||
begin
|
||||
if existenceAux5 = false then xAux := 427
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
snowmanAnimation.StartPoint := Point(xAux, 5);
|
||||
snowmanAnimation.EndPoint := snowmanAnimation.StartPoint;
|
||||
snowmanAnimation.Bitmap := TPortableNetworkGraphic.Create;
|
||||
snowmanAnimation.Bitmap.LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images' + PathDelim + 'sprites' + PathDelim + 'snowman.png');
|
||||
vTappyTuxDrawer.AddAnimation(snowmanAnimation);
|
||||
|
||||
end;
|
||||
|
||||
procedure TTappyWords.Answered;
|
||||
@ -166,9 +244,23 @@ begin
|
||||
end;
|
||||
|
||||
procedure TTappyWords.EndGame;
|
||||
var
|
||||
gameOverScreen: TTappySpriteAnimation;
|
||||
continueBtn: TButton;
|
||||
exitBtn: TButton;
|
||||
begin
|
||||
timerWords.Enabled := False;
|
||||
formTappyTuxGame.Answer.ReadOnly := true;
|
||||
|
||||
//gameOverScreen := TTappySpriteAnimation.Create;
|
||||
//gameOverScreen.IsInfinite := True;
|
||||
//gameOverScreen.StartPoint := Point(90, 150);
|
||||
//gameOverScreen.EndPoint := gameOverScreen.StartPoint;
|
||||
//SetLength(gameOverScreen.Bitmaps, 1);
|
||||
//gameOverScreen.Bitmaps[0] := TPortableNetworkGraphic.Create;
|
||||
//gameOverScreen.Bitmaps[0].LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images' + PathDelim + 'sprites' + PathDelim + 'gameover.png');
|
||||
//vTappyTuxDrawer.AddAnimation(gameOverScreen);
|
||||
|
||||
formTappyTuxGame.GameOver.Visible := true;
|
||||
formTappyTuxGame.Yes.Visible := true;
|
||||
formTappyTuxGame.No.Visible := true;
|
||||
|
@ -14,6 +14,7 @@ type
|
||||
{ TTappyTuxAnimation }
|
||||
|
||||
TTappyTuxAnimation = class
|
||||
StartPoint, EndPoint: TPoint;
|
||||
CurrentStep: Integer;
|
||||
StepCount: Integer;
|
||||
IsInfinite: Boolean; // if True the animation will never end
|
||||
@ -27,19 +28,29 @@ type
|
||||
|
||||
TTappySpriteAnimation = class(TTappyTuxAnimation)
|
||||
public
|
||||
StartPoint, EndPoint: TPoint;
|
||||
//StartPoint, EndPoint: TPoint; override;
|
||||
Bitmaps: array of TFPImageBitmap;
|
||||
procedure DrawToIntfImg(AIntfImage: TLazIntfImage); override;
|
||||
procedure ExecuteFinal; override;
|
||||
end;
|
||||
|
||||
{ TBallonAnimation }
|
||||
{ TBallonAnimation
|
||||
|
||||
TBallonAnimation = class(TTappyTuxAnimation)
|
||||
public
|
||||
constructor Create; override;
|
||||
procedure DrawToCanvas(ACanvas: TCanvas); override;
|
||||
procedure ExecuteFinal; override;
|
||||
end;}
|
||||
|
||||
{ TFallingText }
|
||||
TFallingText = class(TTappyTuxAnimation)
|
||||
public
|
||||
//StartPoint, EndPoint: TPoint; override;
|
||||
Bitmap: TFPImageBitmap;
|
||||
Question: TCanvas;
|
||||
procedure DrawToIntfImg(AIntfImage: TLazIntfImage); override;
|
||||
procedure ExecuteFinal; override;
|
||||
end;
|
||||
|
||||
{ TTappyTuxDrawer }
|
||||
@ -75,7 +86,7 @@ var
|
||||
|
||||
implementation
|
||||
|
||||
{ TBallonAnimation }
|
||||
{ TBallonAnimation
|
||||
|
||||
constructor TBallonAnimation.Create;
|
||||
begin
|
||||
@ -93,7 +104,7 @@ end;
|
||||
procedure TBallonAnimation.ExecuteFinal;
|
||||
begin
|
||||
// Lost the game if the ballon reached its end
|
||||
end;
|
||||
end}
|
||||
|
||||
{ TTappySpriteAnimation }
|
||||
|
||||
@ -121,6 +132,28 @@ begin
|
||||
inherited ExecuteFinal;
|
||||
end;
|
||||
|
||||
{TFallingText}
|
||||
|
||||
procedure TFallingText.DrawToIntfImg(AIntfImage: TLazIntfImage);
|
||||
var
|
||||
t: Double;
|
||||
lPos: TPoint;
|
||||
|
||||
begin
|
||||
t := CurrentStep / StepCount;
|
||||
lPos.X := Round(StartPoint.X + t * (EndPoint.X - StartPoint.X));
|
||||
lPos.Y := Round(StartPoint.Y + t * (EndPoint.Y - StartPoint.Y));
|
||||
|
||||
TTappyTuxDrawer.DrawImageWithTransparentColor(AIntfImage,
|
||||
lPos.X, lPos.Y, colFuchsia, Bitmap);
|
||||
end;
|
||||
|
||||
procedure TFallingText.ExecuteFinal;
|
||||
begin
|
||||
inherited ExecuteFinal;
|
||||
end;
|
||||
|
||||
|
||||
{ TTappyTuxAnimation }
|
||||
|
||||
constructor TTappyTuxAnimation.Create;
|
||||
@ -332,6 +365,8 @@ begin
|
||||
begin
|
||||
lAnimation := TTappyTuxAnimation(FAnimationList.Items[i]);
|
||||
Inc(lAnimation.CurrentStep);
|
||||
|
||||
if lAnimation.InheritsFrom(TFallingText) then lAnimation.StartPoint.y := lAnimation.StartPoint.y + 10;
|
||||
end;
|
||||
|
||||
Self.Invalidate;
|
||||
|
@ -27,6 +27,7 @@ type
|
||||
procedure TranslateTextsToPortuguese; virtual;
|
||||
procedure InitModule(); virtual;
|
||||
procedure StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer); virtual; abstract;
|
||||
procedure CreateQuestion(); virtual; abstract;
|
||||
procedure Answered(); virtual; abstract;
|
||||
procedure EndGame(); virtual; abstract;
|
||||
end;
|
||||
|
@ -91,7 +91,7 @@
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Version Value="10"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="tappytux"/>
|
||||
@ -101,9 +101,6 @@
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf2Set"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
|
Loading…
Reference in New Issue
Block a user