From eb7fda5787b57346df6413f8a994bcba1fb428d4 Mon Sep 17 00:00:00 2001 From: denniscuflat Date: Tue, 15 Nov 2011 12:47:57 +0000 Subject: [PATCH] git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2137 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/tappytux/mod_tappywords.pas | 58 +++++++++++++++++------- applications/tappytux/tappydrawer.pas | 9 ++-- 2 files changed, 46 insertions(+), 21 deletions(-) diff --git a/applications/tappytux/mod_tappywords.pas b/applications/tappytux/mod_tappywords.pas index 88f180cb8..0fb4d0945 100644 --- a/applications/tappytux/mod_tappywords.pas +++ b/applications/tappytux/mod_tappywords.pas @@ -70,6 +70,17 @@ begin end; end; + for i:= 0 to vTappyTuxDrawer.GetAnimationCount - 1 do + begin + if vTappyTuxDrawer.GetAnimation(i).InheritsFrom(TFallingText) then + begin + vTappyTuxDrawer.GetAnimation(i).StartPoint.y:= vTappyTuxDrawer.GetAnimation(i).StartPoint.y + (5*gameLevel); + vTappyTuxDrawer.GetAnimation(i).EndPoint.y:= vTappyTuxDrawer.GetAnimation(i).StartPoint.y; + end; + end; + + + vTappyTuxDrawer.HandleAnimationOnTimer(); end; @@ -106,6 +117,7 @@ procedure TTappyWords.StartNewGame(SndFX: Integer; Music: Integer; Level: Intege var i: Integer; lTuxAnimation: TTappySpriteAnimation; + begin timerWords.Enabled := True; gameScore := 0; @@ -118,10 +130,11 @@ begin if (Music = 1) then gameMusic := false; gameSLevel := gameLevel; + if QuestionList < 0 then QuestionList := 0; gameQuestionList := TStringList.Create; //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'); + gameQuestionList.LoadFromFile('C:/'+IntToStr(QuestionList)+'.txt'); formTappyTuxGame.Answer.ReadOnly := false; formTappyTuxGame.GameOver.Visible := false; @@ -133,14 +146,14 @@ 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; // Animations Creation lTuxAnimation := TTappySpriteAnimation.Create; lTuxAnimation.IsInfinite := True; - lTuxAnimation.StartPoint := Point(250, 300); + lTuxAnimation.StartPoint := Point(250, 328); lTuxAnimation.EndPoint := lTuxAnimation.StartPoint; SetLength(lTuxAnimation.Bitmaps, 6); lTuxAnimation.Bitmaps[0] := TPortableNetworkGraphic.Create; @@ -181,21 +194,24 @@ begin snowmanAnimation := TFallingText.Create; snowmanAnimation.IsInfinite := True; - for i:= 0 to vTappyTuxDrawer.GetAnimationCount - 1 do + if True then 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 + for i:= 0 to vTappyTuxDrawer.GetAnimationCount - 1 do + begin + if vTappyTuxDrawer.GetAnimation(i).InheritsFrom(TFallingText) then begin - xAux := vTappyTuxDrawer.GetAnimation(i).StartPoint.x; - yAux := vTappyTuxDrawer.GetAnimation(i).StartPoint.y; + 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; + end; end; if existenceAux1 = false then xAux := 5 @@ -219,6 +235,7 @@ begin snowmanAnimation.StartPoint := Point(xAux, 5); snowmanAnimation.EndPoint := snowmanAnimation.StartPoint; snowmanAnimation.Bitmap := TPortableNetworkGraphic.Create; + snowmanAnimation.QuestionText:= formTappyTuxGame.Test.Lines.Strings[random(71)]; snowmanAnimation.Bitmap.LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images' + PathDelim + 'sprites' + PathDelim + 'snowman.png'); vTappyTuxDrawer.AddAnimation(snowmanAnimation); @@ -233,7 +250,8 @@ begin if (formTappyTuxGame.Answer.Text = Questions[i].Text) then begin Questions[i].Top := 24; - 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)]; gameScore := gameScore +1; gameLevel := (gameScore div 20) + gameSLevel; formTappyTuxGame.Score.Text := IntToStr(gameScore); @@ -245,6 +263,7 @@ end; procedure TTappyWords.EndGame; var + i : Integer; gameOverScreen: TTappySpriteAnimation; continueBtn: TButton; exitBtn: TButton; @@ -261,6 +280,11 @@ begin //gameOverScreen.Bitmaps[0].LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images' + PathDelim + 'sprites' + PathDelim + 'gameover.png'); //vTappyTuxDrawer.AddAnimation(gameOverScreen); + for i:= 1 to vTappyTuxDrawer.GetAnimationCount - 1 do + begin + vTappyTuxDrawer.GetAnimation(i).Destroy; + end; + formTappyTuxGame.GameOver.Visible := true; formTappyTuxGame.Yes.Visible := true; formTappyTuxGame.No.Visible := true; diff --git a/applications/tappytux/tappydrawer.pas b/applications/tappytux/tappydrawer.pas index 72706d651..06290aa09 100644 --- a/applications/tappytux/tappydrawer.pas +++ b/applications/tappytux/tappydrawer.pas @@ -7,7 +7,7 @@ interface uses Classes, SysUtils, Controls, Graphics, LCLType, IntfGraphics, fpimage, Math, - {tappygamedata,} tappyconfig, tappymodules; + tappyconfig, tappymodules; type @@ -48,7 +48,8 @@ type public //StartPoint, EndPoint: TPoint; override; Bitmap: TFPImageBitmap; - Question: TCanvas; + QuestionText: String; + QuestionBox: TCanvas; procedure DrawToIntfImg(AIntfImage: TLazIntfImage); override; procedure ExecuteFinal; override; end; @@ -146,6 +147,8 @@ begin TTappyTuxDrawer.DrawImageWithTransparentColor(AIntfImage, lPos.X, lPos.Y, colFuchsia, Bitmap); + QuestionBox := TCanvas.Create; + QuestionBox.TextOut(lPos.X, lPos.Y, QuestionText); end; procedure TFallingText.ExecuteFinal; @@ -365,8 +368,6 @@ 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;