2011-09-10 21:30:22 +00:00
|
|
|
unit mod_tappywords;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Classes, SysUtils,
|
2011-09-15 14:34:06 +00:00
|
|
|
// LCL
|
|
|
|
ExtCtrls,
|
|
|
|
// TappyTux
|
2011-10-25 14:29:52 +00:00
|
|
|
tappymodules{, tappygamedata};
|
2011-09-10 21:30:22 +00:00
|
|
|
|
|
|
|
type
|
2011-09-10 21:42:25 +00:00
|
|
|
|
|
|
|
{ TTappyWords }
|
|
|
|
|
2011-09-10 21:30:22 +00:00
|
|
|
TTappyWords = class(TTappyModule)
|
2011-09-15 14:34:06 +00:00
|
|
|
private
|
2011-10-25 14:29:52 +00:00
|
|
|
gameScore : Integer;
|
|
|
|
gameLives : Integer;
|
|
|
|
gameLevel : Integer;
|
|
|
|
gameSLevel : Integer;
|
|
|
|
gameSndFX : Boolean;
|
|
|
|
gameMusic : Boolean;
|
2011-09-15 14:34:06 +00:00
|
|
|
timerWords: TTimer;
|
2011-10-25 14:29:52 +00:00
|
|
|
{newGame : TTappyGameData;}
|
2011-09-15 14:34:06 +00:00
|
|
|
procedure HandleOnTimer(Sender: TObject);
|
2011-09-10 21:30:22 +00:00
|
|
|
public
|
2011-09-10 21:42:25 +00:00
|
|
|
constructor Create; override;
|
2011-09-15 14:34:06 +00:00
|
|
|
destructor Destroy; override;
|
2011-09-10 21:42:25 +00:00
|
|
|
procedure TranslateTextsToEnglish; override;
|
|
|
|
procedure TranslateTextsToPortuguese; override;
|
2011-10-24 19:51:13 +00:00
|
|
|
procedure StartNewGame(SndFX: Integer; Music: Integer; Level: Integer); override;
|
2011-10-25 10:21:59 +00:00
|
|
|
procedure Answered(); override;
|
2011-09-15 14:34:06 +00:00
|
|
|
procedure EndGame(); override;
|
2011-09-10 21:30:22 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2011-10-24 23:09:39 +00:00
|
|
|
uses tappydrawer, gameplayform;
|
2011-10-24 19:51:13 +00:00
|
|
|
|
2011-09-10 21:42:25 +00:00
|
|
|
{ TTappyWords }
|
|
|
|
|
2011-09-15 14:34:06 +00:00
|
|
|
procedure TTappyWords.HandleOnTimer(Sender: TObject);
|
|
|
|
begin
|
2011-10-24 23:09:39 +00:00
|
|
|
//vTappyTuxDrawer.HandleAnimationOnTimer();
|
2011-10-25 14:29:52 +00:00
|
|
|
formTappyTuxGame.Question1.Top:= formTappyTuxGame.Question1.Top + (5*gameLevel);
|
|
|
|
formTappyTuxGame.Question2.Top:= formTappyTuxGame.Question2.Top + (5*gameLevel);
|
|
|
|
formTappyTuxGame.Question3.Top:= formTappyTuxGame.Question3.Top + (5*gameLevel);
|
|
|
|
formTappyTuxGame.Question4.Top:= formTappyTuxGame.Question4.Top + (5*gameLevel);
|
|
|
|
formTappyTuxGame.Question5.Top:= formTappyTuxGame.Question5.Top + (5*gameLevel);
|
|
|
|
|
|
|
|
if ((formTappyTuxGame.Question1.Top >= 370)) then
|
|
|
|
begin
|
|
|
|
gameLives := gameLives - 1;
|
|
|
|
formTappyTuxGame.Lives.Text := IntToStr(gameLives);
|
|
|
|
if (gameLives = 0) then EndGame();
|
|
|
|
formTappyTuxGame.Question1.Top:= 24;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if ((formTappyTuxGame.Question2.Top >= 370)) then
|
|
|
|
begin
|
|
|
|
gameLives := gameLives - 1;
|
|
|
|
formTappyTuxGame.Lives.Text := IntToStr(gameLives);
|
|
|
|
if (gameLives = 0) then EndGame();
|
|
|
|
formTappyTuxGame.Question2.Top:= 24;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if ((formTappyTuxGame.Question3.Top >= 370)) then
|
|
|
|
begin
|
|
|
|
gameLives := gameLives - 1;
|
|
|
|
formTappyTuxGame.Lives.Text := IntToStr(gameLives);
|
|
|
|
if (gameLives = 0) then EndGame();
|
|
|
|
formTappyTuxGame.Question3.Top:= 24;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if ((formTappyTuxGame.Question4.Top >= 370)) then
|
|
|
|
begin
|
|
|
|
gameLives := gameLives - 1;
|
|
|
|
formTappyTuxGame.Lives.Text := IntToStr(gameLives);
|
|
|
|
if (gameLives = 0) then EndGame();
|
|
|
|
formTappyTuxGame.Question4.Top:= 24;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if ((formTappyTuxGame.Question5.Top >= 370)) then
|
|
|
|
begin
|
|
|
|
gameLives := gameLives - 1;
|
|
|
|
formTappyTuxGame.Lives.Text := IntToStr(gameLives);
|
|
|
|
if (gameLives = 0) then EndGame();
|
|
|
|
formTappyTuxGame.Question5.Top:= 24;
|
|
|
|
end;
|
|
|
|
|
2011-09-15 14:34:06 +00:00
|
|
|
|
|
|
|
// Create falling ballons here
|
2011-10-24 23:09:39 +00:00
|
|
|
//vTappyTuxDrawer.AddAnimation(TBallonAnimation.Create);
|
2011-09-15 14:34:06 +00:00
|
|
|
end;
|
|
|
|
|
2011-09-10 21:42:25 +00:00
|
|
|
constructor TTappyWords.Create;
|
|
|
|
begin
|
|
|
|
inherited Create;
|
2011-09-15 14:34:06 +00:00
|
|
|
|
|
|
|
timerWords := TTimer.Create(nil);
|
|
|
|
timerWords.Enabled := False;
|
|
|
|
timerWords.Interval := 1000;
|
|
|
|
timerWords.OnTimer := @HandleOnTimer;
|
2011-10-24 19:51:13 +00:00
|
|
|
|
2011-09-15 14:34:06 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TTappyWords.Destroy;
|
|
|
|
begin
|
|
|
|
timerWords.Free;
|
|
|
|
|
|
|
|
inherited Destroy;
|
2011-09-10 21:42:25 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TTappyWords.TranslateTextsToEnglish;
|
|
|
|
begin
|
|
|
|
ShortDescription := 'TappyWords - A game to learn typing and ortography';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TTappyWords.TranslateTextsToPortuguese;
|
|
|
|
begin
|
|
|
|
ShortDescription := 'TappyWords - Um jogo para aprender a digitar e ortografia';
|
|
|
|
end;
|
|
|
|
|
2011-10-24 19:51:13 +00:00
|
|
|
procedure TTappyWords.StartNewGame(SndFX: Integer; Music: Integer; Level: Integer);
|
2011-09-15 14:34:06 +00:00
|
|
|
begin
|
2011-10-24 19:51:13 +00:00
|
|
|
|
|
|
|
//Causam "External: SIGSEGV"
|
2011-10-24 23:09:39 +00:00
|
|
|
//gameData.SetSndFX(SndFX);
|
|
|
|
//gameData.SetMusic(Music);
|
|
|
|
//gameData.SetLevel(Level);
|
2011-10-24 19:51:13 +00:00
|
|
|
|
2011-09-15 14:34:06 +00:00
|
|
|
timerWords.Enabled := True;
|
2011-10-25 14:29:52 +00:00
|
|
|
gameScore := 0;
|
|
|
|
gameLives := 5;
|
|
|
|
gameLevel := Level+1;
|
|
|
|
if (Level < 0) then gameLevel := 1;
|
|
|
|
if (SndFX <= 0) then gameSndFX := true;
|
|
|
|
if (SndFX = 1) then gameSndFX := false;
|
|
|
|
if (Music <= 0) then gameMusic := true;
|
|
|
|
if (Music = 1) then gameMusic := false;
|
|
|
|
gameSLevel := gameLevel;
|
|
|
|
|
|
|
|
formTappyTuxGame.Answer.ReadOnly := false;
|
|
|
|
formTappyTuxGame.GameOver.Visible := false;
|
|
|
|
formTappyTuxGame.Yes.Visible := false;
|
|
|
|
formTappyTuxGame.No.Visible := false;
|
|
|
|
formTappyTuxGame.Level.Text := IntToStr(gameLevel);
|
|
|
|
formTappyTuxGame.Score.Text := IntToStr(gameScore);
|
|
|
|
formTappyTuxGame.Lives.Text := IntToStr(gameLives);
|
2011-10-24 19:51:13 +00:00
|
|
|
|
2011-10-25 14:29:52 +00:00
|
|
|
end;
|
2011-09-15 14:34:06 +00:00
|
|
|
|
2011-10-25 10:21:59 +00:00
|
|
|
procedure TTappyWords.Answered;
|
|
|
|
begin
|
2011-10-25 14:29:52 +00:00
|
|
|
if (formTappyTuxGame.Answer.Text = formTappyTuxGame.Question1.Text) then
|
|
|
|
begin
|
|
|
|
formTappyTuxGame.Question1.Top := 24;
|
|
|
|
gameScore := gameScore +1;
|
|
|
|
gameLevel := (gameScore div 20) + gameSLevel;
|
|
|
|
formTappyTuxGame.Score.Text := IntToStr(gameScore);
|
|
|
|
formTappyTuxGame.Level.Text := IntToStr(gameLevel);
|
|
|
|
end;
|
|
|
|
if (formTappyTuxGame.Answer.Text = formTappyTuxGame.Question2.Text) then
|
|
|
|
begin
|
|
|
|
formTappyTuxGame.Question2.Top := 24;
|
|
|
|
gameScore := gameScore +1;
|
|
|
|
gameLevel := (gameScore div 20) + gameSLevel;
|
|
|
|
formTappyTuxGame.Score.Text := IntToStr(gameScore);
|
|
|
|
formTappyTuxGame.Level.Text := IntToStr(gameLevel);
|
|
|
|
end;
|
|
|
|
if (formTappyTuxGame.Answer.Text = formTappyTuxGame.Question3.Text) then
|
|
|
|
begin
|
|
|
|
formTappyTuxGame.Question3.Top := 24;
|
|
|
|
gameScore := gameScore +1;
|
|
|
|
gameLevel := (gameScore div 20) + gameSLevel;
|
|
|
|
formTappyTuxGame.Score.Text := IntToStr(gameScore);
|
|
|
|
formTappyTuxGame.Level.Text := IntToStr(gameLevel);
|
|
|
|
end;
|
|
|
|
if (formTappyTuxGame.Answer.Text = formTappyTuxGame.Question4.Text) then
|
|
|
|
begin
|
|
|
|
formTappyTuxGame.Question4.Top := 24;
|
|
|
|
gameScore := gameScore +1;
|
|
|
|
gameLevel := (gameScore div 20) + gameSLevel;
|
|
|
|
formTappyTuxGame.Score.Text := IntToStr(gameScore);
|
|
|
|
formTappyTuxGame.Level.Text := IntToStr(gameLevel);
|
|
|
|
end;
|
|
|
|
if (formTappyTuxGame.Answer.Text = formTappyTuxGame.Question5.Text) then
|
|
|
|
begin
|
|
|
|
formTappyTuxGame.Question5.Top := 24;
|
|
|
|
gameScore := gameScore +1;
|
|
|
|
gameLevel := (gameScore div 20) + gameSLevel;
|
|
|
|
formTappyTuxGame.Score.Text := IntToStr(gameScore);
|
|
|
|
formTappyTuxGame.Level.Text := IntToStr(gameLevel);
|
|
|
|
end;
|
2011-10-25 10:21:59 +00:00
|
|
|
|
|
|
|
end;
|
|
|
|
|
2011-09-15 14:34:06 +00:00
|
|
|
procedure TTappyWords.EndGame;
|
|
|
|
begin
|
|
|
|
timerWords.Enabled := False;
|
2011-10-25 14:29:52 +00:00
|
|
|
formTappyTuxGame.Answer.ReadOnly := true;
|
|
|
|
formTappyTuxGame.GameOver.Visible := true;
|
|
|
|
formTappyTuxGame.Yes.Visible := true;
|
|
|
|
formTappyTuxGame.No.Visible := true;
|
2011-09-15 14:34:06 +00:00
|
|
|
end;
|
|
|
|
|
2011-09-10 21:42:25 +00:00
|
|
|
initialization
|
|
|
|
AddModule(TTappyWords.Create);
|
2011-09-10 21:30:22 +00:00
|
|
|
end.
|
|
|
|
|