diff --git a/applications/tappytux/gameconfigform.pas b/applications/tappytux/gameconfigform.pas index 08a58dea1..c37532a28 100644 --- a/applications/tappytux/gameconfigform.pas +++ b/applications/tappytux/gameconfigform.pas @@ -6,8 +6,10 @@ interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, + // LCL ExtCtrls, - tappymodules, gameplayform{, tappygamedata}; + // TappyTux + tappymodules, gameplayform; type diff --git a/applications/tappytux/gameplayform.lfm b/applications/tappytux/gameplayform.lfm index 39295f46f..7edb6b514 100644 --- a/applications/tappytux/gameplayform.lfm +++ b/applications/tappytux/gameplayform.lfm @@ -1,12 +1,13 @@ object formTappyTuxGame: TformTappyTuxGame - Left = 377 + Left = 375 Height = 425 - Top = 206 + Top = 210 Width = 621 Caption = 'Tappy Tux' ClientHeight = 425 ClientWidth = 621 OnCreate = FormCreate + OnShow = FormShow LCLVersion = '0.9.31' object btnExit: TButton Left = 8 diff --git a/applications/tappytux/gameplayform.pas b/applications/tappytux/gameplayform.pas index 502cf3b95..e7f5734be 100644 --- a/applications/tappytux/gameplayform.pas +++ b/applications/tappytux/gameplayform.pas @@ -6,9 +6,10 @@ interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, + // LCL ExtCtrls, // TappyTux - {GameData,} tappydrawer, tappymodules; + tappydrawer, tappymodules; type @@ -19,6 +20,7 @@ type Answer: TEdit; No: TButton; Yes: TButton; + Question1: TEdit; Question2: TEdit; Question4: TEdit; Question3: TEdit; @@ -26,7 +28,6 @@ type Level: TEdit; Score: TEdit; Lives: TEdit; - Question1: TEdit; LabelLevels: TLabel; LabelScore: TLabel; LabelLives: TLabel; @@ -35,6 +36,7 @@ type procedure btnExitClick(Sender: TObject); procedure AnswerKeyPress(Sender: TObject; var Key: char); procedure FormCreate(Sender: TObject); + procedure FormShow(Sender: TObject); procedure NoClick(Sender: TObject); procedure TestChange(Sender: TObject); procedure YesClick(Sender: TObject); @@ -48,6 +50,7 @@ type var formTappyTuxGame: TformTappyTuxGame; + Questions : array[1..5] of TEdit; implementation @@ -86,6 +89,17 @@ begin vTappyTuxDrawer.Height := Height-vTappyTuxDrawer.Top; vTappyTuxDrawer.Width := Width-vTappyTuxDrawer.Left; vTappyTuxDrawer.SendToBack(); + +end; + +procedure TformTappyTuxGame.FormShow(Sender: TObject); +begin + Questions[1] := Question1; + Questions[2] := Question2; + Questions[3] := Question3; + Questions[4] := Question4; + Questions[5] := Question5; + end; procedure TformTappyTuxGame.NoClick(Sender: TObject); @@ -102,12 +116,13 @@ begin end; procedure TformTappyTuxGame.YesClick(Sender: TObject); +var + i: Integer; begin - Question1.Top := 24; - Question2.Top := 24; - Question3.Top := 24; - Question4.Top := 24; - Question5.Top := 24; + for i:= 1 to 5 do + begin + Questions[i].Top := 24; + end; GetCurrentModule().StartNewGame(formConfig.comboSound.ItemIndex, formConfig.comboMusic.ItemIndex, formConfig.comboLevel.ItemIndex, diff --git a/applications/tappytux/mod_tappymath.pas b/applications/tappytux/mod_tappymath.pas index 59dac1e18..2832accbb 100644 --- a/applications/tappytux/mod_tappymath.pas +++ b/applications/tappytux/mod_tappymath.pas @@ -16,6 +16,7 @@ type { TTappyMath } TTappyMath = class(TTappyModule) + private gameScore : Integer; gameLives : Integer; @@ -25,9 +26,9 @@ type gameMusic : Boolean; questionType : array[1..3] of Integer; questionAnswer : array[1..5] of Integer; - questionNumber : Integer; timerMath : TTimer; procedure HandleOnTimer(Sender: TObject); + public constructor Create; override; destructor Destroy; override; @@ -41,63 +42,26 @@ type implementation -uses tappydrawer, gameplayform {,tappygamedata}; +uses tappydrawer, gameplayform; { TTappyMath } procedure TTappyMath.HandleOnTimer(Sender: TObject); +var + i: Integer; begin - - 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 + 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(); - formTappyTuxGame.Question1.Top:= 24; - QuestionGenerator(1); - 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; - QuestionGenerator(2); - 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; - QuestionGenerator(3); - 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; - QuestionGenerator(4); - 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; - QuestionGenerator(5); - end; + Questions[i].Top:= 24; + QuestionGenerator(i); + end; + end end; @@ -130,6 +94,8 @@ begin end; procedure TTappyMath.StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer); +var + i: Integer; begin timerMath.Enabled := True; @@ -151,62 +117,29 @@ begin formTappyTuxGame.Score.Text := IntToStr(gameScore); formTappyTuxGame.Lives.Text := IntToStr(gameLives); - QuestionGenerator(1); - QuestionGenerator(2); - QuestionGenerator(3); - QuestionGenerator(4); - QuestionGenerator(5); + for i:= 1 to 5 do + begin + QuestionGenerator(i); + end end; procedure TTappyMath.Answered; +var + i: Integer; begin - - if (formTappyTuxGame.Answer.Text = IntToStr(questionAnswer[1])) then + for i:= 1 to 5 do begin - formTappyTuxGame.Question1.Top := 24; - QuestionGenerator(1); + if (formTappyTuxGame.Answer.Text = IntToStr(questionAnswer[i])) then + begin + Questions[i].Top := 24; + QuestionGenerator(i); gameScore := gameScore +1; gameLevel := (gameScore div 20) + gameSLevel; formTappyTuxGame.Score.Text := IntToStr(gameScore); formTappyTuxGame.Level.Text := IntToStr(gameLevel); - end; - if (formTappyTuxGame.Answer.Text = IntToStr(questionAnswer[2])) then - begin - formTappyTuxGame.Question2.Top := 24; - QuestionGenerator(2); - gameScore := gameScore +1; - gameLevel := (gameScore div 20) + gameSLevel; - formTappyTuxGame.Score.Text := IntToStr(gameScore); - formTappyTuxGame.Level.Text := IntToStr(gameLevel); - end; - if (formTappyTuxGame.Answer.Text = IntToStr(questionAnswer[3])) then - begin - formTappyTuxGame.Question3.Top := 24; - QuestionGenerator(3); - gameScore := gameScore +1; - gameLevel := (gameScore div 20) + gameSLevel; - formTappyTuxGame.Score.Text := IntToStr(gameScore); - formTappyTuxGame.Level.Text := IntToStr(gameLevel); - end; - if (formTappyTuxGame.Answer.Text = IntToStr(questionAnswer[4])) then - begin - formTappyTuxGame.Question4.Top := 24; - QuestionGenerator(4); - gameScore := gameScore +1; - gameLevel := (gameScore div 20) + gameSLevel; - formTappyTuxGame.Score.Text := IntToStr(gameScore); - formTappyTuxGame.Level.Text := IntToStr(gameLevel); - end; - if (formTappyTuxGame.Answer.Text = IntToStr(questionAnswer[5])) then - begin - formTappyTuxGame.Question5.Top := 24; - QuestionGenerator(5); - gameScore := gameScore +1; - gameLevel := (gameScore div 20) + gameSLevel; - formTappyTuxGame.Score.Text := IntToStr(gameScore); - formTappyTuxGame.Level.Text := IntToStr(gameLevel); - end; + end; + end end; @@ -229,33 +162,21 @@ begin questionType[2] := random(21); questionType[3] := random(21); questionAnswer[qNumber] := questionType[2] + questionType[3]; - if (qNumber = 1) then formTappyTuxGame.Question1.Text := IntToStr(questionType[2])+' + ' +IntToStr(questionType[3]); - if (qNumber = 2) then formTappyTuxGame.Question2.Text := IntToStr(questionType[2])+' + ' +IntToStr(questionType[3]); - if (qNumber = 3) then formTappyTuxGame.Question3.Text := IntToStr(questionType[2])+' + ' +IntToStr(questionType[3]); - if (qNumber = 4) then formTappyTuxGame.Question4.Text := IntToStr(questionType[2])+' + ' +IntToStr(questionType[3]); - if (qNumber = 5) then formTappyTuxGame.Question5.Text := IntToStr(questionType[2])+' + ' +IntToStr(questionType[3]); + Questions[qNumber].Text := IntToStr(questionType[2])+' + ' +IntToStr(questionType[3]); end; 1: begin questionType[2] := random(21); questionType[3] := random(questionType[2]); questionAnswer[qNumber] := questionType[2] - questionType[3]; - if (qNumber = 1) then formTappyTuxGame.Question1.Text := IntToStr(questionType[2])+' - ' +IntToStr(questionType[3]); - if (qNumber = 2) then formTappyTuxGame.Question2.Text := IntToStr(questionType[2])+' - ' +IntToStr(questionType[3]); - if (qNumber = 3) then formTappyTuxGame.Question3.Text := IntToStr(questionType[2])+' - ' +IntToStr(questionType[3]); - if (qNumber = 4) then formTappyTuxGame.Question4.Text := IntToStr(questionType[2])+' - ' +IntToStr(questionType[3]); - if (qNumber = 5) then formTappyTuxGame.Question5.Text := IntToStr(questionType[2])+' - ' +IntToStr(questionType[3]); + Questions[qNumber].Text := IntToStr(questionType[2])+' - ' +IntToStr(questionType[3]); end; 2: begin questionType[2] := random(11); questionType[3] := random(11); questionAnswer[qNumber] := questionType[2] * questionType[3]; - if (qNumber = 1) then formTappyTuxGame.Question1.Text := IntToStr(questionType[2])+' x ' +IntToStr(questionType[3]); - if (qNumber = 2) then formTappyTuxGame.Question2.Text := IntToStr(questionType[2])+' x ' +IntToStr(questionType[3]); - if (qNumber = 3) then formTappyTuxGame.Question3.Text := IntToStr(questionType[2])+' x ' +IntToStr(questionType[3]); - if (qNumber = 4) then formTappyTuxGame.Question4.Text := IntToStr(questionType[2])+' x ' +IntToStr(questionType[3]); - if (qNumber = 5) then formTappyTuxGame.Question5.Text := IntToStr(questionType[2])+' x ' +IntToStr(questionType[3]); + Questions[qNumber].Text := IntToStr(questionType[2])+' x ' +IntToStr(questionType[3]); end; end; diff --git a/applications/tappytux/mod_tappywords.pas b/applications/tappytux/mod_tappywords.pas index 9b0cea293..22ad9454b 100644 --- a/applications/tappytux/mod_tappywords.pas +++ b/applications/tappytux/mod_tappywords.pas @@ -5,17 +5,18 @@ unit mod_tappywords; interface uses - Classes, SysUtils, + Classes, SysUtils, FileUtil, // LCL ExtCtrls, // TappyTux - tappymodules{, tappygamedata}; + tappyconfig, tappymodules; type { TTappyWords } TTappyWords = class(TTappyModule) + private gameScore : Integer; gameLives : Integer; @@ -24,11 +25,9 @@ type gameSndFX : Boolean; gameMusic : Boolean; gameQuestionList : Integer; - gameFile : Text; - aux : string; timerWords: TTimer; - {newGame : TTappyGameData;} procedure HandleOnTimer(Sender: TObject); + public constructor Create; override; destructor Destroy; override; @@ -39,6 +38,7 @@ type procedure EndGame(); override; end; + implementation uses tappydrawer, gameplayform; @@ -46,62 +46,22 @@ uses tappydrawer, gameplayform; { TTappyWords } procedure TTappyWords.HandleOnTimer(Sender: TObject); +var + i: Integer; begin - //vTappyTuxDrawer.HandleAnimationOnTimer(); - 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 + 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(); - formTappyTuxGame.Question1.Top:= 24; - formTappyTuxGame.Question1.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; - end; + Questions[i].Top:= 24; + Questions[i].Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; + end; + 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; - formTappyTuxGame.Question2.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; - 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; - formTappyTuxGame.Question3.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; - 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; - formTappyTuxGame.Question4.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; - 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; - formTappyTuxGame.Question5.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; - end; - - - // Create falling ballons here - //vTappyTuxDrawer.AddAnimation(TBallonAnimation.Create); end; constructor TTappyWords.Create; @@ -133,13 +93,9 @@ begin end; procedure TTappyWords.StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer); +var + i: Integer; begin - - //Causam "External: SIGSEGV" - //gameData.SetSndFX(SndFX); - //gameData.SetMusic(Music); - //gameData.SetLevel(Level); - timerWords.Enabled := True; gameScore := 0; gameLives := 5; @@ -159,71 +115,29 @@ begin formTappyTuxGame.Score.Text := IntToStr(gameScore); formTappyTuxGame.Lives.Text := IntToStr(gameLives); - formTappyTuxGame.Question1.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; - formTappyTuxGame.Question2.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; - formTappyTuxGame.Question3.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; - formTappyTuxGame.Question4.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; - formTappyTuxGame.Question5.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; - - //gameQuestionList := QuestionList; - //if gameQuestionList < 0 then gameQuestionList := 0; - //Assign(gameFile, {IntToStr(gameQuestionList)}'4.txt') - //gameFile := SearchFile; - //Reset(gameFile); - //Readln(gameFile, aux); - //formTappyTuxGame.Question1.Text := aux; - - //Assign(gameFile, gameQuestionList+'.txt'); + for i:= 1 to 5 do + begin + Questions[i].Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; + end end; procedure TTappyWords.Answered; +var + i: Integer; begin - if (formTappyTuxGame.Answer.Text = formTappyTuxGame.Question1.Text) then + for i:= 1 to 5 do begin - formTappyTuxGame.Question1.Top := 24; - formTappyTuxGame.Question1.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; + if (formTappyTuxGame.Answer.Text = Questions[i].Text) then + begin + Questions[i].Top := 24; + Questions[i].Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; 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; - formTappyTuxGame.Question2.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; - 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; - formTappyTuxGame.Question3.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; - 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; - formTappyTuxGame.Question4.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; - 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; - formTappyTuxGame.Question5.Text := formTappyTuxGame.Test.Lines.Strings[random(71)]; - gameScore := gameScore +1; - gameLevel := (gameScore div 20) + gameSLevel; - formTappyTuxGame.Score.Text := IntToStr(gameScore); - formTappyTuxGame.Level.Text := IntToStr(gameLevel); - end; + end; + end end; diff --git a/applications/tappytux/tappymodules.pas b/applications/tappytux/tappymodules.pas index 74f64a0ea..0e8a8ace7 100644 --- a/applications/tappytux/tappymodules.pas +++ b/applications/tappytux/tappymodules.pas @@ -6,6 +6,7 @@ interface uses Classes, SysUtils, Graphics, + // TappyTux tappyconfig; type @@ -95,7 +96,6 @@ begin imgLevel2.LoadFromFile(lDir + 'images'+PathDelim+'levels'+PathDelim+'level2.jpg'); imgLevel3.LoadFromFile(lDir + 'images'+PathDelim+'levels'+PathDelim+'level3.jpg'); - //imgPenguim.LoadFromFile(lDir + 'images'+PathDelim+'sprites'+PathDelim+'tuxside.xmp'); end; function TTappyModule.GetBackgroundImage(ALevel: Integer): TJPEGImage;