You've already forked lazarus-ccr
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2141 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -186,51 +186,6 @@ object formTappyTuxGame: TformTappyTuxGame
|
|||||||
TabOrder = 5
|
TabOrder = 5
|
||||||
Visible = False
|
Visible = False
|
||||||
end
|
end
|
||||||
object Question1: TEdit
|
|
||||||
Left = 112
|
|
||||||
Height = 23
|
|
||||||
Top = 24
|
|
||||||
Width = 82
|
|
||||||
ReadOnly = True
|
|
||||||
TabOrder = 6
|
|
||||||
Text = 'Question'
|
|
||||||
end
|
|
||||||
object Question2: TEdit
|
|
||||||
Left = 216
|
|
||||||
Height = 23
|
|
||||||
Top = 24
|
|
||||||
Width = 80
|
|
||||||
ReadOnly = True
|
|
||||||
TabOrder = 7
|
|
||||||
Text = 'Question'
|
|
||||||
end
|
|
||||||
object Question4: TEdit
|
|
||||||
Left = 320
|
|
||||||
Height = 23
|
|
||||||
Top = 24
|
|
||||||
Width = 80
|
|
||||||
ReadOnly = True
|
|
||||||
TabOrder = 8
|
|
||||||
Text = 'Question'
|
|
||||||
end
|
|
||||||
object Question3: TEdit
|
|
||||||
Left = 424
|
|
||||||
Height = 23
|
|
||||||
Top = 24
|
|
||||||
Width = 80
|
|
||||||
ReadOnly = True
|
|
||||||
TabOrder = 9
|
|
||||||
Text = 'Question'
|
|
||||||
end
|
|
||||||
object Question5: TEdit
|
|
||||||
Left = 528
|
|
||||||
Height = 23
|
|
||||||
Top = 24
|
|
||||||
Width = 80
|
|
||||||
ReadOnly = True
|
|
||||||
TabOrder = 10
|
|
||||||
Text = 'Question'
|
|
||||||
end
|
|
||||||
object GameOver: TToggleBox
|
object GameOver: TToggleBox
|
||||||
Left = 240
|
Left = 240
|
||||||
Height = 64
|
Height = 64
|
||||||
@ -241,7 +196,7 @@ object formTappyTuxGame: TformTappyTuxGame
|
|||||||
Color = clRed
|
Color = clRed
|
||||||
Enabled = False
|
Enabled = False
|
||||||
State = cbChecked
|
State = cbChecked
|
||||||
TabOrder = 11
|
TabOrder = 6
|
||||||
Visible = False
|
Visible = False
|
||||||
end
|
end
|
||||||
object Yes: TButton
|
object Yes: TButton
|
||||||
@ -252,7 +207,7 @@ object formTappyTuxGame: TformTappyTuxGame
|
|||||||
Caption = 'Yes'
|
Caption = 'Yes'
|
||||||
Color = clRed
|
Color = clRed
|
||||||
OnClick = YesClick
|
OnClick = YesClick
|
||||||
TabOrder = 12
|
TabOrder = 7
|
||||||
Visible = False
|
Visible = False
|
||||||
end
|
end
|
||||||
object No: TButton
|
object No: TButton
|
||||||
@ -263,7 +218,7 @@ object formTappyTuxGame: TformTappyTuxGame
|
|||||||
Caption = 'No'
|
Caption = 'No'
|
||||||
Color = clRed
|
Color = clRed
|
||||||
OnClick = NoClick
|
OnClick = NoClick
|
||||||
TabOrder = 13
|
TabOrder = 8
|
||||||
Visible = False
|
Visible = False
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -20,11 +20,6 @@ type
|
|||||||
Answer: TEdit;
|
Answer: TEdit;
|
||||||
No: TButton;
|
No: TButton;
|
||||||
Yes: TButton;
|
Yes: TButton;
|
||||||
Question1: TEdit;
|
|
||||||
Question2: TEdit;
|
|
||||||
Question4: TEdit;
|
|
||||||
Question3: TEdit;
|
|
||||||
Question5: TEdit;
|
|
||||||
Level: TEdit;
|
Level: TEdit;
|
||||||
Score: TEdit;
|
Score: TEdit;
|
||||||
Lives: TEdit;
|
Lives: TEdit;
|
||||||
@ -50,7 +45,6 @@ type
|
|||||||
|
|
||||||
var
|
var
|
||||||
formTappyTuxGame: TformTappyTuxGame;
|
formTappyTuxGame: TformTappyTuxGame;
|
||||||
Questions : array[1..5] of TEdit;
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -94,11 +88,6 @@ end;
|
|||||||
|
|
||||||
procedure TformTappyTuxGame.FormShow(Sender: TObject);
|
procedure TformTappyTuxGame.FormShow(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Questions[1] := Question1;
|
|
||||||
Questions[2] := Question2;
|
|
||||||
Questions[3] := Question3;
|
|
||||||
Questions[4] := Question4;
|
|
||||||
Questions[5] := Question5;
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -119,10 +108,6 @@ procedure TformTappyTuxGame.YesClick(Sender: TObject);
|
|||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
for i:= 1 to 5 do
|
|
||||||
begin
|
|
||||||
Questions[i].Top := 24;
|
|
||||||
end;
|
|
||||||
GetCurrentModule().StartNewGame(formConfig.comboSound.ItemIndex,
|
GetCurrentModule().StartNewGame(formConfig.comboSound.ItemIndex,
|
||||||
formConfig.comboMusic.ItemIndex,
|
formConfig.comboMusic.ItemIndex,
|
||||||
formConfig.comboLevel.ItemIndex,
|
formConfig.comboLevel.ItemIndex,
|
||||||
|
@ -5,7 +5,7 @@ unit mod_tappymath;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils,
|
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
||||||
// LCL
|
// LCL
|
||||||
ExtCtrls,
|
ExtCtrls,
|
||||||
// TappyTux
|
// TappyTux
|
||||||
@ -24,8 +24,10 @@ type
|
|||||||
gameSLevel : Integer;
|
gameSLevel : Integer;
|
||||||
gameSndFX : Boolean;
|
gameSndFX : Boolean;
|
||||||
gameMusic : Boolean;
|
gameMusic : Boolean;
|
||||||
|
gameQuestionList : TStringList;
|
||||||
questionType : array[1..3] of Integer;
|
questionType : array[1..3] of Integer;
|
||||||
questionAnswer : array[1..5] of Integer;
|
questionAnswer : array[1..5] of Integer;
|
||||||
|
count : Integer;
|
||||||
timerMath : TTimer;
|
timerMath : TTimer;
|
||||||
procedure HandleOnTimer(Sender: TObject);
|
procedure HandleOnTimer(Sender: TObject);
|
||||||
|
|
||||||
@ -38,7 +40,6 @@ type
|
|||||||
procedure CreateQuestion(); override;
|
procedure CreateQuestion(); override;
|
||||||
procedure Answered(); override;
|
procedure Answered(); override;
|
||||||
procedure EndGame(); override;
|
procedure EndGame(); override;
|
||||||
procedure QuestionGenerator(qNumber : Integer);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -50,19 +51,38 @@ uses gameplayform;
|
|||||||
procedure TTappyMath.HandleOnTimer(Sender: TObject);
|
procedure TTappyMath.HandleOnTimer(Sender: TObject);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
j: Integer;
|
||||||
|
frequency: Integer;
|
||||||
begin
|
begin
|
||||||
for i:= 1 to 5 do
|
i:= 0;
|
||||||
|
j:= vTappyTuxDrawer.GetAnimationCount - 1;
|
||||||
|
while (i<= j) do
|
||||||
begin
|
begin
|
||||||
Questions[i].Top := Questions[i].Top + (5*gameLevel);
|
if vTappyTuxDrawer.GetAnimation(i).InheritsFrom(TFallingText) then
|
||||||
if ((Questions[i].Top >= 370)) then
|
|
||||||
begin
|
begin
|
||||||
gameLives := gameLives - 1;
|
if (vTappyTuxDrawer.GetAnimation(i).Position.y >= 270) then
|
||||||
formTappyTuxGame.Lives.Text := IntToStr(gameLives);
|
begin
|
||||||
if (gameLives = 0) then EndGame();
|
gameLives := gameLives - 1;
|
||||||
Questions[i].Top:= 24;
|
formTappyTuxGame.Lives.Text := IntToStr(gameLives);
|
||||||
QuestionGenerator(i);
|
vTappyTuxDrawer.RemoveAnimation(i);
|
||||||
|
i := i - 1;
|
||||||
|
if (gameLives = 0) then EndGame();
|
||||||
|
CreateQuestion;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end
|
i := i + 1;
|
||||||
|
j := vTappyTuxDrawer.GetAnimationCount - 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
frequency := 30;
|
||||||
|
count := count + 1;
|
||||||
|
if count >= frequency then
|
||||||
|
begin
|
||||||
|
count := 0;
|
||||||
|
CreateQuestion();
|
||||||
|
end;
|
||||||
|
|
||||||
|
vTappyTuxDrawer.HandleAnimationOnTimer();
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -99,8 +119,9 @@ end;
|
|||||||
procedure TTappyMath.StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer);
|
procedure TTappyMath.StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
lTuxAnimation: TTappySpriteAnimation;
|
||||||
begin
|
begin
|
||||||
|
count := 0;
|
||||||
timerMath.Enabled := True;
|
timerMath.Enabled := True;
|
||||||
gameScore := 0;
|
gameScore := 0;
|
||||||
gameLives := 5;
|
gameLives := 5;
|
||||||
@ -120,74 +141,195 @@ begin
|
|||||||
formTappyTuxGame.Score.Text := IntToStr(gameScore);
|
formTappyTuxGame.Score.Text := IntToStr(gameScore);
|
||||||
formTappyTuxGame.Lives.Text := IntToStr(gameLives);
|
formTappyTuxGame.Lives.Text := IntToStr(gameLives);
|
||||||
|
|
||||||
|
// Animations Creation
|
||||||
|
lTuxAnimation := TTappySpriteAnimation.Create;
|
||||||
|
lTuxAnimation.IsInfinite := True;
|
||||||
|
lTuxAnimation.StartPoint := Point(250, 328);
|
||||||
|
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);
|
||||||
|
|
||||||
for i:= 1 to 5 do
|
for i:= 1 to 5 do
|
||||||
begin
|
begin
|
||||||
QuestionGenerator(i);
|
CreateQuestion;
|
||||||
end
|
end
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TTappyMath.CreateQuestion;
|
procedure TTappyMath.CreateQuestion;
|
||||||
begin
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TTappyMath.Answered;
|
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
j: Integer;
|
||||||
|
xAux: Integer;
|
||||||
|
yAux: Integer;
|
||||||
|
heightAux: array [0..4] of integer;
|
||||||
|
existenceAux: array [0..4] of boolean;
|
||||||
|
snowmanAnimation: TFallingText;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
for i:= 1 to 5 do
|
|
||||||
|
for i:= 0 to 4 do
|
||||||
begin
|
begin
|
||||||
if (formTappyTuxGame.Answer.Text = IntToStr(questionAnswer[i])) then
|
existenceAux[i]:= False;
|
||||||
|
heightAux[i] := 500;
|
||||||
|
end;
|
||||||
|
|
||||||
|
xAux:=5;
|
||||||
|
yAux:=5;
|
||||||
|
|
||||||
|
snowmanAnimation := TFallingText.Create;
|
||||||
|
snowmanAnimation.IsInfinite := False;
|
||||||
|
|
||||||
|
|
||||||
|
for i:= 0 to vTappyTuxDrawer.GetAnimationCount - 1 do
|
||||||
|
begin
|
||||||
|
if vTappyTuxDrawer.GetAnimation(i).InheritsFrom(TFallingText) then
|
||||||
|
begin
|
||||||
|
for j:= 0 to 4 do
|
||||||
|
begin
|
||||||
|
if vTappyTuxDrawer.GetAnimation(i).StartPoint.X = 5+(103*j) then
|
||||||
|
begin
|
||||||
|
existenceAux[j] := True;
|
||||||
|
if vTappyTuxDrawer.GetAnimation(i).Position.Y < heightAux[j] then heightAux[j] := vTappyTuxDrawer.GetAnimation(i).Position.Y;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
for i:= 0 to 4 do
|
||||||
|
begin
|
||||||
|
if heightAux[i] > yAux then
|
||||||
|
begin
|
||||||
|
yAux := heightAux[i];
|
||||||
|
xAux := 5 + i*103;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
if existenceAux[0] = false then xAux := 5
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if existenceAux[1] = false then xAux := 108
|
||||||
|
else
|
||||||
begin
|
begin
|
||||||
Questions[i].Top := 24;
|
if existenceAux[2] = false then xAux := 211
|
||||||
QuestionGenerator(i);
|
else
|
||||||
gameScore := gameScore +1;
|
begin
|
||||||
gameLevel := (gameScore div 20) + gameSLevel;
|
if existenceAux[3] = false then xAux := 314
|
||||||
formTappyTuxGame.Score.Text := IntToStr(gameScore);
|
else
|
||||||
formTappyTuxGame.Level.Text := IntToStr(gameLevel);
|
begin
|
||||||
|
if existenceAux[4] = false then xAux := 417
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end
|
end;
|
||||||
|
|
||||||
end;
|
snowmanAnimation.StartPoint := Point(xAux, 5);
|
||||||
|
snowmanAnimation.EndPoint := Point(xAux, 205);
|
||||||
|
snowmanAnimation.IsInfinite:= false;
|
||||||
|
snowmanAnimation.Bitmap := TPortableNetworkGraphic.Create;
|
||||||
|
//snowmanAnimation.caption:= gameQuestionList[random(gameQuestionList.Count - 1)];
|
||||||
|
snowmanAnimation.Bitmap.LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images' + PathDelim + 'sprites' + PathDelim + 'snowman.png');
|
||||||
|
|
||||||
procedure TTappyMath.EndGame;
|
|
||||||
begin
|
|
||||||
timerMath.Enabled := False;
|
|
||||||
formTappyTuxGame.Answer.ReadOnly := true;
|
|
||||||
formTappyTuxGame.GameOver.Visible := true;
|
|
||||||
formTappyTuxGame.Yes.Visible := true;
|
|
||||||
formTappyTuxGame.No.Visible := true;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TTappyMath.QuestionGenerator(qNumber : Integer);
|
|
||||||
begin
|
|
||||||
questionType[1] := random(3);
|
questionType[1] := random(3);
|
||||||
|
|
||||||
Case questionType[1] of
|
Case questionType[1] of
|
||||||
0: begin
|
0: begin
|
||||||
questionType[2] := random(21);
|
questionType[2] := random(21);
|
||||||
questionType[3] := random(21);
|
questionType[3] := random(21);
|
||||||
questionAnswer[qNumber] := questionType[2] + questionType[3];
|
snowmanAnimation.value := IntToStr(questionType[2] + questionType[3]);
|
||||||
Questions[qNumber].Text := IntToStr(questionType[2])+' + ' +IntToStr(questionType[3]);
|
snowmanAnimation.caption := IntToStr(questionType[2])+' + ' +IntToStr(questionType[3]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
1: begin
|
1: begin
|
||||||
questionType[2] := random(21);
|
questionType[2] := random(21);
|
||||||
questionType[3] := random(questionType[2]);
|
questionType[3] := random(questionType[2]);
|
||||||
questionAnswer[qNumber] := questionType[2] - questionType[3];
|
snowmanAnimation.value := IntToStr(questionType[2] - questionType[3]);
|
||||||
Questions[qNumber].Text := IntToStr(questionType[2])+' - ' +IntToStr(questionType[3]);
|
snowmanAnimation.caption := IntToStr(questionType[2])+' - ' +IntToStr(questionType[3]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
2: begin
|
2: begin
|
||||||
questionType[2] := random(11);
|
questionType[2] := random(11);
|
||||||
questionType[3] := random(11);
|
questionType[3] := random(11);
|
||||||
questionAnswer[qNumber] := questionType[2] * questionType[3];
|
snowmanAnimation.value := IntToStr(questionType[2] * questionType[3]);
|
||||||
Questions[qNumber].Text := IntToStr(questionType[2])+' x ' +IntToStr(questionType[3]);
|
snowmanAnimation.caption := IntToStr(questionType[2])+' x ' +IntToStr(questionType[3]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
vTappyTuxDrawer.AddAnimation(snowmanAnimation);
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTappyMath.Answered;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
j: Integer;
|
||||||
|
begin
|
||||||
|
i:= 0;
|
||||||
|
j:= vTappyTuxDrawer.GetAnimationCount - 1;
|
||||||
|
while (i<= j) do
|
||||||
|
begin
|
||||||
|
if vTappyTuxDrawer.GetAnimation(i).InheritsFrom(TFallingText) then
|
||||||
|
begin
|
||||||
|
if (vTappyTuxDrawer.GetAnimation(i).value = formTappyTuxGame.Answer.Text) then
|
||||||
|
begin
|
||||||
|
gameScore := gameScore +1;
|
||||||
|
gameLevel := (gameScore div 20) + gameSLevel;
|
||||||
|
formTappyTuxGame.Score.Text := IntToStr(gameScore);
|
||||||
|
formTappyTuxGame.Level.Text := IntToStr(gameLevel);
|
||||||
|
vTappyTuxDrawer.RemoveAnimation(i);
|
||||||
|
i := i - 1;
|
||||||
|
CreateQuestion;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
i := i + 1;
|
||||||
|
j := vTappyTuxDrawer.GetAnimationCount - 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTappyMath.EndGame;
|
||||||
|
var
|
||||||
|
i : Integer;
|
||||||
|
j : Integer;
|
||||||
|
gameOverScreen: TTappySpriteAnimation;
|
||||||
|
continueBtn: TButton;
|
||||||
|
exitBtn: TButton;
|
||||||
|
begin
|
||||||
|
timerMath.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);
|
||||||
|
|
||||||
|
i:= 0;
|
||||||
|
j:= vTappyTuxDrawer.GetAnimationCount - 1;
|
||||||
|
while (i<= j) do
|
||||||
|
begin
|
||||||
|
vTappyTuxDrawer.RemoveAnimation(i);
|
||||||
|
j := vTappyTuxDrawer.GetAnimationCount - 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
formTappyTuxGame.GameOver.Visible := true;
|
||||||
|
formTappyTuxGame.Yes.Visible := true;
|
||||||
|
formTappyTuxGame.No.Visible := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
@ -25,6 +25,7 @@ type
|
|||||||
gameSndFX : Boolean;
|
gameSndFX : Boolean;
|
||||||
gameMusic : Boolean;
|
gameMusic : Boolean;
|
||||||
gameQuestionList : TStringList;
|
gameQuestionList : TStringList;
|
||||||
|
count : Integer;
|
||||||
timerWords: TTimer;
|
timerWords: TTimer;
|
||||||
procedure HandleOnTimer(Sender: TObject);
|
procedure HandleOnTimer(Sender: TObject);
|
||||||
public
|
public
|
||||||
@ -47,41 +48,39 @@ uses gameplayform;
|
|||||||
procedure TTappyWords.HandleOnTimer(Sender: TObject);
|
procedure TTappyWords.HandleOnTimer(Sender: TObject);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
j: Integer;
|
||||||
|
frequency: Integer;
|
||||||
begin
|
begin
|
||||||
{for i:= 1 to vTappyTuxDrawer.GetAnimationCount do
|
i:= 0;
|
||||||
begin
|
j:= vTappyTuxDrawer.GetAnimationCount - 1;
|
||||||
if vTappyTuxDrawer.GetAnimation(i).InheritsFrom(TFallingText) then
|
while (i<= j) do
|
||||||
begin
|
|
||||||
vTappyTuxDrawer.GetAnimation(i).;
|
|
||||||
end;
|
|
||||||
|
|
||||||
end;}
|
|
||||||
|
|
||||||
for i:= 1 to 5 do
|
|
||||||
begin
|
|
||||||
Questions[i].Top := Questions[i].Top + (5*gameLevel);
|
|
||||||
if ((Questions[i].Top >= 370)) then
|
|
||||||
begin
|
|
||||||
gameLives := gameLives - 1;
|
|
||||||
formTappyTuxGame.Lives.Text := IntToStr(gameLives);
|
|
||||||
if (gameLives = 0) then EndGame();
|
|
||||||
Questions[i].Top:= 24;
|
|
||||||
Questions[i].Text := formTappyTuxGame.Test.Lines.Strings[random(71)];
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
for i:= 0 to vTappyTuxDrawer.GetAnimationCount - 1 do
|
|
||||||
begin
|
begin
|
||||||
if vTappyTuxDrawer.GetAnimation(i).InheritsFrom(TFallingText) then
|
if vTappyTuxDrawer.GetAnimation(i).InheritsFrom(TFallingText) then
|
||||||
begin
|
begin
|
||||||
vTappyTuxDrawer.GetAnimation(i).StartPoint.y:= vTappyTuxDrawer.GetAnimation(i).StartPoint.y + (5*gameLevel);
|
if (vTappyTuxDrawer.GetAnimation(i).Position.y >= 270) then
|
||||||
vTappyTuxDrawer.GetAnimation(i).EndPoint.y:= vTappyTuxDrawer.GetAnimation(i).StartPoint.y;
|
begin
|
||||||
|
gameLives := gameLives - 1;
|
||||||
|
formTappyTuxGame.Lives.Text := IntToStr(gameLives);
|
||||||
|
vTappyTuxDrawer.RemoveAnimation(i);
|
||||||
|
i := i - 1;
|
||||||
|
if (gameLives = 0) then EndGame();
|
||||||
|
CreateQuestion;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
i := i + 1;
|
||||||
|
j := vTappyTuxDrawer.GetAnimationCount - 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
frequency := 30;
|
||||||
|
count := count + 1;
|
||||||
|
if count >= frequency then
|
||||||
|
begin
|
||||||
|
count := 0;
|
||||||
|
CreateQuestion();
|
||||||
|
end;
|
||||||
|
|
||||||
vTappyTuxDrawer.HandleAnimationOnTimer();
|
vTappyTuxDrawer.HandleAnimationOnTimer();
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TTappyWords.Create;
|
constructor TTappyWords.Create;
|
||||||
@ -119,6 +118,7 @@ var
|
|||||||
lTuxAnimation: TTappySpriteAnimation;
|
lTuxAnimation: TTappySpriteAnimation;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
count := 5;
|
||||||
timerWords.Enabled := True;
|
timerWords.Enabled := True;
|
||||||
gameScore := 0;
|
gameScore := 0;
|
||||||
gameLives := 5;
|
gameLives := 5;
|
||||||
@ -132,8 +132,8 @@ begin
|
|||||||
|
|
||||||
if QuestionList < 0 then QuestionList := 0;
|
if QuestionList < 0 then QuestionList := 0;
|
||||||
gameQuestionList := TStringList.Create;
|
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:/'+IntToStr(QuestionList)+'.txt');
|
gameQuestionList.LoadFromFile('C:/'+IntToStr(QuestionList)+'.txt');
|
||||||
|
|
||||||
formTappyTuxGame.Answer.ReadOnly := false;
|
formTappyTuxGame.Answer.ReadOnly := false;
|
||||||
formTappyTuxGame.GameOver.Visible := false;
|
formTappyTuxGame.GameOver.Visible := false;
|
||||||
@ -143,12 +143,6 @@ begin
|
|||||||
formTappyTuxGame.Score.Text := IntToStr(gameScore);
|
formTappyTuxGame.Score.Text := IntToStr(gameScore);
|
||||||
formTappyTuxGame.Lives.Text := IntToStr(gameLives);
|
formTappyTuxGame.Lives.Text := IntToStr(gameLives);
|
||||||
|
|
||||||
for i:= 1 to 5 do
|
|
||||||
begin
|
|
||||||
//Questions[i].Text := formTappyTuxGame.Test.Lines.Strings[random(71)];
|
|
||||||
Questions[i].Text := gameQuestionList[random(gameQuestionList.Count - 1)];
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Animations Creation
|
// Animations Creation
|
||||||
lTuxAnimation := TTappySpriteAnimation.Create;
|
lTuxAnimation := TTappySpriteAnimation.Create;
|
||||||
lTuxAnimation.IsInfinite := True;
|
lTuxAnimation.IsInfinite := True;
|
||||||
@ -167,9 +161,10 @@ begin
|
|||||||
lTuxAnimation.Bitmaps[5] := lTuxAnimation.Bitmaps[1];
|
lTuxAnimation.Bitmaps[5] := lTuxAnimation.Bitmaps[1];
|
||||||
vTappyTuxDrawer.AddAnimation(lTuxAnimation);
|
vTappyTuxDrawer.AddAnimation(lTuxAnimation);
|
||||||
|
|
||||||
|
|
||||||
for i:= 1 to 5 do
|
for i:= 1 to 5 do
|
||||||
begin
|
begin
|
||||||
CreateQuestion();
|
CreateQuestion;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
@ -177,64 +172,76 @@ end;
|
|||||||
procedure TTappyWords.CreateQuestion();
|
procedure TTappyWords.CreateQuestion();
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
j: Integer;
|
||||||
xAux: Integer;
|
xAux: Integer;
|
||||||
yAux: Integer;
|
yAux: Integer;
|
||||||
|
heightAux: array [0..4] of integer;
|
||||||
|
existenceAux: array [0..4] of boolean;
|
||||||
snowmanAnimation: TFallingText;
|
snowmanAnimation: TFallingText;
|
||||||
existenceAux1, existenceAux2, existenceAux3, existenceAux4, existenceAux5: boolean;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
existenceAux1:= false;
|
|
||||||
existenceAux2:= false;
|
for i:= 0 to 4 do
|
||||||
existenceAux3:= false;
|
begin
|
||||||
existenceAux4:= false;
|
existenceAux[i]:= False;
|
||||||
existenceAux5:= false;
|
heightAux[i] := 500;
|
||||||
|
end;
|
||||||
|
|
||||||
xAux:=5;
|
xAux:=5;
|
||||||
yAux:=5;
|
yAux:=5;
|
||||||
snowmanAnimation := TFallingText.Create;
|
|
||||||
snowmanAnimation.IsInfinite := True;
|
|
||||||
|
|
||||||
if True then
|
snowmanAnimation := TFallingText.Create;
|
||||||
|
snowmanAnimation.IsInfinite := False;
|
||||||
|
|
||||||
|
|
||||||
|
for i:= 0 to vTappyTuxDrawer.GetAnimationCount - 1 do
|
||||||
begin
|
begin
|
||||||
for i:= 0 to vTappyTuxDrawer.GetAnimationCount - 1 do
|
if vTappyTuxDrawer.GetAnimation(i).InheritsFrom(TFallingText) then
|
||||||
begin
|
begin
|
||||||
if vTappyTuxDrawer.GetAnimation(i).InheritsFrom(TFallingText) then
|
for j:= 0 to 4 do
|
||||||
begin
|
begin
|
||||||
if vTappyTuxDrawer.GetAnimation(i).StartPoint.x = 5 then existenceAux1 := True;
|
if vTappyTuxDrawer.GetAnimation(i).StartPoint.X = 5+(103*j) then
|
||||||
if vTappyTuxDrawer.GetAnimation(i).StartPoint.x = 108 then existenceAux2 := True;
|
begin
|
||||||
if vTappyTuxDrawer.GetAnimation(i).StartPoint.x = 211 then existenceAux3 := True;
|
existenceAux[j] := True;
|
||||||
if vTappyTuxDrawer.GetAnimation(i).StartPoint.x = 314 then existenceAux4 := True;
|
if vTappyTuxDrawer.GetAnimation(i).Position.Y < heightAux[j] then heightAux[j] := vTappyTuxDrawer.GetAnimation(i).Position.Y;
|
||||||
if vTappyTuxDrawer.GetAnimation(i).StartPoint.x = 427 then existenceAux5 := True;
|
end;
|
||||||
if vTappyTuxDrawer.GetAnimation(i).StartPoint.y > yAux then
|
end;
|
||||||
begin
|
|
||||||
xAux := vTappyTuxDrawer.GetAnimation(i).StartPoint.x;
|
|
||||||
yAux := vTappyTuxDrawer.GetAnimation(i).StartPoint.y;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if existenceAux1 = false then xAux := 5
|
for i:= 0 to 4 do
|
||||||
|
begin
|
||||||
|
if heightAux[i] > yAux then
|
||||||
|
begin
|
||||||
|
yAux := heightAux[i];
|
||||||
|
xAux := 5 + i*103;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
if existenceAux[0] = false then xAux := 5
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if existenceAux2 = false then xAux := 108
|
if existenceAux[1] = false then xAux := 108
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if existenceAux3 = false then xAux := 211
|
if existenceAux[2] = false then xAux := 211
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if existenceAux4 = false then xAux := 314
|
if existenceAux[3] = false then xAux := 314
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if existenceAux5 = false then xAux := 427
|
if existenceAux[4] = false then xAux := 417
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
snowmanAnimation.StartPoint := Point(xAux, 5);
|
snowmanAnimation.StartPoint := Point(xAux, 5);
|
||||||
snowmanAnimation.EndPoint := snowmanAnimation.StartPoint;
|
snowmanAnimation.EndPoint := Point(xAux, 205);
|
||||||
|
snowmanAnimation.IsInfinite:= false;
|
||||||
snowmanAnimation.Bitmap := TPortableNetworkGraphic.Create;
|
snowmanAnimation.Bitmap := TPortableNetworkGraphic.Create;
|
||||||
snowmanAnimation.QuestionText:= formTappyTuxGame.Test.Lines.Strings[random(71)];
|
snowmanAnimation.caption:= gameQuestionList[random(gameQuestionList.Count - 1)];
|
||||||
snowmanAnimation.Bitmap.LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images' + PathDelim + 'sprites' + PathDelim + 'snowman.png');
|
snowmanAnimation.Bitmap.LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images' + PathDelim + 'sprites' + PathDelim + 'snowman.png');
|
||||||
vTappyTuxDrawer.AddAnimation(snowmanAnimation);
|
vTappyTuxDrawer.AddAnimation(snowmanAnimation);
|
||||||
|
|
||||||
@ -243,26 +250,35 @@ end;
|
|||||||
procedure TTappyWords.Answered;
|
procedure TTappyWords.Answered;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
j: Integer;
|
||||||
begin
|
begin
|
||||||
for i:= 1 to 5 do
|
i:= 0;
|
||||||
|
j:= vTappyTuxDrawer.GetAnimationCount - 1;
|
||||||
|
while (i<= j) do
|
||||||
begin
|
begin
|
||||||
if (formTappyTuxGame.Answer.Text = Questions[i].Text) then
|
if vTappyTuxDrawer.GetAnimation(i).InheritsFrom(TFallingText) then
|
||||||
begin
|
begin
|
||||||
Questions[i].Top := 24;
|
if (vTappyTuxDrawer.GetAnimation(i).caption = formTappyTuxGame.Answer.Text) then
|
||||||
//Questions[i].Text := formTappyTuxGame.Test.Lines.Strings[random(71)];
|
begin
|
||||||
Questions[i].Text := gameQuestionList[random(gameQuestionList.Count - 1)];
|
gameScore := gameScore +1;
|
||||||
gameScore := gameScore +1;
|
gameLevel := (gameScore div 20) + gameSLevel;
|
||||||
gameLevel := (gameScore div 20) + gameSLevel;
|
formTappyTuxGame.Score.Text := IntToStr(gameScore);
|
||||||
formTappyTuxGame.Score.Text := IntToStr(gameScore);
|
formTappyTuxGame.Level.Text := IntToStr(gameLevel);
|
||||||
formTappyTuxGame.Level.Text := IntToStr(gameLevel);
|
vTappyTuxDrawer.RemoveAnimation(i);
|
||||||
|
i := i - 1;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end
|
i := i + 1;
|
||||||
|
j := vTappyTuxDrawer.GetAnimationCount - 1;
|
||||||
|
end;
|
||||||
|
CreateQuestion;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TTappyWords.EndGame;
|
procedure TTappyWords.EndGame;
|
||||||
var
|
var
|
||||||
i : Integer;
|
i : Integer;
|
||||||
|
j : Integer;
|
||||||
gameOverScreen: TTappySpriteAnimation;
|
gameOverScreen: TTappySpriteAnimation;
|
||||||
continueBtn: TButton;
|
continueBtn: TButton;
|
||||||
exitBtn: TButton;
|
exitBtn: TButton;
|
||||||
@ -279,9 +295,12 @@ begin
|
|||||||
//gameOverScreen.Bitmaps[0].LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images' + PathDelim + 'sprites' + PathDelim + 'gameover.png');
|
//gameOverScreen.Bitmaps[0].LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images' + PathDelim + 'sprites' + PathDelim + 'gameover.png');
|
||||||
//vTappyTuxDrawer.AddAnimation(gameOverScreen);
|
//vTappyTuxDrawer.AddAnimation(gameOverScreen);
|
||||||
|
|
||||||
for i:= 1 to vTappyTuxDrawer.GetAnimationCount - 1 do
|
i:= 0;
|
||||||
|
j:= vTappyTuxDrawer.GetAnimationCount - 1;
|
||||||
|
while (i<= j) do
|
||||||
begin
|
begin
|
||||||
vTappyTuxDrawer.GetAnimation(i).Destroy;
|
vTappyTuxDrawer.RemoveAnimation(i);
|
||||||
|
j := vTappyTuxDrawer.GetAnimationCount - 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
formTappyTuxGame.GameOver.Visible := true;
|
formTappyTuxGame.GameOver.Visible := true;
|
||||||
|
@ -19,6 +19,8 @@ type
|
|||||||
CurrentStep: Integer;
|
CurrentStep: Integer;
|
||||||
StepCount: Integer;
|
StepCount: Integer;
|
||||||
IsInfinite: Boolean; // if True the animation will never end
|
IsInfinite: Boolean; // if True the animation will never end
|
||||||
|
caption: String;
|
||||||
|
value: String;
|
||||||
constructor Create; virtual;
|
constructor Create; virtual;
|
||||||
procedure DrawToIntfImg(AIntfImage: TLazIntfImage); virtual;
|
procedure DrawToIntfImg(AIntfImage: TLazIntfImage); virtual;
|
||||||
procedure DrawToCanvas(ACanvas: TCanvas); virtual;
|
procedure DrawToCanvas(ACanvas: TCanvas); virtual;
|
||||||
@ -41,8 +43,6 @@ type
|
|||||||
public
|
public
|
||||||
//StartPoint, EndPoint: TPoint; override;
|
//StartPoint, EndPoint: TPoint; override;
|
||||||
Bitmap: TFPImageBitmap;
|
Bitmap: TFPImageBitmap;
|
||||||
QuestionText: String;
|
|
||||||
QuestionBox: TCanvas;
|
|
||||||
procedure DrawToIntfImg(AIntfImage: TLazIntfImage); override;
|
procedure DrawToIntfImg(AIntfImage: TLazIntfImage); override;
|
||||||
procedure DrawToCanvas(ACanvas: TCanvas); override;
|
procedure DrawToCanvas(ACanvas: TCanvas); override;
|
||||||
procedure ExecuteFinal; override;
|
procedure ExecuteFinal; override;
|
||||||
@ -108,14 +108,12 @@ procedure TFallingText.DrawToIntfImg(AIntfImage: TLazIntfImage);
|
|||||||
begin
|
begin
|
||||||
TTappyTuxDrawer.DrawImageWithTransparentColor(AIntfImage,
|
TTappyTuxDrawer.DrawImageWithTransparentColor(AIntfImage,
|
||||||
Position.X, Position.Y, colFuchsia, Bitmap);
|
Position.X, Position.Y, colFuchsia, Bitmap);
|
||||||
QuestionBox := TCanvas.Create;
|
|
||||||
//QuestionBox.TextOut(lPos.X, lPos.Y, QuestionText);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFallingText.DrawToCanvas(ACanvas: TCanvas);
|
procedure TFallingText.DrawToCanvas(ACanvas: TCanvas);
|
||||||
begin
|
begin
|
||||||
//ACanvas.Pixels[CurrentStep, CurrentStep] := clRed;
|
//ACanvas.Pixels[CurrentStep, CurrentStep] := clRed;
|
||||||
ACanvas.TextOut(StartPoint.X + 30, StartPoint.Y + 50, QuestionText);
|
ACanvas.TextOut(Position.X + 30, Position.Y + 50, caption);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFallingText.ExecuteFinal;
|
procedure TFallingText.ExecuteFinal;
|
||||||
|
@ -95,8 +95,8 @@ var
|
|||||||
begin
|
begin
|
||||||
lDir := vTappyTuxConfig.GetResourcesDir();
|
lDir := vTappyTuxConfig.GetResourcesDir();
|
||||||
|
|
||||||
imgLevel2.LoadFromFile(lDir + 'images'+PathDelim+'levels'+PathDelim+'level2.jpg');
|
imgLevel2.LoadFromFile(lDir + 'images'+PathDelim+'levels'+PathDelim+'levelp.jpg');
|
||||||
imgLevel3.LoadFromFile(lDir + 'images'+PathDelim+'levels'+PathDelim+'level3.jpg');
|
imgLevel3.LoadFromFile(lDir + 'images'+PathDelim+'levels'+PathDelim+'levelp.jpg');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TTappyModule.GetBackgroundImage(ALevel: Integer): TJPEGImage;
|
function TTappyModule.GetBackgroundImage(ALevel: Integer): TJPEGImage;
|
||||||
|
Reference in New Issue
Block a user